Search in sources :

Example 6 with TupleType

use of com.datastax.driver.core.TupleType in project java-driver by datastax.

the class QueryBuilderTupleExecutionTest method should_handle_collections_of_tuples.

@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);
}
Also used : TupleType(com.datastax.driver.core.TupleType) TupleValue(com.datastax.driver.core.TupleValue) Test(org.testng.annotations.Test)

Example 7 with TupleType

use of com.datastax.driver.core.TupleType in project java-driver by datastax.

the class QueryBuilderTupleExecutionTest method should_handle_tuple.

@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);
}
Also used : TupleType(com.datastax.driver.core.TupleType) Test(org.testng.annotations.Test)

Aggregations

TupleType (com.datastax.driver.core.TupleType)7 TupleValue (com.datastax.driver.core.TupleValue)5 Test (org.junit.Test)3 TreeMap (java.util.TreeMap)2 TreeSet (java.util.TreeSet)2 ProtocolVersion (org.apache.cassandra.transport.ProtocolVersion)2 Test (org.testng.annotations.Test)2 Cluster (com.datastax.driver.core.Cluster)1 DataType (com.datastax.driver.core.DataType)1 LocalDate (com.datastax.driver.core.LocalDate)1 PreparedStatement (com.datastax.driver.core.PreparedStatement)1 QueryTrace (com.datastax.driver.core.QueryTrace)1 Session (com.datastax.driver.core.Session)1 UDTValue (com.datastax.driver.core.UDTValue)1 LoadBalancingPolicy (com.datastax.driver.core.policies.LoadBalancingPolicy)1 ReconnectionPolicy (com.datastax.driver.core.policies.ReconnectionPolicy)1 RetryPolicy (com.datastax.driver.core.policies.RetryPolicy)1 ZonedDateTimeCodec (com.datastax.driver.extras.codecs.jdk8.ZonedDateTimeCodec)1 InetAddress (java.net.InetAddress)1 ByteBuffer (java.nio.ByteBuffer)1