prisma: raw: COALESCE/IFNULL returns `MA==`

Bug description

Prisma2 returns not numeric value for COALESCE/IFNULL

How to reproduce

const result = await prisma.raw(`
SELECT COALESCE(SUM(SaleProduct.qty - SaleProduct.qtyInFulfilments),0) as total
FROM SaleProduct
LEFT JOIN Sale ON SaleProduct.ownerCuid = Sale.cuid
LEFT JOIN Product On SaleProduct.productId = Product.id
LEFT JOIN Organisation ON Organisation.id = Sale.orgId
WHERE Organisation.cuid = 'ck8nyod3s00018ssqre2ked2w' AND Sale.status <> 'DRAFT' AND Product.cuid IN ("ck8o07uxr00002z60c7fbfme8","ck8o07v9000012z60qj2d81a8","ck8o07vhs00022z60of43n2ye")
`);

Expected behavior

Should Return 0 but got total='MA=='

COALESCE image

IFNULL image

Prisma information

prisma-2.0.0.beta.1

Environment & setup

  • OS: Manjaro 19
  • Database: MySQL
  • Prisma version: 2.0.0-beata.1
  • Node.js version: 12.16.1

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 28 (26 by maintainers)

Most upvoted comments

Confirmed. @prisma/cli@alpha fixed the issue. I’ll be closing this issue.