Sample query: ```SELECT SUM(payment.price) AS 'inc...
# prisma-client
p
Sample query:
Copy code
SELECT
SUM(payment.price) AS 'income',
YEAR(payment.createdAt) AS 'year',
MONTH(payment.createdAt) AS 'month'
FROM
(
	SELECT price, createdAt
	FROM pay_pal_payment
	WHERE status = ${PayPalPaymentStatusEnum.COMPLETED}
	UNION ALL SELECT price, createdAt
	FROM paysafecard_payment
	WHERE status = ${PaysafecardPaymentStatusEnum.SUCCESS}
	UNION ALL SELECT price, createdAt
	FROM stripe_payment
	WHERE status = ${StripePaymentStatusEnum.COMPLETED}
	ORDER BY createdAt
) payment
GROUP BY year, month
ORDER BY year ASC, month ASC
Prisma used to return
number
for
income
, instead of
Decimal
. I read the changes in Prisma 4, about
$queryRaw
type mapping, but in this case it seems odd to me, that it returns a
Decimal
, because
price
is of type
Int @db.UnsignedMediumInt
.
1
a
Hey Pascal 👋🏾 Prisma Client now infers types from the values returned by the query. To resolve the types, you’ll have to cast the values. You can refer to the upgrade guide: Raw query mapping: PostgreSQL type-casts to learn how you can smoothly upgrade your raw queries. 🙂