cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkazimirc...@apache.org
Subject svn commit: r1142921 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/ framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/
Date Tue, 05 Jul 2011 08:28:41 GMT
Author: dkazimirchyk
Date: Tue Jul  5 08:28:40 2011
New Revision: 1142921

URL: http://svn.apache.org/viewvc?rev=1142921&view=rev
Log:
CAY-1577 SQL queries for LIKE expressions with escape character generated with syntax errors

patch + unit test

Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QualifierTranslator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpressionFactoryTest.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1142921&r1=1142920&r2=1142921&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Tue Jul  5 08:28:40 2011
@@ -29,6 +29,7 @@ CAY-1526 Preferences: java.lang.IllegalA
 CAY-1546 cayenne-lifecycle: UuidBatchFault concurrency issues
 CAY-1555 Unpublished dependencies of Maven plugins
 CAY-1575 Error generating Embeddable classes in Cayenne Modeler
+CAY-1577 SQL queries for LIKE expressions with escape character generated with syntax errors
 
 ----------------------------------
 Release: 3.1 M2
@@ -114,11 +115,20 @@ CAY-1364 SQL server don't support notati
 CAY-1430 Problems with TINYINT type mapping
 
 ----------------------------------
+Release: 3.0.3
+Date: 
+----------------------------------
+
+Bug Fixes Since 3.0.2
+
+CAY-1577 SQL queries for LIKE expressions with escape character generated with syntax errors
+
+----------------------------------
 Release: 3.0.2
 Date: 
 ----------------------------------
 
-Improvements Sice 3.0.1
+Improvements Since 3.0.1
 
 CAY-1500 MySQL JDBC Batching
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QualifierTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QualifierTranslator.java?rev=1142921&r1=1142920&r2=1142921&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QualifierTranslator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QualifierTranslator.java
Tue Jul  5 08:28:40 2011
@@ -355,17 +355,18 @@ public class QualifierTranslator extends
             boolean isPatternMatchNode = PatternMatchNode.class.isAssignableFrom(node
                     .getClass());
 
+            if (parenthesisNeeded)
+                out.append(')');
+            
             if (isPatternMatchNode && !likeIgnoreCase)
                 appendLikeEscapeCharacter((PatternMatchNode) node);
-
-            if (parenthesisNeeded)
+            
+            if (likeIgnoreCase)
                 out.append(')');
 
             if (isPatternMatchNode && likeIgnoreCase)
                 appendLikeEscapeCharacter((PatternMatchNode) node);
 
-            if (likeIgnoreCase)
-                out.append(')');
         }
         catch (IOException ioex) {
             throw new CayenneRuntimeException("Error appending content", ioex);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpressionFactoryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpressionFactoryTest.java?rev=1142921&r1=1142920&r2=1142921&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpressionFactoryTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpressionFactoryTest.java
Tue Jul  5 08:28:40 2011
@@ -19,6 +19,7 @@
 
 package org.apache.cayenne.exp;
 
+import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -26,6 +27,7 @@ import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.exp.parser.ASTLike;
 import org.apache.cayenne.exp.parser.ASTLikeIgnoreCase;
+import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.testdo.testmap.Artist;
 import org.apache.cayenne.testdo.testmap.Painting;
 import org.apache.cayenne.unit.di.server.ServerCase;
@@ -292,4 +294,22 @@ public class ExpressionFactoryTest exten
         Expression in = ExpressionFactory.inExp("paintingArray", p1);
         assertTrue(in.match(a1));
     }
+    
+    public void testEscapeCharacter() {
+        Artist a1 = context.newObject(Artist.class);
+        a1.setArtistName("A_1");
+        Artist a2 = context.newObject(Artist.class);
+        a2.setArtistName("A_2");
+        context.commitChanges();
+        
+        Expression ex1 = ExpressionFactory.likeIgnoreCaseDbExp("ARTIST_NAME", "A*_1", '*');
+        SelectQuery q1 = new SelectQuery(Artist.class, ex1);
+        List<Artist> artists = context.performQuery(q1);
+        assertEquals(1, artists.size());
+        
+        Expression ex2 = ExpressionFactory.likeExp("artistName", "A*_2", '*');
+        SelectQuery q2 = new SelectQuery(Artist.class, ex2);
+        artists = context.performQuery(q2);
+        assertEquals(1, artists.size());
+    }
 }



Mime
View raw message