New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify driver.supportedDataTypes
to support installed Postgres extension data type. Bypass validation for a column.
#10056
Comments
driver.supportedDataTypes
to support installed Postgres extension data type. Can I bypass validation for a column?driver.supportedDataTypes
to support installed Postgres extension data type. Bypass validation for a column.
You can use my work from this PR: #8625 I'm too busy to complete it, so feel free to rebase/merge and add some tests. |
How about directly support |
+1 |
ORMs are simply a mapping between tables and classes. As far as typeorm is concerned, the vector datatype is just a string. |
+1 much needed! |
Not when it comes to generating migrations |
Migrations are in fact raw SQL! |
That is a fact, I don't know what else they might be. This ORM happens to generate that SQL based on the column annotation. So no, as far as TypeORM is concerned this is not just a string. |
I happen to write my own migrations (old habits). However, I don't think modifying the generated SQL and replacing |
That being said, I do believe it's a good idea to support pgvector out of the box similar to PostGIS (#2423). |
What's the right workaround type for a vector column:
|
I worked with other ORMs, and all of them that I remember have some form to define custom data types, this happens in a lot of databases, PostgreSQL is one of this cases where can be user defined types, extensions, and so on. Supporting custom column data types allow for all this use cases to fit the common use case for the library, we are exploring this kind of modification. At this time for example we have some tables that have a xid8 data type, that is not supported by typeorm. We workaround by marking the entity as not synced and making all the migration changes by hand, not very fun. |
Feature Description
I'm using the pgvector extension in my database, which allows me to store data in a vector datatype and perform vector operations such as nearest neighbors with
SELECT * FROM items WHERE embedding <-> '[3,1,2]' < 5;
. However, TypeORM seems to have an entity validator method that verifies whether the datatype defined in my entity exists.For instance, the following won't work because the
vector
datatype doesn't natively exist.In raw SQL, this is how I would achieve it:
Is there a way to modify or bypass the validation for a column? I could create this column using raw SQL, but that defeats the purpose of using an ORM. Of course, bypassing seems like a terrible idea. Is there a way to do this?
The Solution
I would like to bypass the entity validation for a specific column, as I'm using a custom extension,
pgvector
, in my database. Defining the type in the TypeORM entity results in a validation error, since thevector
datatype isn't natively supported by PostgreSQL.As a side note, I've installed the extension manually using the command
CREATE EXTENSION vector
.Considered Alternatives
I could create this column using raw SQL, but that defeats the purpose of using an ORM.
Additional Context
You may refer to the
pgvector
documentation https://github.com/pgvector/pgvectorRelevant Database Driver(s)
Are you willing to resolve this issue by submitting a Pull Request?
Yes, I have the time, but I don't know how to start. I would need guidance.
The text was updated successfully, but these errors were encountered: