cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r903174 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/jdbc/EJBQLAggregateColumnTranslator.java test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java
Date Tue, 26 Jan 2010 11:21:59 GMT
Author: aadamchik
Date: Tue Jan 26 11:21:59 2010
New Revision: 903174

URL: http://svn.apache.org/viewvc?rev=903174&view=rev
Log:
CAY-1367 EJBQL: Implement support for relationship-ending paths in GROUP BY clause

combined patch by Ksenia Khailenko - fixing COUNT(..) syntax for Derby, et. al.

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAggregateColumnTranslator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAggregateColumnTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAggregateColumnTranslator.java?rev=903174&r1=903173&r2=903174&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAggregateColumnTranslator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAggregateColumnTranslator.java
Tue Jan 26 11:21:59 2010
@@ -131,37 +131,16 @@
                     table.getFullyQualifiedName());
             context.append(alias).append('.').append(attribute.getDbAttributeName());
         }
-        @Override
-        public boolean visitIdentificationVariable(EJBQLExpression expression) {
-
-            String idVariableAbsolutePath = idPath+"."+expression.getText();
-            ClassDescriptor descriptor = context.getEntityDescriptor(idVariableAbsolutePath);
-            if (descriptor != null) {
-                this.lastAlias = context.getTableAlias(idVariableAbsolutePath, descriptor.getEntity().getDbEntityName());
-            }
-
-            this.lastPathComponent = expression.getText();
-            
-            return true;
-        }
         
         @Override
         protected void processTerminatingRelationship(ObjRelationship relationship) {
-
             Collection<DbAttribute> dbAttr = ((ObjEntity) relationship
                     .getTargetEntity()).getDbEntity().getAttributes();
 
-            DbRelationship dbRelationship = relationship.getDbRelationships().get(0);
-            DbEntity table = (DbEntity) dbRelationship.getTargetEntity();
-
             if (dbAttr.size() > 0) {
                 this.resolveJoin(false);
             }
-
-            String alias = this.lastAlias != null ? lastAlias : context
-                    .getTableAlias(idPath, table.getFullyQualifiedName());
-
-            context.append(alias).append(".*");
+            context.append('*');
         }
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java?rev=903174&r1=903173&r2=903174&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextEJBQLGroupByHavingTest.java
Tue Jan 26 11:21:59 2010
@@ -227,12 +227,20 @@
     public void testGroupByJoinedEntityInCount() throws Exception {
         createTestData("testGroupByEntities");
         EJBQLQuery query = new EJBQLQuery(
-                "SELECT COUNT(p.toArtist) FROM Painting p GROUP BY p.toArtist");
-        List<Long> data = createDataContext().performQuery(query);
+                "SELECT COUNT(p.toArtist), p.paintingTitle FROM Painting p " +
+                "GROUP BY p.paintingTitle " +
+                "HAVING p.paintingTitle LIKE 'P1%'");
+        List<Object[]> data = createDataContext().performQuery(query);
         assertNotNull(data);
         assertEquals(3, data.size());
-        for(Long result:data){
-            assertTrue(result==3L||result==2L);
+        
+        HashSet<List> expectedResults=new HashSet<List>();
+        expectedResults.add(Arrays.asList(1L, "P1"));
+        expectedResults.add(Arrays.asList(1L, "P111"));
+        expectedResults.add(Arrays.asList(1L, "P112"));
+        
+        for(Object[] row:data){
+            assertFalse(expectedResults.add(Arrays.asList(row[0], row[1])));
         }
     }
     



Mime
View raw message