cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [1/2] cayenne git commit: CAY-2193 HAVING clause - extracted abstract class FluentSelect from ObjectSelect - created new class ColumnSelect (extends FluentSelect)
Date Thu, 12 Jan 2017 13:41:54 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master ba64168d3 -> 4f860180d


http://git-wip-us.apache.org/repos/asf/cayenne/blob/4f860180/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelectTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelectTest.java b/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelectTest.java
index 35749c0..94a7292 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelectTest.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelectTest.java
@@ -33,7 +33,6 @@ import java.util.Collections;
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.exp.Property;
 import org.apache.cayenne.testdo.testmap.Artist;
 import org.junit.Test;
 
@@ -430,52 +429,4 @@ public class ObjectSelectTest {
 		assertNull(q.getCacheGroups());
 	}
 
-	@Test
-	public void testColumnsAddByOne() {
-		ObjectSelect<Artist> q = ObjectSelect.query(Artist.class);
-
-		assertEquals(null, q.getColumns());
-
-		q.columns(Artist.ARTIST_NAME);
-		q.columns();
-		q.columns(Artist.DATE_OF_BIRTH);
-		q.columns();
-		q.columns(Artist.PAINTING_ARRAY);
-		q.columns();
-
-		Collection<Property<?>> properties = Arrays.asList(Artist.ARTIST_NAME, Artist.DATE_OF_BIRTH,
Artist.PAINTING_ARRAY);
-		assertEquals(properties, q.getColumns());
-	}
-
-	@Test
-	public void testColumnsAddAll() {
-		ObjectSelect<Artist> q = ObjectSelect.query(Artist.class);
-
-		assertEquals(null, q.getColumns());
-
-		q.columns(Artist.ARTIST_NAME, Artist.DATE_OF_BIRTH, Artist.PAINTING_ARRAY);
-		q.columns(Artist.ARTIST_NAME, Artist.DATE_OF_BIRTH, Artist.PAINTING_ARRAY);
-
-		Collection<Property<?>> properties = Arrays.asList(
-				Artist.ARTIST_NAME, Artist.DATE_OF_BIRTH, Artist.PAINTING_ARRAY,
-				Artist.ARTIST_NAME, Artist.DATE_OF_BIRTH, Artist.PAINTING_ARRAY); // should it be Set
instead of List?
-		assertEquals(properties, q.getColumns());
-	}
-
-	@Test
-	public void testColumnAddByOne() {
-		ObjectSelect<Artist> q = ObjectSelect.query(Artist.class);
-
-		assertEquals(null, q.getColumns());
-
-		q.column(Artist.ARTIST_NAME);
-		q.columns();
-		q.column(Artist.DATE_OF_BIRTH);
-		q.columns();
-		q.column(Artist.PAINTING_ARRAY);
-		q.columns();
-
-		Collection<Property<?>> properties = Collections.<Property<?>>singletonList(Artist.PAINTING_ARRAY);
-		assertEquals(properties, q.getColumns());
-	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4f860180/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_AggregateIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_AggregateIT.java
b/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_AggregateIT.java
index 6034d6b..0152470 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_AggregateIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_AggregateIT.java
@@ -21,6 +21,7 @@ package org.apache.cayenne.query;
 
 import java.sql.Types;
 import java.text.DateFormat;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 import java.util.Locale;
@@ -54,6 +55,8 @@ public class ObjectSelect_AggregateIT extends ServerCase {
     @Inject
     private DBHelper dbHelper;
 
+    // Format: d/m/YY
+    DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
 
     @Before
     public void createArtistsDataSet() throws Exception {
@@ -62,8 +65,6 @@ public class ObjectSelect_AggregateIT extends ServerCase {
         tArtist.setColumnTypes(Types.INTEGER, Types.VARCHAR, Types.DATE);
 
         java.sql.Date[] dates = new java.sql.Date[5];
-        // Format: d/m/YY
-        DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
         for(int i=1; i<=5; i++) {
             dates[i-1] = new java.sql.Date(dateFormat.parse("1/" + i + "/17").getTime());
         }
@@ -80,18 +81,15 @@ public class ObjectSelect_AggregateIT extends ServerCase {
         for (int i = 1; i <= 20; i++) {
             tPaintings.insert(i, "painting" + i, i % 5 + 1, 1);
         }
+        tPaintings.insert(21, "painting21", 2, 1);
     }
 
     @After
     public void clearArtistsDataSet() throws Exception {
-        TableHelper tPaintings = new TableHelper(dbHelper, "PAINTING");
-        tPaintings.deleteAll();
-
-        TableHelper tArtist = new TableHelper(dbHelper, "ARTIST");
-        tArtist.deleteAll();
-
-        TableHelper tGallery = new TableHelper(dbHelper, "GALLERY");
-        tGallery.deleteAll();
+        for(String table : Arrays.asList("PAINTING", "ARTIST", "GALLERY")) {
+            TableHelper tHelper = new TableHelper(dbHelper, table);
+            tHelper.deleteAll();
+        }
     }
 
     @Test
@@ -112,7 +110,6 @@ public class ObjectSelect_AggregateIT extends ServerCase {
         Date avg = ObjectSelect.query(Artist.class)
                 .column(avgProp)
                 .selectOne(context);
-        DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
         Date date = dateFormat.parse("1/3/17");
         assertEquals(date, avg);
     }
@@ -124,7 +121,6 @@ public class ObjectSelect_AggregateIT extends ServerCase {
         Date avg = ObjectSelect.query(Artist.class)
                 .column(minProp)
                 .selectOne(context);
-        DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
         Date date = dateFormat.parse("1/1/17");
         assertEquals(date, avg);
     }
@@ -136,7 +132,6 @@ public class ObjectSelect_AggregateIT extends ServerCase {
         Date avg = ObjectSelect.query(Artist.class)
                 .column(maxProp)
                 .selectOne(context);
-        DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
         Date date = dateFormat.parse("1/5/17");
         assertEquals(date, avg);
     }
@@ -149,7 +144,6 @@ public class ObjectSelect_AggregateIT extends ServerCase {
                 .columns(countProp, Artist.DATE_OF_BIRTH)
                 .orderBy(Artist.DATE_OF_BIRTH.asc())
                 .select(context);
-        DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
         Date date = dateFormat.parse("1/2/17");
         assertEquals(5L, count.size());
         assertEquals(4L, count.get(1)[0]);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4f860180/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_CompileIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_CompileIT.java
b/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_CompileIT.java
index 84a8077..b0aecb0 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_CompileIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_CompileIT.java
@@ -178,9 +178,9 @@ public class ObjectSelect_CompileIT extends ServerCase {
 		SelectQuery selectQuery1 = (SelectQuery) q.createReplacementQuery(resolver);
 		assertNull(selectQuery1.getColumns());
 
-		q.columns(Artist.ARTIST_NAME, Artist.DATE_OF_BIRTH);
+		ColumnSelect<Object[]> newQ = q.columns(Artist.ARTIST_NAME, Artist.DATE_OF_BIRTH);
 
-		SelectQuery selectQuery2 = (SelectQuery) q.createReplacementQuery(resolver);
+		SelectQuery selectQuery2 = (SelectQuery) newQ.createReplacementQuery(resolver);
 		assertNotNull(selectQuery2.getColumns());
 
 		Collection<Property<?>> properties = Arrays.<Property<?>>asList(Artist.ARTIST_NAME,
Artist.DATE_OF_BIRTH);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4f860180/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_RunIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_RunIT.java
b/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_RunIT.java
index 3881135..ca4a7ce 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_RunIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/ObjectSelect_RunIT.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.cayenne.CayenneRuntimeException;
@@ -81,14 +82,10 @@ public class ObjectSelect_RunIT extends ServerCase {
 
 	@After
 	public void clearArtistsDataSet() throws Exception {
-		TableHelper tPaintings = new TableHelper(dbHelper, "PAINTING");
-		tPaintings.deleteAll();
-
-		TableHelper tArtist = new TableHelper(dbHelper, "ARTIST");
-		tArtist.deleteAll();
-
-		TableHelper tGallery = new TableHelper(dbHelper, "GALLERY");
-		tGallery.deleteAll();
+		for(String table : Arrays.asList("PAINTING", "ARTIST", "GALLERY")) {
+			TableHelper tHelper = new TableHelper(dbHelper, table);
+			tHelper.deleteAll();
+		}
 	}
 
 	@Test

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4f860180/cayenne-server/src/test/java/org/apache/cayenne/unit/DB2UnitDbAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/DB2UnitDbAdapter.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/DB2UnitDbAdapter.java
index f4fc4f1..ac46910 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/DB2UnitDbAdapter.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/DB2UnitDbAdapter.java
@@ -63,4 +63,9 @@ public class DB2UnitDbAdapter extends UnitDbAdapter {
     public boolean supportsGeneratedKeysAdd() {
         return true;
     }
+
+    @Override
+    public boolean supportsExpressionInHaving() {
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4f860180/cayenne-server/src/test/java/org/apache/cayenne/unit/DerbyUnitDbAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/DerbyUnitDbAdapter.java
b/cayenne-server/src/test/java/org/apache/cayenne/unit/DerbyUnitDbAdapter.java
index bc3f584..c64f1b2 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/DerbyUnitDbAdapter.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/DerbyUnitDbAdapter.java
@@ -50,4 +50,9 @@ public class DerbyUnitDbAdapter extends UnitDbAdapter {
     public boolean supportsLobs() {
         return true;
     }
+
+    @Override
+    public boolean supportsExpressionInHaving() {
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4f860180/cayenne-server/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java
b/cayenne-server/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java
index 9cb93fb..1d9c99b 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java
@@ -130,4 +130,9 @@ public class OracleUnitDbAdapter extends UnitDbAdapter {
     public boolean onlyGenericNumberType() {
         return true;
     }
+
+    @Override
+    public boolean supportsExpressionInHaving() {
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4f860180/cayenne-server/src/test/java/org/apache/cayenne/unit/SQLServerUnitDbAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/SQLServerUnitDbAdapter.java
b/cayenne-server/src/test/java/org/apache/cayenne/unit/SQLServerUnitDbAdapter.java
index 6c03130..b91f09b 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/SQLServerUnitDbAdapter.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/SQLServerUnitDbAdapter.java
@@ -81,4 +81,9 @@ public class SQLServerUnitDbAdapter extends SybaseUnitDbAdapter {
     // ((JdbcAdapter) getAdapter()).setSupportsGeneratedKeys(false);
     // }
     // }
+
+    @Override
+    public boolean supportsExpressionInHaving() {
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4f860180/cayenne-server/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
index 1297d74..57a2336 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
@@ -382,4 +382,8 @@ public class UnitDbAdapter {
     public boolean supportsEscapeInLike() {
         return true;
     }
+
+    public boolean supportsExpressionInHaving() {
+        return true;
+    }
 }


Mime
View raw message