return QueryBuilder.contains(key, value); case CONTAINS_KEY: return QueryBuilder.containsKey(key, value);
@Test(groups = "short") public void should_handle_contains_on_set_with_index() { PreparedStatement byCategory = session() .prepare( select("id", "description", "categories") .from("products") .where(contains("categories", bindMarker("category")))); ResultSet results = session().execute(byCategory.bind().setString("category", "hdtv")); assertThat(results.getAvailableWithoutFetching()).isEqualTo(2); for (Row row : results) { assertThat(row.getSet("categories", String.class)).contains("hdtv"); } }
select = select().from("foo").where(contains("e", "text")); assertEquals(select.toString(), query);
@Test(groups = "short") public void should_handle_contains_on_list_with_index() { PreparedStatement byBuyer = session() .prepare( select("id", "description", "buyers") .from("products") .where(contains("buyers", bindMarker("buyer")))); ResultSet results = session().execute(byBuyer.bind().setInt("buyer", 4)); Row row = results.one(); assertThat(row).isNotNull(); assertThat(row.getInt("id")).isEqualTo(38471); assertThat(row.getList("buyers", Integer.class)).contains(4); }
return QueryBuilder.contains(key, value); case CONTAINS_KEY: return QueryBuilder.containsKey(key, value);
@Test(groups = "short") public void should_handle_contains_on_map_with_index() { PreparedStatement byFeatures = session() .prepare( select("id", "description", "features_values") .from("products") .where(contains("features_values", bindMarker("feature")))); ResultSet results = session().execute(byFeatures.bind().setString("feature", "LED")); Row row = results.one(); assertThat(row).isNotNull(); assertThat(row.getInt("id")).isEqualTo(29412); assertThat(row.getMap("features_values", String.class, String.class)) .containsEntry("techno", "LED"); }
Assert.state(predicate.getValue() != null, () -> String.format("CONTAINS value for column %s is null", columnName)); return QueryBuilder.contains(columnName, predicate.getValue());
private Statement createQueryForAppsOwnedBy(String userId) { UUID ownerId = UUID.fromString(userId); return queryBuilder .select() .all() .from(TABLE_NAME) .where(contains(OWNERS, ownerId)); }
select = select().from("foo").where(contains("e", "text")); assertEquals(select.toString(), query);
private Statement createQueryForAppsOwnedBy(String userId) { UUID ownerId = UUID.fromString(userId); return QueryBuilder .select() .all() .from(TABLE_NAME) .where(contains(OWNERS, ownerId)); }
update("foo").where(eq("good", "drivers")).onlyIf(contains("developers", "datastax")), update("foo").onlyIf().and(contains("developers", "datastax")).where(eq("good", "drivers")), update("foo").onlyIf(contains("developers", "datastax")).with(set("v", 0)), update("foo").with(set("v", 0)).onlyIf(contains("hello", "world")), insertInto("foo").value("k", 1).value("v", Sets.newHashSet(now())).ifNotExists(), delete().from("foo").where(eq("k", 2)).ifExists(),
@Test(groups = "short") public void should_handle_contains_on_list_with_index() { PreparedStatement byBuyer = session() .prepare( select("id", "description", "buyers") .from("products") .where(contains("buyers", bindMarker("buyer")))); ResultSet results = session().execute(byBuyer.bind().setInt("buyer", 4)); Row row = results.one(); assertThat(row).isNotNull(); assertThat(row.getInt("id")).isEqualTo(38471); assertThat(row.getList("buyers", Integer.class)).contains(4); }
@Test(groups = "short") public void should_handle_contains_on_set_with_index() { PreparedStatement byCategory = session() .prepare( select("id", "description", "categories") .from("products") .where(contains("categories", bindMarker("category")))); ResultSet results = session().execute(byCategory.bind().setString("category", "hdtv")); assertThat(results.getAvailableWithoutFetching()).isEqualTo(2); for (Row row : results) { assertThat(row.getSet("categories", String.class)).contains("hdtv"); } }
@Test(groups = "short") public void should_handle_contains_on_map_with_index() { PreparedStatement byFeatures = session() .prepare( select("id", "description", "features_values") .from("products") .where(contains("features_values", bindMarker("feature")))); ResultSet results = session().execute(byFeatures.bind().setString("feature", "LED")); Row row = results.one(); assertThat(row).isNotNull(); assertThat(row.getInt("id")).isEqualTo(29412); assertThat(row.getMap("features_values", String.class, String.class)) .containsEntry("techno", "LED"); }
update("foo").where(eq("good", "drivers")).onlyIf(contains("developers", "datastax")), update("foo").onlyIf().and(contains("developers", "datastax")).where(eq("good", "drivers")), update("foo").onlyIf(contains("developers", "datastax")).with(set("v", 0)), update("foo").with(set("v", 0)).onlyIf(contains("hello", "world")), insertInto("foo").value("k", 1).value("v", Sets.newHashSet(now())).ifNotExists(), delete().from("foo").where(eq("k", 2)).ifExists(),