@FixFor( "MODE-2178" ) @Test public void shouldAllowQueryForPropertyWithEmptyStringAsCriteria() throws RepositoryException { String[] columnNames = {"car:engine", "car:maker", "car:model", "car:year", "car:userRating"}; String queryStr = "SELECT [car:engine], [car:maker], [car:model], [car:year], [car:userRating] FROM [car:Car]"; Query query = session.getWorkspace().getQueryManager().createQuery(queryStr, Query.JCR_SQL2); validateQuery().rowCount(13L).hasColumns(columnNames).validate(query, query.execute()); queryStr = "SELECT [car:engine], [car:maker], [car:model], [car:year], [car:userRating] FROM [car:Car] WHERE LENGTH([car:engine]) = 0"; query = session.getWorkspace().getQueryManager().createQuery(queryStr, Query.JCR_SQL2); validateQuery().rowCount(8L).hasColumns(columnNames).validate(query, query.execute()); queryStr = "SELECT [car:engine], [car:maker], [car:model], [car:year], [car:userRating] FROM [car:Car] WHERE [car:engine] IS NULL OR [car:engine] = ''"; query = session.getWorkspace().getQueryManager().createQuery(queryStr, Query.JCR_SQL2); validateQuery().rowCount(8L).hasColumns(columnNames).validate(query, query.execute()); queryStr = "SELECT * FROM [car:Car] WHERE LENGTH([car:engine]) = 0"; query = session.getWorkspace().getQueryManager().createQuery(queryStr, Query.JCR_SQL2); validateQuery().rowCount(8L).validate(query, query.execute()); queryStr = "SELECT [car:engine], [car:maker], [car:model], [car:year], [car:userRating] FROM [car:Car] WHERE [car:engine] = ''"; query = session.getWorkspace().getQueryManager().createQuery(queryStr, Query.JCR_SQL2); validateQuery().rowCount(0L).hasColumns(columnNames).validate(query, query.execute()); Node car = session.getNode("/Cars/Hybrid/Toyota Prius"); assertThat(car.hasProperty("car:engine"), is(false)); try { car.setProperty("car:engine", ""); session.save(); query = session.getWorkspace().getQueryManager().createQuery(queryStr, Query.JCR_SQL2); validateQuery().rowCount(1L).hasColumns(columnNames).validate(query, query.execute()); } finally { car.getProperty("car:engine").remove(); session.save(); } }
@Override public org.modeshape.jcr.api.query.Query createQuery( String statement, String language ) throws InvalidQueryException, RepositoryException { CheckArg.isNotNull(statement, "statement"); CheckArg.isNotNull(language, "language"); return createQuery(statement, language, null, null); }
JcrQueryManager implements QueryManager { @Override public org.modeshape.jcr.api.query.Query createQuery( String statement, String language ) throws InvalidQueryException, RepositoryException { CheckArg.isNotNull(statement, "statement"); CheckArg.isNotNull(language, "language"); return createQuery(statement, language, null, null); } }
JcrQueryManager implements QueryManager { @Override public org.modeshape.jcr.api.query.Query createQuery( String statement, String language ) throws InvalidQueryException, RepositoryException { CheckArg.isNotNull(statement, "statement"); CheckArg.isNotNull(language, "language"); return createQuery(statement, language, null, null); } JcrQueryManager( JcrSession session ); }
JcrQueryManager implements QueryManager { @Override public org.modeshape.jcr.api.query.Query createQuery( String statement, String language ) throws InvalidQueryException, RepositoryException { CheckArg.isNotNull(statement, "statement"); CheckArg.isNotNull(language, "language"); return createQuery(statement, language, null, null); } JcrQueryManager( JcrSession session ); @Override org.modeshape.jcr.api.query.qom.QueryObjectModelFactory getQOMFactory(); @Override org.modeshape.jcr.api.query.Query createQuery( String statement,
                                                          String language ); @Override org.modeshape.jcr.api.query.Query createQuery( String statement, 
                                                          String language,
                                                          Locale locale ); org.modeshape.jcr.api.query.Query createQuery( String expression,
                                                          String language,
                                                          Path storedAtPath, 
                                                          Locale locale ); Query createQuery( QueryCommand command ); @Override org.modeshape.jcr.api.query.Query getQuery( Node node ); @Override String[] getSupportedQueryLanguages(); }
JcrQueryManager implements QueryManager { @Override public org.modeshape.jcr.api.query.Query createQuery( String statement, String language ) throws InvalidQueryException, RepositoryException { CheckArg.isNotNull(statement, "statement"); CheckArg.isNotNull(language, "language"); return createQuery(statement, language, null, null); } JcrQueryManager( JcrSession session ); @Override org.modeshape.jcr.api.query.qom.QueryObjectModelFactory getQOMFactory(); @Override org.modeshape.jcr.api.query.Query createQuery( String statement,
                                                          String language ); @Override org.modeshape.jcr.api.query.Query createQuery( String statement, 
                                                          String language,
                                                          Locale locale ); org.modeshape.jcr.api.query.Query createQuery( String expression,
                                                          String language,
                                                          Path storedAtPath, 
                                                          Locale locale ); Query createQuery( QueryCommand command ); @Override org.modeshape.jcr.api.query.Query getQuery( Node node ); @Override String[] getSupportedQueryLanguages();  }