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
Client: using update + connect throws an error on an idempotent operation #14759
Comments
Debug output:
|
Schema SQL: CREATE TABLE "User" (
"id" TEXT NOT NULL,
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);
CREATE TABLE "Profile" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
CONSTRAINT "Profile_pkey" PRIMARY KEY ("id")
);
CREATE UNIQUE INDEX "Profile_userId_key" ON "Profile"("userId");
ALTER TABLE
"Profile"
ADD CONSTRAINT "Profile_userId_fkey"
FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE |
The culprit SQL causing the issue (using foreign keys, but we trigger no updates): SELECT "public"."Profile"."id", "public"."Profile"."userId"
FROM "public"."Profile"
WHERE "public"."Profile"."id" = 1;
SELECT "public"."User"."id"
FROM "public"."User"
WHERE "public"."User"."id" = 1;
SELECT "public"."Profile"."id", "public"."Profile"."userId"
FROM "public"."Profile"
WHERE ("public"."Profile"."userId" IN (1)); This looks like the core is doing something wrong. |
Was there any update on this issue? I think I've just run into this but in a slightly different scenario. When I do an const price = {
...
Transaction: {
connect: {
block_id_transaction_index_transaction_hash: {
block_id: event.blockHeight,
transaction_index: event.transactionIndex,
transaction_hash: event.transactionHash,
},
},
},
};
return ctx.prisma.price.upsert({
where: {
transaction_hash: event.transactionHash,
},
update: price,
create: price,
}); This throws a similar error as described in this issue:
|
It seems there is a common understanding that the following Client query performed on the given schema should be idempotent, given that user and profile are linked via an optional 1-to-1 relation, and a user with id 1 with a profile whose id is 1 already exists. However, the following currently throws an error (
prisma@4.2.0
). This problem isn't related to a specific provider.Schema
Client Code
Error
Also see the internal discussion.
The text was updated successfully, but these errors were encountered: