avoid float in prisma template param

This commit is contained in:
keyan 2024-07-14 16:53:06 -05:00
parent e045c46811
commit dd4806c1a3

View File

@ -200,15 +200,16 @@ export async function onPaid ({ invoice, id }, context) {
// denormalize ncomments, lastCommentAt, and "weightedComments" for ancestors, and insert into reply table // denormalize ncomments, lastCommentAt, and "weightedComments" for ancestors, and insert into reply table
await tx.$executeRaw` await tx.$executeRaw`
WITH comment AS ( WITH comment AS (
SELECT * SELECT "Item".*, users.trust
FROM "Item" FROM "Item"
WHERE id = ${item.id}::INTEGER JOIN users ON "Item"."userId" = users.id
WHERE "Item".id = ${item.id}::INTEGER
), ancestors AS ( ), ancestors AS (
UPDATE "Item" UPDATE "Item"
SET ncomments = "Item".ncomments + 1, SET ncomments = "Item".ncomments + 1,
"lastCommentAt" = now(), "lastCommentAt" = now(),
"weightedComments" = "Item"."weightedComments" + "weightedComments" = "Item"."weightedComments" +
CASE WHEN comment."userId" = "Item"."userId" THEN 0 ELSE ${item.user.trust}::FLOAT END CASE WHEN comment."userId" = "Item"."userId" THEN 0 ELSE comment.trust END
FROM comment FROM comment
WHERE "Item".path @> comment.path AND "Item".id <> comment.id WHERE "Item".path @> comment.path AND "Item".id <> comment.id
RETURNING "Item".* RETURNING "Item".*