-
-
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
UUID PrimaryGeneratedColumn is not marked as PRIMARY KEY in SQL schema #1161
Comments
I'm getting this problem in postgres too with a column using a
... and if I replace
For reference, here's my (extremely simple) entity:
Edit - turns out in our case it was caused by calling createConnection in a process kicked off by node-foreman |
@RLovelett uuid column types are used as real column types when database supports them. Does sqlite support uuid? |
AFAIK no, thats why you don't see uuid column type in sqlite. In postgres for example uuid column type is used because its supported by this database. |
This response appears to be incongruent with the support found in the typeorm library. I do agree, sqlite does not support uuid column natively. Though that seems irrelevant in light of the code inside of the typeorm library. Sqlite does support varchar as a valid primary key column. Typeorm library is exposing uuid as a valid primary key column which it stores as a varchar. What is more, it appears typeorm even explicitly supports and tests uuid as a primary column in sqlite by auto-generating the uuid at insert. Given your response and the existence of the code there is 100% a bug here. It is still however not clear to me what the bug is. It appears to either be:
In its current implementation typeorm is a buggy implementation of 1 and 2. |
Sorry looks like I misunderstood issue you have. Since sqlite does not support database-level uuid orm tries to generate it by its own and uses varchar column to store uuid there. Looks like issue you have is missing primary key on that column. I'll try to reproduce this issue tomorrow |
This issue is fixed and released in |
@pleerock thank you. That worked great. |
If I declare a column as
PrimaryGeneratedColumn('uuid')
the actual column in the schema is not marked asPRIMARY KEY
in the resulting SQL.I would have expected the
CREATE TABLE
statement to look more likeCREATE TABLE "foo" ("id" varchar NOT NULL PRIMARY KEY)
.Source that exemplifies the possible bug mentioned above
example.ts
This in and of itself is a problem because it does not require the column to be unique. Of course, I could work-around this quite simply by applying an
Index
to the column.The real-show stopper occurs if you try to apply a relationship to the
id
column above it fails to create the tables.Source that exemplifies the possible bug mentioned above
Foo.ts
Bar.ts
example.ts
Questions
The text was updated successfully, but these errors were encountered: