mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-17 10:13:29 +00:00
fixed Bug in PreFilter of AzureCosmosDBNoSqlVectorSearch (#29613)
Description: Fixes PreFilter value handling in Azure Cosmos DB NoSQL vectorstore. The current implementation fails to handle numeric values in filter conditions, causing an undefined value variable error. This PR adds support for numeric, boolean, and NULL values while maintaining the existing string and list handling. Changes: Added handling for numeric types (int/float) Added boolean value support Added NULL value handling Added type validation for unsupported values Fixed scope of value variable initialization Issue: Fixes #29610 Implementation Notes: No changes to public API Backwards compatible Maintains consistent behavior with existing MongoDB-style filtering Preserves SQL injection prevention through proper value handling --------- Co-authored-by: Chester Curme <chester.curme@gmail.com>
This commit is contained in:
parent
6ff0d5c807
commit
f849305a56
@ -789,6 +789,13 @@ class AzureCosmosDBNoSqlVectorSearch(VectorStore):
|
||||
elif isinstance(condition.value, list):
|
||||
# e.g., for IN clauses
|
||||
value = f"({', '.join(map(str, condition.value))})"
|
||||
elif isinstance(condition.value, (int, float, bool)):
|
||||
value = str(condition.value)
|
||||
elif condition.value is None:
|
||||
value = "NULL"
|
||||
else:
|
||||
raise ValueError(f"Unsupported value type: {type(condition.value)}")
|
||||
|
||||
clauses.append(f"c.{condition.property} {sql_operator} {value}")
|
||||
return f""" WHERE {' {} '.format(sql_logical_operator).join(clauses)}""".strip()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user