Prisma1: Postgres Introspection Bugs

Created on 24 May 2018  Â·  9Comments  Â·  Source: prisma/prisma1

Bug Report

Current behavior

Here are some errors I got after introspecting my schema.

  1. Error message: The field `id` is reserved and has to have the format: id: ID! @unique or id: Int! @unique.
  2. It did not add the @unique directive to the id fields
  3. Error message: The relation field `receiver` must specify a `@relation` directive: `@relation(name: "MyRelation")`
  4. It added @pgRelation(column: "receiver_id") instead of @relation
  5. Error message: The type `Users` has a duplicate fieldName.
  6. I had 2 foreign keys to the User table so it created 2 references back to that table with that same name

Those are the errors that occurred when trying to deploy. I fixed most of the errors manually, and then removed the problematic fields. This let me deploy, but when I opened up graphql playground I got the following error from the server: sangria.schema.NonUniqueFieldsError: All fields within 'Query' type should have unique names! Non-unique fields: 'members'.

Reproduction

I can give you guys the database schema if that would be helpful.

Expected behavior?

Everything should just work after introspecting.

bu2-confirmed areconnectopostgres

Most helpful comment

I have version 1.23.1 and it still happens

All 9 comments

Thanks a lot for opening this issue! It would be super helpful if you can additionally your database schema (or a minimal version that exhibits the same bugs).

Here are a few more prisma introspect errors with information about them! Any help in resolution/time frame for fix is appreciated :)

Error seen after prisma deploy

1)

  Pg_stat_statements
    ✖ The field `dbid` has the type `null` but there's no type or enum declaration with that name.
    ✖ The field `userid` has the type `null` but there's no type or enum declaration with that name.
    ✖ The relation field `dbid` must specify a `@relation` directive: `@relation(name: "MyRelation")`
    ✖ The relation field `userid` must specify a `@relation` directive: `@relation(name: "MyRelation")`

Line in schema causing the above errors

enable_extension "pg_stat_statements"

2)

    ✖ The field `xxxxxxxxx` has the type `null` but there's no type or enum declaration with that name.
    ✖ The field `yyyyyyyy` has the type `null` but there's no type or enum declaration with that name.

is being seen for all fields of type:

t.inet     "xxxxxxxxx"
t.date     "yyyyyyyy"

so probably t.inet and t.date needs inclusion/fixing in prisma introspect

3)
The id error as reported previously is all over the place!

    ✖ The field `id` is reserved and has to have the format: id: ID! @unique.

4)
Finally, I am not sure why some fields give the below error about @relation

    ✖ The relation field `xxxxxxxxx` must specify a `@relation` directive: `@relation(name: "MyRelation")`

I am not sure if I can share the schema at this point, would need to get permission from my client.

I deleted the fields with the type null from the SDL and tried a prisma deploy. Prisma successfully detects the delta in the SDL (the changes between the original SDL and the SDL generated through introspect).
It then gets stuck at Applying changes (5/261) ⣯

@Jaikant : Thanks for sharing the details. Can you please also share your schema that exhibits these issues? That would expedite the fixes 🙂

@divyenduz thanks for your reply. I had moved on from here and currently working on something different. When I get back to it, I will create some sample schema to reproduce this issue.

Thanks everyone for your great feedback - we merged a lot of fixes to the introspection feature in 1.14 that should fix the issues you reported here.

I have version 1.23.1 and it still happens

@redbluenat : Thanks, there are a lot of issues mentioned in this thread, can you please create a new issue for which one(s) of them have regressed here: https://github.com/prisma/prisma/issues/new?template=bug_report.md

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nikolasburk picture nikolasburk  Â·  3Comments

tbrannam picture tbrannam  Â·  3Comments

marktani picture marktani  Â·  3Comments

AlessandroAnnini picture AlessandroAnnini  Â·  3Comments

schickling picture schickling  Â·  3Comments