@Test(groups = "short") public void should_delete_map_entry() throws Exception { // given session().execute("INSERT INTO test_coll (k, b) VALUES (1, {1:'foo', 2:'bar'})"); // when BuiltStatement statement = delete().mapElt("b", 1).from("test_coll").where(eq("k", 1)); session().execute(statement); // then Map<Integer, String> actual = session() .execute("SELECT b FROM test_coll WHERE k = 1") .one() .getMap("b", Integer.class, String.class); assertThat(actual).containsExactly(entry(2, "bar")); }
@Test(groups = "short") public void should_delete_map_entry_with_bind_marker() throws Exception { // given session().execute("INSERT INTO test_coll (k, a, b) VALUES (1, null, {1:'foo', 2:'bar'})"); // when BuiltStatement statement = delete().mapElt("b", bindMarker()).from("test_coll").where(eq("k", 1)); PreparedStatement ps = session().prepare(statement); session().execute(ps.bind().setInt(0, 1)); // then Map<Integer, String> actual = session() .execute("SELECT b FROM test_coll WHERE k = 1") .one() .getMap("b", Integer.class, String.class); assertThat(actual).containsExactly(entry(2, "bar")); }
delete() .listElt("a", 3) .mapElt("b", "foo") .column("c") .from("foo")
for(Entry<String, List<Object>> entry : data.getMapValuesToRemove().entrySet()) { for(Object object : entry.getValue()) { deletion.mapElt(entry.getKey(), object);
@Test(groups = "short") public void should_delete_map_entry_with_bind_marker() throws Exception { // given session().execute("INSERT INTO test_coll (k, a, b) VALUES (1, null, {1:'foo', 2:'bar'})"); // when BuiltStatement statement = delete().mapElt("b", bindMarker()).from("test_coll").where(eq("k", 1)); PreparedStatement ps = session().prepare(statement); session().execute(ps.bind().setInt(0, 1)); // then Map<Integer, String> actual = session() .execute("SELECT b FROM test_coll WHERE k = 1") .one() .getMap("b", Integer.class, String.class); assertThat(actual).containsExactly(entry(2, "bar")); }
@Test(groups = "short") public void should_delete_map_entry() throws Exception { // given session().execute("INSERT INTO test_coll (k, b) VALUES (1, {1:'foo', 2:'bar'})"); // when BuiltStatement statement = delete().mapElt("b", 1).from("test_coll").where(eq("k", 1)); session().execute(statement); // then Map<Integer, String> actual = session() .execute("SELECT b FROM test_coll WHERE k = 1") .one() .getMap("b", Integer.class, String.class); assertThat(actual).containsExactly(entry(2, "bar")); }
protected Delete.Where delete(Identifier accId, UUID uuid, String column, Object key) { return QueryBuilder.delete().mapElt(column, key).from(TABLE_NAME).where(eq("id", uuid)).and(eq("account_id", accId.toString())); } }
delete() .listElt("a", 3) .mapElt("b", "foo") .column("c") .from("foo")