feat: add create_extension flag to init_vectorstore_table#293
Open
Michele Catalano (ironpinguin) wants to merge 1 commit intolangchain-ai:mainfrom
Open
feat: add create_extension flag to init_vectorstore_table#293Michele Catalano (ironpinguin) wants to merge 1 commit intolangchain-ai:mainfrom
Michele Catalano (ironpinguin) wants to merge 1 commit intolangchain-ai:mainfrom
Conversation
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.
Summary
Add a
create_extensionparameter (defaultTrue) to_ainit_vectorstore_table,ainit_vectorstore_table, andinit_vectorstore_table. When set toFalse, theCREATE EXTENSION IF NOT EXISTS vectorstatement is skipped.Motivation
Some deployments use managed databases (e.g. AlloyDB, Cloud SQL) where the pgvector
extension is pre-installed, or the database user lacks
CREATE EXTENSIONprivileges.Forcing the extension creation on every table init causes unnecessary permission errors.
Changes
langchain_postgres/v2/engine.py: addedcreate_extension: bool = Trueparameterto the three
init_vectorstore_tablevariants; wrapped theCREATE EXTENSIONcallin a conditional block.
tests/unit_tests/v2/test_engine.py: addedtest_init_table_no_create_extensionfor both async and sync paths.
Usage Example
Breaking Changes
None. The new parameter defaults to True, preserving existing behavior.