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
Support postgres column with varchar datatype and uuid_generate_v4() default #9063
Labels
Comments
The more I look into it, the more it makes sense to pursue the alternative. |
knarfchan
changed the title
New generated option to support postgres column with varchar datatype and uuid_generate_v4() default
Support postgres column with varchar datatype and uuid_generate_v4() default
Jun 2, 2022
7 tasks
knarfchan
added a commit
to knarfchan/typeorm
that referenced
this issue
Jun 2, 2022
…v4() default Closes: typeorm#9063
wirekang
pushed a commit
to wirekang/typeorm
that referenced
this issue
Aug 25, 2022
…efault (typeorm#9065) * fix: support postgres column with varchar datatype and uuid_generate_v4() default Closes: typeorm#9063 * added test Co-authored-by: Dmitry Zotov <dmzt08@gmail.com>
nordinh
pushed a commit
to nordinh/typeorm
that referenced
this issue
Aug 29, 2022
…efault (typeorm#9065) * fix: support postgres column with varchar datatype and uuid_generate_v4() default Closes: typeorm#9063 * added test Co-authored-by: Dmitry Zotov <dmzt08@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature Description
A new column option for
generated
calleddefault
that represents a column generated by whatever default function a column.The Problem
Right now there's no way for an Entity column to represent a column in Postgres that has
varchar
data type anduuid_generate_v4()
default.Typeorm thinks that any column with
uuid_generate_v4()
default should have generationStrategyuuid
, and it thinks that anything with generationStrategyuuid
should be of data typeuuid
. This causes Typeorm to constantly try to drop and re-create any column that tries to define avarchar
column with defaultuuid_generate_v4()
when generating a migration.The Solution
I tried patching the Typeorm library with a new generated type called
default
and mapping nonuuid
columns withuuid_generate_v4()
to this default. Then when defining the column, I can define it like below and this seems to work.Considered Alternatives
Is there anything special about a column marked as
generated
in this case? Might be better just to parse Postgres columns withvarchar
datatype anduuid_generate_v4
to haveisGenerated = false
. Happy to go this route if it makes sense and is simpler.Additional Context
I need to match the database's column definition as is because it's a huge table and there multiple of them, so I need the typeorm column definition to conform to the column instead of vice versa.
Relevant Database Driver(s)
aurora-mysql
aurora-postgres
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
spanner
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
Any guidance would be great! Thanks!
The text was updated successfully, but these errors were encountered: