[langchain-sqlserver] Use binary collation for custom_id column#299
Open
Copilot wants to merge 6 commits into
Open
[langchain-sqlserver] Use binary collation for custom_id column#299Copilot wants to merge 6 commits into
Copilot wants to merge 6 commits into
Conversation
Co-authored-by: santiagxf <32112894+santiagxf@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Use binary collation for custom_id column
[langchain-sqlserver] Use binary collation for custom_id column
Feb 27, 2026
Copilot started reviewing on behalf of
Facundo Santiago (santiagxf)
February 27, 2026 22:50
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a performance improvement request (#74) by applying Latin1_General_100_BIN2_UTF8 binary collation to the custom_id column in EmbeddingStore, with an opt-out flag for users who prefer the database's default collation.
Changes:
- Adds a
BINARY_COLLATIONconstant at module level invectorstores.py - Introduces a new
use_binary_collation_on_custom_id: bool = Trueconstructor parameter that conditionally passes the collation toVARCHAR(1000)when building the ORM model - Adds a new test file
test_binary_collation.pycovering default behavior, explicit opt-in, opt-out, and the constant value
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
libs/sqlserver/langchain_sqlserver/vectorstores.py |
Adds BINARY_COLLATION constant, new __init__ parameter, stores it as _use_binary_collation_on_custom_id, and conditionally applies collation in _get_embedding_store |
libs/sqlserver/tests/unit_tests/test_binary_collation.py |
New unit tests verifying binary collation is applied by default, when explicitly set to True, and not applied when opted out |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…tibility Co-authored-by: santiagxf <32112894+santiagxf@users.noreply.github.com> Agent-Logs-Url: https://github.com/langchain-ai/langchain-azure/sessions/22c20090-35b2-475a-8f70-85e72913b698
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The
custom_idcolumn inEmbeddingStorewas created without a collation. This adds support forLatin1_General_100_BIN2_UTF8binary collation on thecustom_idcolumn as an opt-in flag for best performance, while preserving backward compatibility for existing deployments by defaulting to the database's collation.Changes
BINARY_COLLATIONconstant —"Latin1_General_100_BIN2_UTF8"defined at module level.use_binary_collation_on_custom_id: bool = False— new__init__parameter; set toTrueto apply binary collation for best performance. Defaults toFalseto preserve backward compatibility with existing tables that were created without a forced collation._get_embedding_store()— conditionally passescollation=BINARY_COLLATIONtoVARCHAR(1000)forcustom_idbased on the flag.Usage
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.