From 21f1888f88cdbffac7897e072040b4cbbddf33ab Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Mon, 23 Mar 2015 15:21:39 +0200 Subject: [PATCH] cql: fix lists::setter to use a tombstone Properly squash existing value --- cql3/lists.hh | 14 ++++++-------- tests/urchin/cql_query_test.cc | 3 --- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/cql3/lists.hh b/cql3/lists.hh index fc5f9d8d12..96eb88d82a 100644 --- a/cql3/lists.hh +++ b/cql3/lists.hh @@ -328,16 +328,12 @@ public: } virtual void execute(mutation& m, const exploded_clustering_prefix& prefix, const update_parameters& params) override { + tombstone ts; if (column.type->is_multi_cell()) { // delete + append - // FIXME: - warn(unimplemented::cause::COLLECTIONS); -#if 0 - CellName name = cf.getComparator().create(prefix, column); - cf.addAtom(params.makeTombstoneForOverwrite(name.slice())); -#endif + ts = params.make_tombstone_just_before(); } - do_append(_t, m, prefix, column, params); + do_append(_t, m, prefix, column, params, ts); } }; @@ -418,7 +414,8 @@ public: mutation& m, const exploded_clustering_prefix& prefix, const column_definition& column, - const update_parameters& params) { + const update_parameters& params, + tombstone ts = {}) { auto&& value = t->bind(params._options); auto&& list_value = dynamic_pointer_cast(value); auto&& ltype = dynamic_pointer_cast(column.type); @@ -431,6 +428,7 @@ public: auto&& to_add = list_value->_elements; collection_type_impl::mutation appended; + appended.tomb = ts; appended.cells.reserve(to_add.size()); for (auto&& e : to_add) { auto uuid1 = utils::UUID_gen::get_time_UUID_bytes(); diff --git a/tests/urchin/cql_query_test.cc b/tests/urchin/cql_query_test.cc index 2e2afb72c8..c80c65a044 100644 --- a/tests/urchin/cql_query_test.cc +++ b/tests/urchin/cql_query_test.cc @@ -501,11 +501,8 @@ SEASTAR_TEST_CASE(test_list_insert_update) { }).then([state, db] { return state->execute_cql("update cf set list1 = [ 1002, 1003 ] where p1 = 'key1';").discard_result(); }).then([state, db] { -#if 0 - // test fails due to lack of collection tombstones (append instead of replace) return require_column_has_value(*db, ks_name, table_name, {sstring("key1")}, {}, "list1", list_type_impl::native_type({boost::any(1002), boost::any(1003)})); -#endif }).then([db] { return db->stop(); }).then_wrapped([db] (future<> f) mutable {