mirror of
https://github.com/typesense/typesense.git
synced 2025-05-19 05:08:43 +08:00
Fix id field filter value parsing crash. (#1817)
This commit is contained in:
parent
6cb6a07891
commit
6189fec042
@ -459,6 +459,10 @@ Option<bool> toFilter(const std::string expression,
|
||||
} else {
|
||||
std::vector<std::string> doc_ids;
|
||||
StringUtils::split_to_values(raw_value, doc_ids); // to handle backticks
|
||||
if (doc_ids.empty()) {
|
||||
return Option<bool>(400, empty_filter_err);
|
||||
}
|
||||
|
||||
std::string seq_id_str;
|
||||
StoreStatus seq_id_status = store->get(doc_id_prefix + doc_ids[0], seq_id_str);
|
||||
if (seq_id_status == StoreStatus::FOUND) {
|
||||
|
@ -1399,6 +1399,10 @@ TEST_F(CollectionFilteringTest, FilteringViaDocumentIds) {
|
||||
ASSERT_FALSE(res_op.ok());
|
||||
ASSERT_EQ("Error with filter field `id`: Filter value cannot be empty.", res_op.error());
|
||||
|
||||
res_op = coll1->search("*", {}, "id: ``", {}, sort_fields, {0}, 10, 1, FREQUENCY, {true});
|
||||
ASSERT_FALSE(res_op.ok());
|
||||
ASSERT_EQ("Error with filter field `id`: Filter value cannot be empty.", res_op.error());
|
||||
|
||||
// when no IDs exist
|
||||
results = coll1->search("*",
|
||||
{}, "id: [1000] && num_employees: <300",
|
||||
|
Loading…
x
Reference in New Issue
Block a user