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
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) {
192
192
return this ;
193
193
}
194
194
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
+
195
202
public QueryCriteria notContaining (@ Nullable Object o ) {
196
203
value = new QueryCriteria [] { wrap (containing (o )) };
197
204
operator = "NOT" ;
Original file line number Diff line number Diff line change @@ -123,14 +123,11 @@ void testStartingWith() {
123
123
assertEquals ("`name` like (\" Cou\" ||\" %\" )" , c .export ());
124
124
}
125
125
126
- /* cannot do this properly yet because in arg to when() in
127
- * startingWith() cannot be a QueryCriteria
128
126
@ Test
129
127
void testStartingWithExpr () {
130
128
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 ());
132
130
}
133
- */
134
131
135
132
@ Test
136
133
void testEndingWith () {
@@ -162,6 +159,12 @@ void testNotContaining() {
162
159
assertEquals ("not( (contains(`name`, \" Elvis\" )) )" , c .export ());
163
160
}
164
161
162
+ @ Test
163
+ void testArrayContaining () {
164
+ QueryCriteria c = where (i ("name" )).arrayContaining ("Elvis" );
165
+ assertEquals ("array_containing(`name`, \" Elvis\" )" , c .export ());
166
+ }
167
+
165
168
@ Test
166
169
void testLike () {
167
170
QueryCriteria c = where (i ("name" )).like ("%ouch%" );
You can’t perform that action at this time.
0 commit comments