mirror of
https://github.com/langchain-ai/langchain-postgres.git
synced 2026-07-16 01:33:18 -04:00
[BUG] Wrong database type checking for embedding_column in PGVectorStore.create
#88
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @NanoClem on GitHub (Aug 6, 2025).
Originally assigned to: @averikitsch on GitHub.
Hello !
I am trying to use the latest features of
langchain-postgresas they perfectly answer my need of reusing a pre-existing table.I think I have stumbled upon a bug during the instanciation of PGVectorStore (AsyncPGVectorStore) through its
createclass method implemented inlangchain_postgres/v2/async_vectorstore.py.Specs
I am running my database with docker using
pgvector/pgvector:pg17image.Python specs :
Issue
If I change "USER-DEFINED" to "vector", it works without any issues.
It looks like a good idea, but as I am not part of the dev team there must be things I am missing.
Thanks for the work put in the library !
@averikitsch commented on GitHub (Aug 8, 2025):
Hi @NanoClem , can you provide the error that you are facing? I am unable to reproduce your issue. When using this container, the underlying code
SELECT column_name, data_type FROM information_schema.columns WHERE table_name = 'my_table';returns "USER_DEFINED" not "vector".@NanoClem commented on GitHub (Aug 10, 2025):
Sorry, I don't have access to my work PC at the moment. I will recreate a local environnement on my personal machine by tomorrow so I can double check this.
For what it is worth, I created my tables using slqalchemy ORM with alembic migrations. My vector's column type is of
Vector(pgvector.sqalchemy), and I saw there was another typeVECTORunder the same package. I will investigate this lead once I get home later in the afternoon.@NanoClem commented on GitHub (Aug 10, 2025):
I cannot reproduce the error on my personal machine with a minimal setup. I also get
USER-DEFINEDwhether I usepgvector.sqlalchemy.Vectororpgvector.sqlalchemy.VECTORclass in my sqlalchemy model.I created a repo when attempting to reproduce the error.
Guess I just have to properly re-create my tables with my alembic revisions in case I did something wrong during my initial setup at work 😓
Anyway, thank you for taking the time to investigate !
@onestardao commented on GitHub (Aug 11, 2025):
this is a classic ProblemMap No.16 — the type check is being done against the information_schema output instead of the driver’s accepted type list.
pgvector stores the column as USER-DEFINED when using certain vector types, so the strict equality check fails even though the column is valid.
you can confirm by running a manual \d+ in psql — if the column shows the correct dimensions, the failure is purely in the validation branch, not the storage.
short-term fix is to patch the check to accept USER-DEFINED alongside vector, or bypass the clause when the target type matches pgvector.
btw we’ve mapped out 16 such recurring issues (including this one) and have helped 70+ devs fix RAG-related problems under MIT-licensed tooling — ping me if you want the full list.