Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ public QueryCriteria containing(@Nullable Object o) {
return this;
}

public QueryCriteria arrayContaining(@Nullable Object o) {
operator = "ARRAY_CONTAINING";
value = new Object[] { o };
format = "array_containing(%1$s, %3$s)";
return this;
}

public QueryCriteria notContaining(@Nullable Object o) {
value = new QueryCriteria[] { wrap(containing(o)) };
operator = "NOT";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,11 @@ void testStartingWith() {
assertEquals("`name` like (\"Cou\"||\"%\")", c.export());
}

/* cannot do this properly yet because in arg to when() in
* startingWith() cannot be a QueryCriteria
@Test
void testStartingWithExpr() {
QueryCriteria c = where(i("name")).startingWith(where(i("name")).plus("xxx"));
assertEquals("`name` like (((`name` || "xxx") || ""%""))", c.export());
assertEquals("`name` like (((`name` || \"xxx\"))||\"%\")", c.export());
}
*/

@Test
void testEndingWith() {
Expand Down Expand Up @@ -162,6 +159,12 @@ void testNotContaining() {
assertEquals("not( (contains(`name`, \"Elvis\")) )", c.export());
}

@Test
void testArrayContaining() {
QueryCriteria c = where(i("name")).arrayContaining("Elvis");
assertEquals("array_containing(`name`, \"Elvis\")", c.export());
}

@Test
void testLike() {
QueryCriteria c = where(i("name")).like("%ouch%");
Expand Down