From a4c220c700f7b8dfdbfe45273c7adb1bd8836567 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Fri, 5 Jul 2024 11:02:18 +0700 Subject: [PATCH] fix: sql query --- src/controllers/product-service-controller.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/controllers/product-service-controller.ts b/src/controllers/product-service-controller.ts index 0e278e0..c60ccba 100644 --- a/src/controllers/product-service-controller.ts +++ b/src/controllers/product-service-controller.ts @@ -64,11 +64,11 @@ export class ProductServiceController extends Controller { if (query) or.push(Prisma.sql`"name" LIKE ${`%${query}%`}`); if (status) and.push(Prisma.sql`"status" = ${status}::"Status"`); if (productTypeId) { - and.push(Prisma.sql`("productTypeId" = ${productTypeId})`); + and.push(Prisma.sql`"productTypeId" = ${productTypeId}`); } if (registeredBranchId) { and.push( - Prisma.sql`("registeredBranchId" = ${registeredBranchId} OR "registeredBranchId" = null)`, + Prisma.sql`("registeredBranchId" = ${registeredBranchId} OR "registeredBranchId" IS NULL)`, ); } @@ -78,6 +78,7 @@ export class ProductServiceController extends Controller { ${or.length > 0 && and.length > 0 ? Prisma.sql` AND ` : Prisma.empty} ${and.length > 0 ? Prisma.join(and, " AND ", "(", ")") : Prisma.empty} `; + console.log(where.sql); const [result, [{ total }]] = await prisma.$transaction([ prisma.$queryRaw<((Product & { type: "product" }) | (Service & { type: "service" }))[]>`