mirror of
https://github.com/typesense/typesense.git
synced 2025-05-20 13:42:26 +08:00
Fix bug in geopoint array alter drop.
This commit is contained in:
parent
c299172ccc
commit
4c562fa6c8
@ -6137,7 +6137,7 @@ void Index::refresh_schemas(const std::vector<field>& new_fields, const std::vec
|
||||
if(!del_field.is_single_geopoint()) {
|
||||
spp::sparse_hash_map<uint32_t, int64_t*>* geo_array_map = geo_array_index[del_field.name];
|
||||
for(auto& kv: *geo_array_map) {
|
||||
delete kv.second;
|
||||
delete [] kv.second;
|
||||
}
|
||||
delete geo_array_map;
|
||||
geo_array_index.erase(del_field.name);
|
||||
|
@ -1088,6 +1088,37 @@ TEST_F(CollectionSchemaChangeTest, IndexFalseToTrue) {
|
||||
ASSERT_EQ(1, res_op.get()["facet_counts"].size());
|
||||
}
|
||||
|
||||
TEST_F(CollectionSchemaChangeTest, DropGeoPointArrayField) {
|
||||
// when a value is `null` initially, and is altered, subsequent updates should not fail
|
||||
nlohmann::json schema = R"({
|
||||
"name": "coll1",
|
||||
"fields": [
|
||||
{"name": "geoloc", "type": "geopoint[]"}
|
||||
]
|
||||
})"_json;
|
||||
|
||||
auto coll_create_op = collectionManager.create_collection(schema);
|
||||
ASSERT_TRUE(coll_create_op.ok());
|
||||
Collection* coll1 = coll_create_op.get();
|
||||
|
||||
nlohmann::json doc = R"({
|
||||
"geoloc": [[10, 20]]
|
||||
})"_json;
|
||||
|
||||
ASSERT_TRUE(coll1->add(doc.dump()).ok());
|
||||
ASSERT_TRUE(coll1->add(doc.dump()).ok());
|
||||
|
||||
auto schema_changes = R"({
|
||||
"fields": [
|
||||
{"name": "geoloc", "drop": true},
|
||||
{"name": "_geoloc", "type": "geopoint[]", "optional": true}
|
||||
]
|
||||
})"_json;
|
||||
|
||||
auto alter_op = coll1->alter(schema_changes);
|
||||
ASSERT_TRUE(alter_op.ok());
|
||||
}
|
||||
|
||||
TEST_F(CollectionSchemaChangeTest, AddingFieldWithExistingNullValue) {
|
||||
// when a value is `null` initially, and is altered, subsequent updates should not fail
|
||||
nlohmann::json schema = R"({
|
||||
|
Loading…
x
Reference in New Issue
Block a user