-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Not set Name Constraint > Unique #8494
Comments
I also have this issue, only difference is I'm on PostgreSQL 12.4, but I imagine this is an issue in the library code and not the database side anyway. Another note is, for me at least, this only happens if you're targeting one property, like in the example above, if you target multiple properties, it works fine. There were older issues for this that were closed because it was assumed to be fixed by PR #7561, but that OP says...
...although 2/3 of the issues they linked were PostgreSQL, so I guess there were either issues with the tests, or something changed between then and current version (should try the older version myself and see). One of the issues mentions that dropping the table fully would fix it, but didn't test, and obviously a bit destructive. There's also a "workaround" posted here which can be used to find the constraint name so you can at least use it programatically. |
@zoton2 This issue still exist for PostgreSQL 14.4 |
@Index doesn't work for me. I need a constraint, not an index. If you specify only one value in columnNames, typeOrm generates a random name. But you have more one values in columnNames, @unique works correctly For example Case 1: export const UQ_CITY: UniqueOptions = {
name: 'UQ_CITY',
columnNames: ['name'],
}; typeorm generate sql command: ALTER TABLE "cities" ADD CONSTRAINT "UQ_a0ae8d83b7d32359578c486e7f6" UNIQUE ("name"); Case 2: export const UQ_CITY: UniqueOptions = {
name: 'UQ_CITY',
columnNames: ['name', 'countryId'],
}; typeorm generate sql command: ALTER TABLE "cities" ADD CONSTRAINT "UQ_CITY" UNIQUE ("name", "countryId"); |
@zoton2 pg: 8.11.2 |
Same error, PostgreSQL 15.3, typeorm: 0.3.17 |
Issue Description
I have @unique with name but in database name constraint have random value
Database : Postgresql 13
Expected Behavior
New Constraint with properly name from entity
Actual Behavior
Random name contraint
Relevant Database Driver(s)
Postgresql 13
The text was updated successfully, but these errors were encountered: