question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Relations not being picked up during create statement

See original GitHub issue

Bug description

Our createUser() function has stopped working, erroring that we aren’t providing an institutionUid when we are using the connect func. Prisma reports it is using UserUncheckedCreateInput, which doesn’t have the relations beyond the uid. Not sure why this is now the default.

(I noticed @matthewmueller closed off uncheckedScalarInputs as stable 4 hours ago, not sure if a change has been made during that time or if that’s just a coincidence).

How to reproduce

  1. Run a prisma.[table-goes-here].create({}) query with a connection, such as:
institution: {
  connect: {
    institutionUid: institutionToAdd.institutionUid,
  },
},
  1. Errors

Expected behavior

The query to succeed.

Prisma information

PrismaClientValidationError: 
Invalid `prisma.user.create()` invocation:

{
  include: {
    institution: true,
  },
  data: {
    userUid: '374174ea-2204-4a62-b033-9795a3fc31b3',
    institution: {
    ~~~~~~~~~~~
      connect: {
        institutionUid: 'df25802e-6cf5-4c21-bafc-141e2c296d58'
      }
    },
+   institutionUid: String,
  }
}

Unknown arg `institution` in data.institution for type UserUncheckedCreateInput. Did you mean `institutionUid`?
Argument institutionUid for data.institutionUid is missing.

Environment & setup

  • OS: macOS
  • Database: PostgreSQL
  • Node.js version: v12.18.1 (using ts-node version 8.10.2, typescript version 3.9.7)
  • Prisma version:
prisma               : 2.17.0
@prisma/client       : 2.16.1
Current platform     : darwin
Query Engine         : query-engine 3c463ebd78b1d21d8fdacdd27899e280cf686223 (at ../../../.config/yarn/global/node_mo
dules/@prisma/engines/query-engine-darwin)
Migration Engine     : migration-engine-cli 3c463ebd78b1d21d8fdacdd27899e280cf686223 (at ../../../.config/yarn/global
/node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 3c463ebd78b1d21d8fdacdd27899e280cf686223 (at ../../../.config/yarn/global/n
ode_modules/@prisma/engines/introspection-engine-darwin)
Format Binary        : prisma-fmt 3c463ebd78b1d21d8fdacdd27899e280cf686223 (at ../../../.config/yarn/global/node_modu
les/@prisma/engines/prisma-fmt-darwin)
Studio               : 0.353.0

(edit: realised my prisma versions were out of sync so updated the client to 2.17.0, same issue persists)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:26 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
brantchoatecommented, Mar 2, 2021

@lucasjohnston I’m having the same issue

3reactions
andrew-hwahincommented, Mar 13, 2021

I’ve just verified in my own codebase, if one of the fields is using the format of postId instead of post:{connect:{id}} then it will automatically switch into unchecked mode. Once it switched into unchecked mode, then we’re not able to use the connect checked method anymore. Hence to use the checked mode, we need to switch all to use the checked method.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot table relationships - Microsoft Support
If any of the tables used in the PivotTable contain columns of non-supported data types only, no relationships can be detected. In this...
Read more >
RELATED Function Not Working - Goodly
In this post I'll share with you some of the top reasons why the RELATED function stops working and how to fix it....
Read more >
Cannot simply use PostgreSQL table name ("relation does not ...
From what I've read, this error means that you're not referencing the table name correctly. One common reason is that the table is...
Read more >
Power BI not bringing correct relationships from SQL Server?
I have an empty Fact Table which has many-to-one relationships with many Dimension tables in my SQL Server, however, when bringing these tables...
Read more >
Many-to-many relations - Prisma
How to define and work with many-to-many relations in Prisma. ... If you want a relation table to be picked up by introspection...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found