/** * Tests that a value that was previously set on a bound statement can be unset by name. This only * works from protocol V4 onwards. * * @test_category prepared_statements:binding * @jira_ticket JAVA-930 * @since 2.2.0 */ @Test(groups = "short") @CassandraVersion("2.2.0") public void should_unset_value_by_name() { PreparedStatement prepared = session().prepare("INSERT INTO " + SIMPLE_TABLE + " (k, i) VALUES (:k, :i)"); BoundStatement bound = prepared.bind(); bound.setString("k", "foo"); bound.setInt("i", 1234); bound.unset("i"); assertThat(bound.isSet("i")).isFalse(); session().execute(bound); ResultSet rows = session() .execute( new SimpleStatement("SELECT i from " + SIMPLE_TABLE + " where k = 'foo'") .enableTracing()); assertThat(rows.one().isNull("i")); // sleep 10 seconds to make sure the trace will be complete Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); QueryTrace queryTrace = rows.getExecutionInfo().getQueryTrace(); assertEventsContain(queryTrace, "0 tombstone"); }
/** * Tests that a value that was previously set on a bound statement can be unset by index. This * only works from protocol V4 onwards. * * @test_category prepared_statements:binding * @jira_ticket JAVA-930 * @since 2.2.0 */ @Test(groups = "short") @CassandraVersion("2.2.0") public void should_unset_value_by_index() { PreparedStatement prepared = session().prepare("INSERT INTO " + SIMPLE_TABLE + " (k, i) VALUES (?, ?)"); BoundStatement bound = prepared.bind(); bound.setString(0, "foo"); bound.setInt(1, 1234); bound.unset(1); assertThat(bound.isSet(1)).isFalse(); session().execute(bound); ResultSet rows = session() .execute( new SimpleStatement("SELECT i from " + SIMPLE_TABLE + " where k = 'foo'") .enableTracing()); assertThat(rows.one().isNull("i")); // sleep 10 seconds to make sure the trace will be complete Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); QueryTrace queryTrace = rows.getExecutionInfo().getQueryTrace(); assertEventsContain(queryTrace, "0 tombstone"); }
/** * Tests that a value that was previously set on a bound statement can be unset by name. This only * works from protocol V4 onwards. * * @test_category prepared_statements:binding * @jira_ticket JAVA-930 * @since 2.2.0 */ @Test(groups = "short") @CassandraVersion("2.2.0") public void should_unset_value_by_name() { PreparedStatement prepared = session().prepare("INSERT INTO " + SIMPLE_TABLE + " (k, i) VALUES (:k, :i)"); BoundStatement bound = prepared.bind(); bound.setString("k", "foo"); bound.setInt("i", 1234); bound.unset("i"); assertThat(bound.isSet("i")).isFalse(); session().execute(bound); ResultSet rows = session() .execute( new SimpleStatement("SELECT i from " + SIMPLE_TABLE + " where k = 'foo'") .enableTracing()); assertThat(rows.one().isNull("i")); // sleep 10 seconds to make sure the trace will be complete Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); QueryTrace queryTrace = rows.getExecutionInfo().getQueryTrace(); assertEventsContain(queryTrace, "0 tombstone"); }
/** * Tests that a value that was previously set on a bound statement can be unset by index. This * only works from protocol V4 onwards. * * @test_category prepared_statements:binding * @jira_ticket JAVA-930 * @since 2.2.0 */ @Test(groups = "short") @CassandraVersion("2.2.0") public void should_unset_value_by_index() { PreparedStatement prepared = session().prepare("INSERT INTO " + SIMPLE_TABLE + " (k, i) VALUES (?, ?)"); BoundStatement bound = prepared.bind(); bound.setString(0, "foo"); bound.setInt(1, 1234); bound.unset(1); assertThat(bound.isSet(1)).isFalse(); session().execute(bound); ResultSet rows = session() .execute( new SimpleStatement("SELECT i from " + SIMPLE_TABLE + " where k = 'foo'") .enableTracing()); assertThat(rows.one().isNull("i")); // sleep 10 seconds to make sure the trace will be complete Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); QueryTrace queryTrace = rows.getExecutionInfo().getQueryTrace(); assertEventsContain(queryTrace, "0 tombstone"); }