fix: use column expression in order_by instead of string literal #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
order_by(asc("distance"))bug where SQLAlchemy requires a column expression object, not a string literaldistance_expr) and used it in bothsession.query()andorder_by()ascimporttest_irisvectortest that was using an incorrect assertion patternProblem
When calling
similarity_search_with_score_by_vector(), the query fails with an error because SQLAlchemy'sorder_by()clause was receiving a string literal"distance"viaasc("distance"), but SQLAlchemy requires an actual column expression object.Solution
Extract the distance expression that is already labeled as
"distance"and reference it directly in theorder_by()clause:Test Plan
test_irisvector_similarity_search_with_score_by_vectorthat directly calls the affected methodtest_irisvectortest to use consistent assertion patternFiles Changed
langchain_iris/vectorstores.py: Fix implementation + removed unusedascimporttests/test_vectorstores.py: Added regression test + fixed pre-existing test