@Override public String toString() { return statement.toString(); } }
@Override public String toString() { return statement.toString(); } }
@Override public String toString() { return statement.toString(); } }
@Override public String toString() { return statement.toString(); } }
@Override public String toString() { return statement.toString(); } }
@SuppressWarnings("deprecation") @Test(groups = "short") public void should_handle_collections_of_tuples() { String query; BuiltStatement statement; query = "UPDATE foo SET l=[(1,2)] WHERE k=1;"; TupleType tupleType = cluster().getMetadata().newTupleType(cint(), cint()); List<TupleValue> list = ImmutableList.of(tupleType.newValue(1, 2)); statement = update("foo").with(set("l", list)).where(eq("k", 1)); assertThat(statement.toString()).isEqualTo(query); } }
@Test(groups = "short") public void should_handle_tuple() throws Exception { String query = "INSERT INTO foo (k,x) VALUES (0,(1));"; TupleType tupleType = cluster().getMetadata().newTupleType(cint()); BuiltStatement insert = insertInto("foo").value("k", 0).value("x", tupleType.newValue(1)); assertEquals(insert.toString(), query); }
.add(update(table).using(ttl(400))); assertEquals(batch.getRoutingKey(protocolVersion, codecRegistry), bb); assertEquals(batch.toString(), batch_query); batch = batch(query); assertEquals(batch.getRoutingKey(protocolVersion, codecRegistry), bb); assertEquals(batch.toString(), batch_query); batch = batch().add(select().from("foo").where(eq("k", 42))); assertEquals(batch.getRoutingKey(protocolVersion, codecRegistry), null); assertEquals(batch.toString(), batch_query); batch = batch().using(timestamp(42)).add(insertInto("foo", "bar").value("a", 123)); assertEquals(batch.getRoutingKey(protocolVersion, codecRegistry), null); assertEquals(batch.toString(), batch_query);
public List<Row> get() { Select.Where where = QueryBuilder.select().from(parent.getKeyspace(), parent.getTable()).where(); for (Clause clause : clauses) { where.and(clause); } if (searchBuilder != null) { where.and(QueryBuilder.eq(parent.getIndexColumn(), searchBuilder.refresh(refresh).toJson())); } BuiltStatement statement = limit == null ? where : where.limit(limit); String query = statement.toString(); query = query.substring(0, query.length() - 1); StringBuilder sb = new StringBuilder(query); for (String extra : extras) { sb.append(" "); sb.append(extra); sb.append(" "); } return parent.execute(sb, fetchSize); }
@SuppressWarnings("deprecation") @Test(groups = "short") public void should_handle_collections_of_tuples() { String query; BuiltStatement statement; query = "UPDATE foo SET l=[(1,2)] WHERE k=1;"; TupleType tupleType = cluster().getMetadata().newTupleType(cint(), cint()); List<TupleValue> list = ImmutableList.of(tupleType.newValue(1, 2)); statement = update("foo").with(set("l", list)).where(eq("k", 1)); assertThat(statement.toString()).isEqualTo(query); } }
@Test(groups = "short") public void should_handle_tuple() throws Exception { String query = "INSERT INTO foo (k,x) VALUES (0,(1));"; TupleType tupleType = cluster().getMetadata().newTupleType(cint()); BuiltStatement insert = insertInto("foo").value("k", 0).value("x", tupleType.newValue(1)); assertEquals(insert.toString(), query); }
.add(update(table).using(ttl(400))); assertEquals(batch.getRoutingKey(protocolVersion, codecRegistry), bb); assertEquals(batch.toString(), batch_query); batch = batch(query); assertEquals(batch.getRoutingKey(protocolVersion, codecRegistry), bb); assertEquals(batch.toString(), batch_query); batch = batch().add(select().from("foo").where(eq("k", 42))); assertEquals(batch.getRoutingKey(protocolVersion, codecRegistry), null); assertEquals(batch.toString(), batch_query); batch = batch().using(timestamp(42)).add(insertInto("foo", "bar").value("a", 123)); assertEquals(batch.getRoutingKey(protocolVersion, codecRegistry), null); assertEquals(batch.toString(), batch_query);
.where(eq("k", 1))) .using(timestamp(42)); assertEquals(batch.toString(), query); assertThat(batch.getKeyspace()) .isEqualTo("baz"); // batch returns first statements keyspace if present. batch.setKeyspace("bar"); // can still explicitly set keyspace assertThat(batch.getKeyspace()).isEqualTo("bar"); assertThat(batch.toString()).isEqualTo(query); // but does not alter query string. query += "APPLY BATCH;"; batch = batch(delete().listElt("a", 3).from("foo").where(eq("k", 1))); assertEquals(batch.toString(), query);