cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r546919 - /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateTest.java
Date Wed, 13 Jun 2007 15:24:00 GMT
Author: aadamchik
Date: Wed Jun 13 08:23:59 2007
New Revision: 546919

URL: http://svn.apache.org/viewvc?view=rev&rev=546919
Log:
CAY-805: SQLTemplate improvement: new #bindObjectEqual #bindObjectNotEqual directives
null binding test

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateTest.java?view=diff&rev=546919&r1=546918&r2=546919
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateTest.java
Wed Jun 13 08:23:59 2007
@@ -174,6 +174,24 @@
         assertEquals(33002, DataObjectUtils.intPKForObject(p));
     }
 
+    public void testBindObjectEqualNull() throws Exception {
+        createTestData("prepare");
+
+        ObjectContext context = createDataContext();
+
+        String template = "SELECT * FROM PAINTING t0"
+                + " WHERE #bindObjectEqual($a [ 't0.ARTIST_ID' ] [ 'ARTIST_ID' ] ) ORDER
BY PAINTING_ID";
+        SQLTemplate query = new SQLTemplate(Painting.class, template);
+        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setParameters(Collections.singletonMap("a", null));
+
+        List objects = context.performQuery(query);
+        assertEquals(1, objects.size());
+
+        Painting p = (Painting) objects.get(0);
+        assertEquals(33003, DataObjectUtils.intPKForObject(p));
+    }
+
     public void testBindObjectNotEqualFull() throws Exception {
         createTestData("prepare");
 
@@ -193,6 +211,28 @@
         Painting p = (Painting) objects.get(0);
         assertEquals(33001, DataObjectUtils.intPKForObject(p));
     }
+    
+    public void testBindObjectNotEqualNull() throws Exception {
+        createTestData("prepare");
+
+        ObjectContext context = createDataContext();
+
+        String template = "SELECT * FROM PAINTING t0"
+                + " WHERE #bindObjectNotEqual($a [ 't0.ARTIST_ID' ] [ 'ARTIST_ID' ] ) ORDER
BY PAINTING_ID";
+        SQLTemplate query = new SQLTemplate(Painting.class, template);
+        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setParameters(Collections.singletonMap("a", null));
+
+        List objects = context.performQuery(query);
+        assertEquals(2, objects.size());
+
+        Painting p1 = (Painting) objects.get(0);
+        assertEquals(33001, DataObjectUtils.intPKForObject(p1));
+        
+        Painting p2 = (Painting) objects.get(1);
+        assertEquals(33002, DataObjectUtils.intPKForObject(p2));
+    }
+
 
     public void testFetchLimit() throws Exception {
         getAccessStack().createTestData(DataContextCase.class, "testArtists", null);



Mime
View raw message