File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
main/java/org/springframework/data/couchbase/core/query
test/java/org/springframework/data/couchbase/core/query Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,13 @@ public QueryCriteria containing(@Nullable Object o) {
192192 return this ;
193193 }
194194
195+ public QueryCriteria arrayContaining (@ Nullable Object o ) {
196+ operator = "ARRAY_CONTAINING" ;
197+ value = new Object [] { o };
198+ format = "array_containing(%1$s, %3$s)" ;
199+ return this ;
200+ }
201+
195202 public QueryCriteria notContaining (@ Nullable Object o ) {
196203 value = new QueryCriteria [] { wrap (containing (o )) };
197204 operator = "NOT" ;
Original file line number Diff line number Diff line change @@ -123,14 +123,11 @@ void testStartingWith() {
123123 assertEquals ("`name` like (\" Cou\" ||\" %\" )" , c .export ());
124124 }
125125
126- /* cannot do this properly yet because in arg to when() in
127- * startingWith() cannot be a QueryCriteria
128126 @ Test
129127 void testStartingWithExpr () {
130128 QueryCriteria c = where (i ("name" )).startingWith (where (i ("name" )).plus ("xxx" ));
131- assertEquals("`name` like (((`name` || "xxx") || ""%"") )", c.export());
129+ assertEquals ("`name` like (((`name` || \ " xxx\" ))|| \" % \" )" , c .export ());
132130 }
133- */
134131
135132 @ Test
136133 void testEndingWith () {
@@ -162,6 +159,12 @@ void testNotContaining() {
162159 assertEquals ("not( (contains(`name`, \" Elvis\" )) )" , c .export ());
163160 }
164161
162+ @ Test
163+ void testArrayContaining () {
164+ QueryCriteria c = where (i ("name" )).arrayContaining ("Elvis" );
165+ assertEquals ("array_containing(`name`, \" Elvis\" )" , c .export ());
166+ }
167+
165168 @ Test
166169 void testLike () {
167170 QueryCriteria c = where (i ("name" )).like ("%ouch%" );
You can’t perform that action at this time.
0 commit comments