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.

uncheckedScalarInputs One relationship unchecked

See original GitHub issue

Bug description

If we have a table which has two or more relationships, we can’t use both the “connect” method and direct id method. Also ‘create’ relationship won’t work on other relationships

How to reproduce

    return this.prisma.zone.create({
      data: {
        facilityId: record.cityId, // direct
        city: {
          connect: {
            id: record.cityId // using connect
          },
        },
      },
    });

Create

    return this.prisma.zone.create({
      data: {
        facilityId: record.cityId, // direct
        city: {
          create: {
            name: record.city.name, //create
          },
        },
      },
    });

Expected behavior

It should allow both ways for different relationships. Right now with the XOR check its deciding either checked or unchecked input type for the object.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pantharshit00commented, Dec 3, 2020

Hey @DregondRahl

This is intentional right now. The problem here is if we allow both cases for each foreign key, there will be too many permutations and input generation will blow exponentially. For example with four foreign keys, we will need to generate 2^4=16 input types.

For now you will need to either choose use one of the syntaxes. My recommendation would be to if you fallback to connect method if you need connect via some other field.

0reactions
matthewmuellercommented, Feb 3, 2021

Thanks @pantharshit00, closing. We can re-open if that doesn’t work for you @DregondRahl.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prisma Client and Prisma schema preview features
When we release a new Prisma Client or Prisma schema feature, it often starts in preview so that you can test it and...
Read more >
Prisma 2.11.0 Release - GitClear
We now support writing foreign keys (also known as relation scalars) directly with the uncheckedScalarInputs preview feature.
Read more >
Create or update one to many relationship in Prisma
I'm providing my solution based on the clarifications you provided in the comments. First I would make the following changes to your Schema....
Read more >
@prisma/cli: Versions | Openbase
Prisma has a set of rules for defining relations between models in the Prisma ... Upsert not creating all entries · uncheckedScalarInputs: XOR...
Read more >
asciant/prisma2-unchecked-relations - Issues Antenna
Unchecked inputs don't have access to connect , or set , etc. with some ... In isolation, it would create the 1-1 relation,...
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