You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When someone first generates the CREATE TABLE statement for a table with a generated UUID column, the PostgresQueryRunner automatically applies the DEFAULT using PostgresDriver#uuidGenerator. See here.
However, after the column has been created, if you then add a @Generated('uuid'), the migration generation will not add the DEFAULT, which is particularly frustrating because nothing in the documentation calls out that if you're using a database engine that supports UUID generation, TypeORM skips the in-app UUID generation as shown here
The Solution
Ideally the InsertQueryBuilder would be smart enough to see that the UUID column has no default, and either fall into that block to generate the UUID, or pass the UUID generator function instead of DEFAULT.
Considered Alternatives
Alternatively, the simplest solution would be to update PostgresQueryRunner#changeColumn here to generate alter column default statements.
Additional Context
Relevant Database Driver(s)
DB Type
Relevant
aurora-data-api
no
aurora-data-api-pg
no
better-sqlite3
no
cockroachdb
no
cordova
no
expo
no
mongodb
no
mysql
no
nativescript
no
oracle
no
postgres
yes
react-native
no
sap
no
sqlite
no
sqlite-abstract
no
sqljs
no
sqlserver
no
Are you willing to resolve this issue by submitting a Pull Request?
✅ Yes, I have the time, and I know how to start.
✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
✖️ No, I don’t have the time, but I can support (using donations) development.
✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
The text was updated successfully, but these errors were encountered:
Feature Description
The Problem
When someone first generates the CREATE TABLE statement for a table with a generated UUID column, the PostgresQueryRunner automatically applies the DEFAULT using PostgresDriver#uuidGenerator. See here.
However, after the column has been created, if you then add a
@Generated('uuid')
, the migration generation will not add the DEFAULT, which is particularly frustrating because nothing in the documentation calls out that if you're using a database engine that supports UUID generation, TypeORM skips the in-app UUID generation as shown hereThe Solution
Ideally the InsertQueryBuilder would be smart enough to see that the UUID column has no default, and either fall into that block to generate the UUID, or pass the UUID generator function instead of DEFAULT.
Considered Alternatives
Alternatively, the simplest solution would be to update PostgresQueryRunner#changeColumn here to generate alter column default statements.
Additional Context
Relevant Database Driver(s)
aurora-data-api
aurora-data-api-pg
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: