Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

CAY-1380 Support for Escaped LIKE Clauses in Expressions

* fixing unit test. Not all DB's allow arbitrary escapes

git-svn-id: https://svn.apache.org/repos/asf/cayenne/main/trunk@905112 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit c06bc30e308f2f5f00910f0d61a7c4719d863008 1 parent afda38d
@andrus andrus authored
View
34 ...rk/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SelectQueryTest.java
@@ -37,6 +37,7 @@
import org.apache.cayenne.map.EntityResolver;
import org.apache.cayenne.map.ObjEntity;
import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.test.TableHelper;
public class SelectQueryTest extends SelectQueryBase {
@@ -210,16 +211,19 @@ public void testSelectLikeSingleWildcardMatch() throws Exception {
assertNotNull(objects);
assertEquals(1, objects.size());
}
-
+
public void testSelectLikeSingleWildcardMatchAndEscape() throws Exception {
- query.setRoot(Artist.class);
- Expression qual = ExpressionFactory.likeExp("artistName", "=artist11%", '=');
- query.setQualifier(qual);
- performQuery();
- // check query results
- List objects = opObserver.rowsForQuery(query);
- assertNotNull(objects);
+ TableHelper artistHelper = new TableHelper(getDbHelper(), "ARTIST");
+ artistHelper.deleteAll();
+ artistHelper.setColumns("ARTIST_ID", "ARTIST_NAME");
+ artistHelper.insert(1, "_X");
+ artistHelper.insert(2, "Y_");
+
+ SelectQuery query = new SelectQuery(Artist.class);
+ query.andQualifier(ExpressionFactory.likeExp("artistName", "=_%", '='));
+
+ List objects = createDataContext().performQuery(query);
assertEquals(1, objects.size());
}
@@ -550,17 +554,19 @@ protected void populateTables() throws java.lang.Exception {
}
}
}
-
+
public void testLeftJoinAndPrefetchToMany() {
- SelectQuery query = new SelectQuery(Artist.class,
- ExpressionFactory.matchExp("paintingArray+.toGallery", null));
+ SelectQuery query = new SelectQuery(Artist.class, ExpressionFactory.matchExp(
+ "paintingArray+.toGallery",
+ null));
query.addPrefetch("artistExhibitArray");
createDataContext().performQuery(query);
}
-
+
public void testLeftJoinAndPrefetchToOne() {
- SelectQuery query = new SelectQuery(Painting.class,
- ExpressionFactory.matchExp("toArtist+.artistName", null));
+ SelectQuery query = new SelectQuery(Painting.class, ExpressionFactory.matchExp(
+ "toArtist+.artistName",
+ null));
query.addPrefetch("toGallery");
createDataContext().performQuery(query);
}
Please sign in to comment.
Something went wrong with that request. Please try again.