From a1fefd64ef3f2e8338d0ca90b7057d47f838becb Mon Sep 17 00:00:00 2001 From: Andrew Hind Date: Mon, 9 Sep 2013 10:55:39 +0000 Subject: [PATCH] Fix for ALF-19901 Metadata query CMIS QL queries need to do outer joins for "is null" and "order by" git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@55121 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../metadata-query-common-SqlMap.xml | 18 +++--- .../impl/querymodel/impl/db/DBOrdering.java | 3 + .../querymodel/impl/db/ParentSupport.java | 12 +++- .../querymodel/impl/db/PropertySupport.java | 31 +++++++++- .../impl/querymodel/impl/db/TypeSupport.java | 10 ++++ .../impl/querymodel/impl/db/UUIDSupport.java | 10 ++++ .../impl/db/functions/DBExists.java | 7 +++ .../impl/querymodel/impl/db/DBQueryTest.java | 57 ++++++++++--------- 8 files changed, 109 insertions(+), 39 deletions(-) diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/metadata-query-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/metadata-query-common-SqlMap.xml index 93bd52d1cf..0837e3cd8c 100644 --- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/metadata-query-common-SqlMap.xml +++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/metadata-query-common-SqlMap.xml @@ -16,23 +16,23 @@ - join alf_child_assoc ${item.alias} on (${item.alias}.child_node_id = node.id) + left outer join alf_child_assoc ${item.alias} on (${item.alias}.child_node_id = node.id) - join alf_node_properties ${item.alias} on ((${item.alias}.node_id = node.id) AND (#{item.qnameId} = ${item.alias}.qname_id)) + left outer join alf_node_properties ${item.alias} on ((${item.alias}.node_id = node.id) AND (#{item.qnameId} = ${item.alias}.qname_id)) - join alf_node_properties ${item.alias}_p on ((${item.alias}_p.node_id = node.id) AND (#{item.qnameId} = ${item.alias}_p.qname_id)) - join alf_content_data ${item.alias}_cd on (${item.alias}_cd.id = ${item.alias}_p.long_value) - join alf_mimetype ${item.alias} on (${item.alias}_cd.content_mimetype_id = ${item.alias}.id) + left outer join alf_node_properties ${item.alias}_p on ((${item.alias}_p.node_id = node.id) AND (#{item.qnameId} = ${item.alias}_p.qname_id)) + left outer join alf_content_data ${item.alias}_cd on (${item.alias}_cd.id = ${item.alias}_p.long_value) + left outer join alf_mimetype ${item.alias} on (${item.alias}_cd.content_mimetype_id = ${item.alias}.id) - join alf_node_properties ${item.alias}_p on ((${item.alias}_p.node_id = node.id) AND (#{item.qnameId} = ${item.alias}_p.qname_id)) - join alf_content_data ${item.alias}_cd on (${item.alias}_cd.id = ${item.alias}_p.long_value) - join alf_content_url ${item.alias} on (${item.alias}.id = ${item.alias}_cd.content_url_id) + left outer join alf_node_properties ${item.alias}_p on ((${item.alias}_p.node_id = node.id) AND (#{item.qnameId} = ${item.alias}_p.qname_id)) + left outer join alf_content_data ${item.alias}_cd on (${item.alias}_cd.id = ${item.alias}_p.long_value) + left outer join alf_content_url ${item.alias} on (${item.alias}.id = ${item.alias}_cd.content_url_id) - join alf_node_aspects ${item.alias} on (${item.alias}.node_id = node.id) + left outer join alf_node_aspects ${item.alias} on (${item.alias}.node_id = node.id) diff --git a/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBOrdering.java b/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBOrdering.java index 34f7f30e55..e923a5a130 100644 --- a/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBOrdering.java +++ b/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/DBOrdering.java @@ -114,6 +114,7 @@ public class DBOrdering extends BaseOrdering implements DBQueryBuilderComponent propertySupport.setJoinCommandType(DBQueryBuilderJoinCommandType.CONTENT_MIMETYPE); propertySupport.setFieldName("mimetype_str"); propertySupport.setCommandType(DBQueryBuilderPredicatePartCommandType.ORDER); + propertySupport.setLeftOuter(true); builderSupport = propertySupport; } else if (property.getPropertyName().equals(PropertyIds.CONTENT_STREAM_LENGTH)) @@ -134,6 +135,7 @@ public class DBOrdering extends BaseOrdering implements DBQueryBuilderComponent propertySupport.setJoinCommandType(DBQueryBuilderJoinCommandType.CONTENT_URL); propertySupport.setFieldName("content_size"); propertySupport.setCommandType(DBQueryBuilderPredicatePartCommandType.ORDER); + propertySupport.setLeftOuter(true); builderSupport = propertySupport; } else @@ -153,6 +155,7 @@ public class DBOrdering extends BaseOrdering implements DBQueryBuilderComponent propertySupport.setJoinCommandType(DBQuery.getJoinCommandType(propertyQName)); propertySupport.setFieldName(DBQuery.getFieldName(dictionaryService, propertyQName)); propertySupport.setCommandType(DBQueryBuilderPredicatePartCommandType.ORDER); + propertySupport.setLeftOuter(true); builderSupport = propertySupport; } } diff --git a/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/ParentSupport.java b/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/ParentSupport.java index 4a183f61bf..88ff7d1f7f 100644 --- a/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/ParentSupport.java +++ b/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/ParentSupport.java @@ -40,6 +40,8 @@ public class ParentSupport implements DBQueryBuilderComponent DBQueryBuilderPredicatePartCommandType commandType; + private boolean leftOuter; + /** * @param dbid * the dbid to set @@ -103,7 +105,7 @@ public class ParentSupport implements DBQueryBuilderComponent DBQueryBuilderJoinCommand join = new DBQueryBuilderJoinCommand(); alias = "PARENT_" + multiJoins.size(); join.setAlias(alias); - join.setOuter(false); + join.setOuter(leftOuter); join.setType(DBQueryBuilderJoinCommandType.PARENT); multiJoins.add(join); @@ -128,4 +130,12 @@ public class ParentSupport implements DBQueryBuilderComponent } + /** + * @param leftOuter + */ + public void setLeftOuter(boolean leftOuter) + { + this.leftOuter = leftOuter; + } + } \ No newline at end of file diff --git a/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/PropertySupport.java b/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/PropertySupport.java index 8f16f78d57..b62f23b841 100644 --- a/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/PropertySupport.java +++ b/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/PropertySupport.java @@ -58,6 +58,8 @@ public class PropertySupport implements DBQueryBuilderComponent DBQueryBuilderPredicatePartCommandType commandType; LuceneFunction luceneFunction; + + private boolean leftOuter; /** * @param pair @@ -171,7 +173,7 @@ public class PropertySupport implements DBQueryBuilderComponent join = new DBQueryBuilderJoinCommand(); alias = "PROP_" + singleJoins.size(); join.setAlias(alias); - join.setOuter(false); + join.setOuter(leftOuter); join.setType(joinCommandType); join.setQnameId(pair.getFirst()); singleJoins.put(propertyQName, join); @@ -185,6 +187,10 @@ public class PropertySupport implements DBQueryBuilderComponent if(join != null) { alias = join.getAlias(); + if(leftOuter) + { + join.setOuter(true); + } } } @@ -301,14 +307,25 @@ public class PropertySupport implements DBQueryBuilderComponent case CONTENT_MIMETYPE: command.setAlias(alias); command.setType(commandType); + + // Good for order and predicates command.setValue(value); command.setValues(values); + break; case CONTENT_URL: command.setAlias(alias); command.setType(commandType); - command.setValue(DefaultTypeConverter.INSTANCE.convert(Integer.class, value)); - command.setValues(values == null ? null : DefaultTypeConverter.INSTANCE.convert(Integer.class, Arrays.asList(values)).toArray(new Integer[]{})); + if(commandType == DBQueryBuilderPredicatePartCommandType.ORDER) + { + command.setValue(value); + command.setValues(values); + } + else + { + command.setValue(DefaultTypeConverter.INSTANCE.convert(Long.class, value)); + command.setValues(values == null ? null : DefaultTypeConverter.INSTANCE.convert(Integer.class, Arrays.asList(values)).toArray(new Integer[]{})); + } break; default: command.setType(commandType.propertyNotFound()); @@ -332,5 +349,13 @@ public class PropertySupport implements DBQueryBuilderComponent { this.luceneFunction = luceneFunction; } + + /** + * @param leftOuter + */ + public void setLeftOuter(boolean leftOuter) + { + this.leftOuter = leftOuter; + } } \ No newline at end of file diff --git a/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/TypeSupport.java b/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/TypeSupport.java index 54bcbf5557..0454df5c00 100644 --- a/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/TypeSupport.java +++ b/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/TypeSupport.java @@ -37,6 +37,8 @@ public class TypeSupport implements DBQueryBuilderComponent DBQueryBuilderPredicatePartCommandType commandType; + private boolean leftOuter; + /** * @param qnameIds * the qnameIds to set @@ -117,4 +119,12 @@ public class TypeSupport implements DBQueryBuilderComponent } + /** + * @param leftOuter + */ + public void setLeftOuter(boolean leftOuter) + { + this.leftOuter = leftOuter; + } + } \ No newline at end of file diff --git a/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/UUIDSupport.java b/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/UUIDSupport.java index 63d022ed72..0e09a2685b 100644 --- a/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/UUIDSupport.java +++ b/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/UUIDSupport.java @@ -43,6 +43,8 @@ public class UUIDSupport implements DBQueryBuilderComponent DBQueryBuilderPredicatePartCommandType commandType; + private boolean leftOuter; + /** * @param uud the uud to set */ @@ -129,5 +131,13 @@ public class UUIDSupport implements DBQueryBuilderComponent command.setValues(uuids); predicatePartCommands.add(command); } + + /** + * @param leftOuter + */ + public void setLeftOuter(boolean leftOuter) + { + this.leftOuter = leftOuter; + } } diff --git a/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/functions/DBExists.java b/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/functions/DBExists.java index 4c0032e8b4..6a8c4a6da7 100644 --- a/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/functions/DBExists.java +++ b/source/java/org/alfresco/repo/search/impl/querymodel/impl/db/functions/DBExists.java @@ -84,6 +84,7 @@ public class DBExists extends Exists implements DBQueryBuilderComponent if ((not != null) && (not.equals(Boolean.TRUE))) { parentSupport.setCommandType(DBQueryBuilderPredicatePartCommandType.NOTEXISTS); + parentSupport.setLeftOuter(true); } else { @@ -97,6 +98,7 @@ public class DBExists extends Exists implements DBQueryBuilderComponent if ((not != null) && (not.equals(Boolean.TRUE))) { uuidSupport.setCommandType(DBQueryBuilderPredicatePartCommandType.NOTEXISTS); + uuidSupport.setLeftOuter(true); } else { @@ -110,6 +112,7 @@ public class DBExists extends Exists implements DBQueryBuilderComponent if ((not != null) && (not.equals(Boolean.TRUE))) { typeSupport.setCommandType(DBQueryBuilderPredicatePartCommandType.NOTEXISTS); + typeSupport.setLeftOuter(true); } else { @@ -123,6 +126,7 @@ public class DBExists extends Exists implements DBQueryBuilderComponent if ((not != null) && (not.equals(Boolean.TRUE))) { typeSupport.setCommandType(DBQueryBuilderPredicatePartCommandType.NOTEXISTS); + typeSupport.setLeftOuter(true); } else { @@ -143,6 +147,7 @@ public class DBExists extends Exists implements DBQueryBuilderComponent if ((not != null) && (not.equals(Boolean.TRUE))) { propertySupport.setCommandType(DBQueryBuilderPredicatePartCommandType.NOTEXISTS); + propertySupport.setLeftOuter(true); } else { @@ -163,6 +168,7 @@ public class DBExists extends Exists implements DBQueryBuilderComponent if ((not != null) && (not.equals(Boolean.TRUE))) { propertySupport.setCommandType(DBQueryBuilderPredicatePartCommandType.NOTEXISTS); + propertySupport.setLeftOuter(true); } else { @@ -183,6 +189,7 @@ public class DBExists extends Exists implements DBQueryBuilderComponent if ((not != null) && (not.equals(Boolean.TRUE))) { propertySupport.setCommandType(DBQueryBuilderPredicatePartCommandType.NOTEXISTS); + propertySupport.setLeftOuter(true); } else { diff --git a/source/test-java/org/alfresco/repo/search/impl/querymodel/impl/db/DBQueryTest.java b/source/test-java/org/alfresco/repo/search/impl/querymodel/impl/db/DBQueryTest.java index d4caa5817d..7f9c9ad865 100644 --- a/source/test-java/org/alfresco/repo/search/impl/querymodel/impl/db/DBQueryTest.java +++ b/source/test-java/org/alfresco/repo/search/impl/querymodel/impl/db/DBQueryTest.java @@ -51,6 +51,8 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.ContentData; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.MLText; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; @@ -182,6 +184,8 @@ public class DBQueryTest implements DictionaryListener private String midOrderDate; + private ContentService contentService; + protected static void startContext() { ctx = ApplicationContextHelper.getApplicationContext(); @@ -234,6 +238,7 @@ public class DBQueryTest implements DictionaryListener serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); namespaceDao = (NamespaceDAOImpl) ctx.getBean("namespaceDAO"); authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); + contentService = (ContentService) ctx.getBean("contentService"); loadTestModel(); createTestData(); @@ -401,6 +406,9 @@ public class DBQueryTest implements DictionaryListener properties.put(ContentModel.PROP_CREATED, explicitCreatedDate); n14 = nodeService.createNode(n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}fourteen"), ContentModel.TYPE_CONTENT, properties).getChildRef(); nodeService.setProperty(n14, ContentModel.PROP_NAME, "Content 14"); + ContentWriter writer = contentService.getWriter(n14, ContentModel.PROP_CONTENT, true); + writer.setEncoding("UTF-8"); + writer.putContent("12345678"); n15 = nodeService.createNode(n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}fifteen"), ContentModel.TYPE_THUMBNAIL, getOrderProperties()).getChildRef(); nodeService.setProperty(n15, ContentModel.PROP_NAME, "Content 15"); @@ -580,7 +588,7 @@ public class DBQueryTest implements DictionaryListener sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderLong >= "+longValue, 7); sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderLong IN ( "+longValue+")", 1); sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderLong NOT IN ("+longValue+")", 12); - sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderLong is null", 0); + sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderLong is null", 1); sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderLong is not null", 13); long intValue = -45764576 + (8576457 * 6); @@ -594,7 +602,7 @@ public class DBQueryTest implements DictionaryListener sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderInt >= "+intValue, 7); sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderInt IN ( "+intValue+")", 1); sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderInt NOT IN ("+intValue+")", 12); - sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderInt is null", 0); + sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderInt is null", 1); sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderInt is not null", 13); String stringValue = new String(new char[] { (char) ('a' + 6) }) + " cabbage"; @@ -608,7 +616,7 @@ public class DBQueryTest implements DictionaryListener sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderText >= '"+stringValue+"'", 7); sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderText IN ( '"+stringValue+"')", 1); sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderText NOT IN ('"+stringValue+"')", 12); - sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderText is null", 0); + sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderText is null", 1); sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderText is not null", 13); // ML text is essentially multi-valued and gives unuusla results as ther is no locale constraint @@ -624,7 +632,7 @@ public class DBQueryTest implements DictionaryListener // sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText >= '"+stringValue+"'", 7); sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText IN ( '"+stringValue+"')", 1); // sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText NOT IN ('"+stringValue+"')", 12); - sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText is null", 0); + sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText is null", 1); sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText is not null", 13); stringValue = new String(new char[] { (char) ('Z' - 6) }) + " banane"; @@ -638,7 +646,7 @@ public class DBQueryTest implements DictionaryListener // sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText >= '"+stringValue+"'", 7); sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText IN ( '"+stringValue+"')", 1); // sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText NOT IN ('"+stringValue+"')", 12); - sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText is null", 0); + sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText is null", 1); sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText is not null", 13); stringValue = new String(new char[] { (char) ('香' + 6) }) + " 香蕉"; @@ -652,7 +660,7 @@ public class DBQueryTest implements DictionaryListener // sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText >= '"+stringValue+"'", 7); sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText IN ( '"+stringValue+"')", 1); // sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText NOT IN ('"+stringValue+"')", 12); - sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText is null", 0); + sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText is null", 1); sqlQueryWithCount("SELECT * FROM test:testSuperAspect a where a.test:orderMLText is not null", 13); } @@ -685,24 +693,23 @@ public class DBQueryTest implements DictionaryListener sqlQueryWithCount("SELECT * FROM cmis:document order by cmis:lastModifiedBy desc", 8, ContentModel.PROP_MODIFIER, false); sqlQueryWithCount("SELECT * FROM cmis:folder order by cmis:lastModifiedBy desc", 6, ContentModel.PROP_MODIFIER, false); - sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:createdDate asc", 13, CREATED_DATE, true); - sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:createdDate desc", 13, CREATED_DATE, false); + sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:createdDate asc", 14, CREATED_DATE, true); + sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:createdDate desc", 14, CREATED_DATE, false); - sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:orderLong asc", 13, ORDER_LONG, true); - sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:orderLong desc", 13, ORDER_LONG, false); + sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:orderLong asc", 14, ORDER_LONG, true); + sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:orderLong desc", 14, ORDER_LONG, false); - sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:orderInt asc", 13, ORDER_INT, true); - sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:orderInt desc", 13, ORDER_INT, false); + sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:orderInt asc", 14, ORDER_INT, true); + sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:orderInt desc", 14, ORDER_INT, false); - sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:orderText asc", 13, ORDER_TEXT, true); - sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:orderText desc", 13, ORDER_TEXT, false); + sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:orderText asc", 14, ORDER_TEXT, true); + sqlQueryWithCount("SELECT * FROM test:testSuperAspect a order by a.test:orderText desc", 14, ORDER_TEXT, false); - // Note nulls not found as we use inner join - sqlQueryWithCount("SELECT * FROM cmis:document order by cmis:contentStreamMimeType asc", 1); - sqlQueryWithCount("SELECT * FROM cmis:document order by cmis:contentStreamMimeType desc", 1); + sqlQueryWithCount("SELECT * FROM cmis:document order by cmis:contentStreamMimeType asc", 8); + sqlQueryWithCount("SELECT * FROM cmis:document order by cmis:contentStreamMimeType desc", 8); - //sqlQueryWithCount("SELECT * FROM cmis:document order by cmis:contentStreamLength asc", 1); - //sqlQueryWithCount("SELECT * FROM cmis:document order by cmis:contentStreamLength desc", 1); + sqlQueryWithCount("SELECT * FROM cmis:document order by cmis:contentStreamLength asc", 8); + sqlQueryWithCount("SELECT * FROM cmis:document order by cmis:contentStreamLength desc", 8); } @@ -713,10 +720,9 @@ public class DBQueryTest implements DictionaryListener sqlQueryWithCount("SELECT * FROM cmis:folder where cmis:parentId IN ('"+ n2 + "')", 1); sqlQueryWithCount("SELECT * FROM cmis:folder where cmis:parentId <> '"+ n2 + "'", 6); sqlQueryWithCount("SELECT * FROM cmis:folder where cmis:parentId NOT IN ('"+ n2 + "')", 6); - // IS not null is OK but null requires an outer join - //sqlQueryWithCount("SELECT * FROM cmis:folder where cmis:parentId IS NULL", 0); - //sqlQueryWithCount("SELECT * FROM cmis:folder where cmis:parentId IS NOT NULL", 7); - //sqlQueryWithCount("SELECT * FROM cmis:document where cmis:contentStreamLength = 0", 1); + sqlQueryWithCount("SELECT * FROM cmis:folder where cmis:parentId IS NULL", 0); + sqlQueryWithCount("SELECT * FROM cmis:folder where cmis:parentId IS NOT NULL", 6); + sqlQueryWithCount("SELECT * FROM cmis:document where cmis:contentStreamLength = 8", 1); sqlQueryWithCount("SELECT * FROM cmis:document where cmis:contentStreamFileName = 'Content 3'", 1); sqlQueryWithCount("SELECT * FROM cmis:document where cmis:contentStreamFileName < 'Content 3'", 3); sqlQueryWithCount("SELECT * FROM cmis:document where cmis:contentStreamFileName <= 'Content 3'", 4); @@ -735,9 +741,8 @@ public class DBQueryTest implements DictionaryListener sqlQueryWithCount("SELECT * FROM cmis:document where cmis:contentStreamMimeType <> 'text/plain'", 0); sqlQueryWithCount("SELECT * FROM cmis:document where cmis:contentStreamMimeType IN ('text/plain')", 1); sqlQueryWithCount("SELECT * FROM cmis:document where cmis:contentStreamMimeType NOT IN ('text/plain')", 0); - //Would need LOJ for exists - should porbably exclude from DB support for now - //sqlQueryWithCount("SELECT * FROM cmis:document where cmis:contentStreamMimeType IS NULL", 0); - //sqlQueryWithCount("SELECT * FROM cmis:document where cmis:contentStreamMimeType IS NOT NULL", 1); + sqlQueryWithCount("SELECT * FROM cmis:document where cmis:contentStreamMimeType IS NULL", 7); + sqlQueryWithCount("SELECT * FROM cmis:document where cmis:contentStreamMimeType IS NOT NULL", 1); sqlQueryWithCount("SELECT * FROM cmis:document where cmis:contentStreamMimeType like 'text%'", 1); sqlQueryWithCount("SELECT * FROM cmis:folder where cmis:objectId = '"+ n2 + "'", 1); sqlQueryWithCount("SELECT * FROM cmis:folder where cmis:objectId IN ('"+ n2 + "')", 1);