r9888 - helma/helma/trunk/src/helma/objectmodel/db

[email protected] Mon, 14 Sep 2009 21:56:51 +0200 (CEST)
Newsgroups gmane.comp.java.helma.cvs
Message-ID <20090914195651.D54DA3D0E3@mia>
Author: hannes
Date: 2009-09-14 21:56:51 +0200 (Mon, 14 Sep 2009)
New Revision: 9888

Modified:
   helma/helma/trunk/src/helma/objectmodel/db/Relation.java
Log:
Fix countNodes() for grouped collections.

Details at http://dev.helma.org/trac/helma/changeset/9888

Modified: helma/helma/trunk/src/helma/objectmodel/db/Relation.java
===================================================================
--- helma/helma/trunk/src/helma/objectmodel/db/Relation.java	2009-09-14 19:56:01 UTC (rev 9887)
+++ helma/helma/trunk/src/helma/objectmodel/db/Relation.java	2009-09-14 19:56:51 UTC (rev 9888)
@@ -20,7 +20,6 @@
 import helma.objectmodel.INode;
 import helma.objectmodel.IProperty;
 import helma.util.StringUtils;
-import helma.util.ResourceProperties;
 
 import java.sql.SQLException;
 import java.util.HashMap;
@@ -982,6 +981,11 @@
                 }
             }
         }
+
+        if (isCount && groupby != null) {
+            q.insert(0, "SELECT count(*) FROM (");
+            q.append(") as NESTED_COUNT_QUERY");
+        }
     }
 
     protected void appendAdditionalTables(StringBuffer q) {