mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-31 12:06:44 +00:00
Merge "Fix query of collection cell with all items deleted" from Tomek
This commit is contained in:
@@ -596,7 +596,7 @@ static void get_compacted_row_slice(const schema& s,
|
||||
} else {
|
||||
auto&& mut = cell->as_collection_mutation();
|
||||
auto&& ctype = static_pointer_cast<const collection_type_impl>(def.type);
|
||||
if (ctype->is_empty(mut)) {
|
||||
if (!ctype->is_any_live(mut)) {
|
||||
writer.add().skip();
|
||||
} else {
|
||||
write_cell(writer, slice, def.type, mut);
|
||||
|
||||
@@ -2103,6 +2103,24 @@ SEASTAR_TEST_CASE(test_alter_table) {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(test_map_query) {
|
||||
return do_with_cql_env([] (auto& e) {
|
||||
return seastar::async([&e] {
|
||||
e.execute_cql("CREATE TABLE xx (k int PRIMARY KEY, m map<text, int>);").get();
|
||||
e.execute_cql("insert into xx (k, m) values (0, {'v2': 1});").get();
|
||||
auto m_type = map_type_impl::get_instance(utf8_type, int32_type, true);
|
||||
assert_that(e.execute_cql("select m from xx where k = 0;").get0())
|
||||
.is_rows().with_rows({
|
||||
{ make_map_value(m_type, map_type_impl::native_type({{sstring("v2"), 1}})).serialize() }
|
||||
});
|
||||
e.execute_cql("delete m['v2'] from xx where k = 0;").get();
|
||||
assert_that(e.execute_cql("select m from xx where k = 0;").get0())
|
||||
.is_rows().with_rows({{{}}});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(test_drop_table) {
|
||||
return do_with_cql_env([] (auto& e) {
|
||||
return seastar::async([&e] {
|
||||
|
||||
2
types.hh
2
types.hh
@@ -723,7 +723,7 @@ public:
|
||||
static bytes pack(BytesViewIterator start, BytesViewIterator finish, int elements, cql_serialization_format sf);
|
||||
static mutation_view deserialize_mutation_form(collection_mutation_view in);
|
||||
bool is_empty(collection_mutation_view in) const;
|
||||
bool is_any_live(collection_mutation_view in, tombstone tomb, gc_clock::time_point now) const;
|
||||
bool is_any_live(collection_mutation_view in, tombstone tomb = tombstone(), gc_clock::time_point now = gc_clock::time_point::min()) const;
|
||||
virtual bytes to_value(mutation_view mut, cql_serialization_format sf) const = 0;
|
||||
bytes to_value(collection_mutation_view mut, cql_serialization_format sf) const;
|
||||
// FIXME: use iterators?
|
||||
|
||||
Reference in New Issue
Block a user