Repository navigation
Commit 555c46b
authored
Python: Stop doubling apostrophes in Chroma and Weaviate filter values (#14560)
### Motivation and Context
The Chroma and Weaviate `_lambda_parser` implementations double
apostrophes in string constants (`O'Brien` becomes `O''Brien`). That is
SQL-style escaping, but these connectors pass the value as data (a
Chroma `where` dict, a Weaviate `Filter` object), so the doubled value
never equals the stored one. A record with `name="O'Brien"` cannot be
found with `x.name == "O'Brien"`.
I reproduced it against a real in-process Chroma client: the filter
built `{'name': "O''Brien"}` and the search returned no results, while a
filter on `"Smith"` returned the Smith record.
Fixes #14559
### Description
- Return string (and decoded bytes) constants unchanged in
`ChromaCollection._lambda_parser` and
`WeaviateCollection._lambda_parser`, the same way the MongoDB, Pinecone
and Qdrant connectors already do.
- Connectors that build query or SQL strings (Azure AI Search, Postgres,
SQL Server, Oracle) are not touched.
- Add a unit test for each connector. Both fail on `main` and pass with
this change. After the change the same real-Chroma script returns record
`1`.
- Chroma, Weaviate and `tests/unit/data` unit tests pass, and ruff
reports nothing on the changed files.
### Contribution Checklist
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄1 parent f37f308 commit 555c46b
4 files changed
Lines changed: 26 additions & 4 deletions
File tree
- python
- semantic_kernel/connectors
- tests/unit/connectors/memory
- weaviate
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | | - | |
| 427 | + | |
428 | 428 | | |
429 | | - | |
| 429 | + | |
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
| 474 | + | |
475 | 475 | | |
476 | | - | |
| 476 | + | |
477 | 477 | | |
478 | 478 | | |
479 | 479 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
0 commit comments