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
{{ message }}
Repository navigation
[Introspection] @@unique name with spaces are not supported #8645
Using introspection for creating the schema for a ugly database I found that if the index had non suported characters, they were used directly on the name, breaking the client.
The generated code:
@@index([SetType], name: "Master Index 5-2")
The workaround (that I don´t know if it will have any problems)
changed the title [-][Introspection] @@index name with spaces are not supported[/-][+][Introspection] @@unique name with spaces are not supported[/+]on Aug 11, 2021
Hummm I tried, but when I did a db pull it break my schema (but don´t sweat it, the schema is an existant borked one and I myself I´m not a prisma expert)
I guess I´ll use my parsed names. Will that be a problem that the constrains on the schema and the one in db are not aligned? will the introspect work properly? I say it because after the db pull the schema shows again:
@@unique([FeatId, ClassId], name: "my name with spaces")
instead of how I understand you it will work:
@@unique([FeatId, ClassId], name: "my_name_with_spaces", map: "my name with spaces")
Edit: Nevermind, I didnt had the namedConstraints enabled, now it shows properly:
@@unique([RaceId, Category], map: "my name with spaces")
Activity
do4gr commentedon Aug 9, 2021
Hey, names in
@@indexshould not make their way into the client api. Can you share the invalid part in the client types?irbian commentedon Aug 9, 2021
ups, this is only my fault
The one bugged is not @@index, but @@unique
@@unique([Id, SubId], name: "error 1 myuniquekey")Generates inside the index.d.ts:
and another error
do4gr commentedon Aug 11, 2021
Ok, yes that makes sense. Can you try out the just released
namedConstraintspreview feature of https://github.com/prisma/prisma/releases/tag/2.29.0? That should fix this particular issue by splitting the @@unique arguments intonamethat goes into the Client Api andmapwhich contains the database name of the constraint. This way you will be able to create a valid client.[-][Introspection] @@index name with spaces are not supported[/-][+][Introspection] @@unique name with spaces are not supported[/+]irbian commentedon Aug 13, 2021
Hummm I tried, but when I did a db pull it break my schema (but don´t sweat it, the schema is an existant borked one and I myself I´m not a prisma expert)
I guess I´ll use my parsed names. Will that be a problem that the constrains on the schema and the one in db are not aligned? will the introspect work properly? I say it because after the db pull the schema shows again:
@@unique([FeatId, ClassId], name: "my name with spaces")instead of how I understand you it will work:
@@unique([FeatId, ClassId], name: "my_name_with_spaces", map: "my name with spaces")Edit: Nevermind, I didnt had the namedConstraints enabled, now it shows properly:
@@unique([RaceId, Category], map: "my name with spaces")irbian commentedon Aug 13, 2021
Regarding the "breaking", I guess is related to #1368, but I don´t know what options I have
michael-land commentedon Aug 23, 2021
"prisma": "2.29.1",
re-introspect will remove name alias defined on model
@@id(fields: [productId, warehouseId, condition], name: "pk", map: "product_quantity_pk")after introspect, it become
@@id([productId, warehouseId, condition], map: "product_quantity_pk")janpio commentedon Aug 23, 2021
Thanks for the report @xiaoyu-tamu, I split this off into its own issue: #8865
tomhoule commentedon Sep 3, 2021
This should be fixed in
prisma@devand next week's release. Please open a new issue if you see something similar happening in the new version.