typeorm
typeorm copied to clipboard
feat: Add vector as column type to postgres
Description of change
Added vector as column type to postgres
Fixes #10056
Pull-Request Checklist
- [x] Code is up-to-date with the
master
branch - [x]
npm run format
to apply prettier formatting - [x]
npm run test
passes with this change: N/A - [x] This pull request links relevant issues as
Fixes #10056
- [x] There are new or updated unit tests validating the change: N/A
- [x] Documentation has been updated to reflect this change
- [x] The new commits follow conventions explained in CONTRIBUTING.md
Since vector
seems a special use-case and requires the existence of the according extension in the db. I would recommend adding the vector type in a note below the regular types, stating that this needs pgvector to be present in order to work.
Added a note in the English docs
Hello @hinogi, it would be great to have such a feature in a new release, when can we expect it?
This feature is needed but this PR is incomplete. It doesn't support passing dimensions, using indexes for approximate search, installing the extension automatically or have any tests. Pleases see #2423 as a reference.
Hello @hinogi, it would be great to have such a feature in a new release, when can we expect it?
I am not a maintainer, I just try to help out with additional code reviews and stuff.
please merge this PR, I need the feature and forking isn't working!
@strongpauly please update Postgres column types test with the new type to make sure synchronization works as expected
Would be nice if you also update Postgres driver to install the extention automatically.
any news on this?
Sorry, I can do nothing.
I created this PR because it was a simple change that I was already hacking in in my codebase. However, the requested additions require more time than I can devote at the moment. Apologies. Feel free to take what I've started and expand upon it.
@strongpauly how did you hack it?
I'm getting this error:
"DataTypeNotSupportedError: Data type \\\"vector\\\" in \\\"Entity.embedding\\\" is not supported by \\\"postgres\\\" database.
import { ColumnType, DataSource, DataSourceOptions } from 'typeorm';
export const dataSourceFactory = (options?: DataSourceOptions): DataSource => {
const dataSource = new DataSource(options);
dataSource.driver.supportedDataTypes.push('vector' as ColumnType);
dataSource.driver.withLengthColumnTypes.push('vector' as ColumnType);
return dataSource;
};
Comments in this PR must be addressed before it can be merged.
Created https://github.com/typeorm/typeorm/pull/10789 to address the issues FYI @pleerock - can you please take a look?
what's the status of this one would love to see this in typeorm! ❤️
what's the status of this one would love to see this in typeorm! ❤️
@lukasholzer I have been using a build from my branch via https://github.com/typeorm/typeorm/pull/10789 which works quite well for my usecases.
I won't be able to update my code any more since I have moved on from typeorm to another ORM because of various issues, but anyone's free to spin off from it if they like.
@firtoz thanks so much!
Out of curiosity which ORM did you choose and why? MikroORM?
@lukasholzer trying out drizzle for now, the community and the repo feels active, may consider prisma if it doesn't work out