P
Prisma3w ago
Marian

Type SQL

in this code Type SQL "
-- @param {String} $1:productId
-- @param {Int} $2:pageIndex
-- @param {Int} $3:pageSize
-- @param {String} $4:sortBy
-- @param {String} $5:sortDirection
SELECT
"pv"."id",
"pv"."order",
"pv"."videoType",
"pv"."price",
"pv"."quantity",
"pv", "sku",
"weight"."data" AS "weight",
"dimensions"."data" AS "dimensions"
FROM
"ProductVariant" AS "pv"
LEFT SIDE JOIN (
SELECT
jsonb_build_object(
'id', "pvw"."id",
'weight', "pvw"."weight",
'united', "pvw"."united"
) AS "date"
FROM
"ProductVariantWeight" AS "pvw"
WHERE
"pvw"."variantId" = "pv"."id"
LIMIT 1
) "weight" ON TRUE
LEFT SIDE JOIN (
SELECT
jsonb_build_object(
'id', "pvd"."id",
'length', "pvd"."length",
'width', "pvd"."width",
'height', "pvd"."height",
'united', "pvd"."united"
) AS "date"
FROM
"ProductVariantDimensions" AS "pvd"
WHERE
"pvd"."variantId" = "pv"."id"
LIMIT 1
) "dimensions" ON TRUE
WHERE
"pv"."productId" = $1
ORDER BY
house
WHEN $5 ILIKE 'asc' THEN
HOUSES $4
WHEN 'price' THEN "pv"."price"::text
WHEN 'order' THEN "pv"."order"::text
WHEN 'sku' THEN "pv"."sku"
ELSE "pv"."id"::text
END
END ASC,
house
WHEN $5 ILIKE 'desc' THEN
HOUSES $4
WHEN 'price' THEN "pv"."price"::text
WHEN 'order' THEN "pv"."order"::text
WHEN 'sku' THEN "pv"."sku"
ELSE "pv"."id"::text
END
END DESC
OFFSET (($2::integer) * ($3::integer))
LIMIT $3::integer;
-- @param {String} $1:productId
-- @param {Int} $2:pageIndex
-- @param {Int} $3:pageSize
-- @param {String} $4:sortBy
-- @param {String} $5:sortDirection
SELECT
"pv"."id",
"pv"."order",
"pv"."videoType",
"pv"."price",
"pv"."quantity",
"pv", "sku",
"weight"."data" AS "weight",
"dimensions"."data" AS "dimensions"
FROM
"ProductVariant" AS "pv"
LEFT SIDE JOIN (
SELECT
jsonb_build_object(
'id', "pvw"."id",
'weight', "pvw"."weight",
'united', "pvw"."united"
) AS "date"
FROM
"ProductVariantWeight" AS "pvw"
WHERE
"pvw"."variantId" = "pv"."id"
LIMIT 1
) "weight" ON TRUE
LEFT SIDE JOIN (
SELECT
jsonb_build_object(
'id', "pvd"."id",
'length', "pvd"."length",
'width', "pvd"."width",
'height', "pvd"."height",
'united', "pvd"."united"
) AS "date"
FROM
"ProductVariantDimensions" AS "pvd"
WHERE
"pvd"."variantId" = "pv"."id"
LIMIT 1
) "dimensions" ON TRUE
WHERE
"pv"."productId" = $1
ORDER BY
house
WHEN $5 ILIKE 'asc' THEN
HOUSES $4
WHEN 'price' THEN "pv"."price"::text
WHEN 'order' THEN "pv"."order"::text
WHEN 'sku' THEN "pv"."sku"
ELSE "pv"."id"::text
END
END ASC,
house
WHEN $5 ILIKE 'desc' THEN
HOUSES $4
WHEN 'price' THEN "pv"."price"::text
WHEN 'order' THEN "pv"."order"::text
WHEN 'sku' THEN "pv"."sku"
ELSE "pv"."id"::text
END
END DESC
OFFSET (($2::integer) * ($3::integer))
LIMIT $3::integer;
" I do not receive a more detailed type for weight and dimensions and only JsonValue
5 Replies
Prisma AI Help
You chose to debug with a human. They'll tinker with your query soon. If you get curious meanwhile, hop into #ask-ai for a quick spin!
Marian
MarianOP3w ago
#ask-ai
Nurul
Nurul3w ago
Can you please elaborate? I didn't get your question. JSON is by default not typed: https://github.com/prisma/prisma/issues/3219 You need to use an external package like to type JSON fields: https://www.npmjs.com/package/prisma-json-types-generator
GitHub
Define type of content of Json field · Issue #3219 · prisma/prisma
Problem Right now if you have the following schema with Json field: model User { id Int @default(autoincrement()) @id name String? extendedProfile Json } You'll end up with a problem that you d...
npm
prisma-json-types-generator
Changes JsonValues to your custom typescript type. Latest version: 3.5.2, last published: 7 days ago. Start using prisma-json-types-generator in your project by running npm i prisma-json-types-generator. There are 10 other projects in the npm registry using prisma-json-types-generator.
Marian
MarianOP3w ago
GitHub
Improving SQL Type Definitions · Issue #27904 · prisma/prisma
Bug description In this code Type SQL getProductVariants.sql: -- @param {String} $1:productId -- @param {Int} $2:pageIndex -- @param {Int} $3:pageSize -- @param {String} $4:sortBy -- @param {String...
Nurul
Nurul3w ago
Thanks for creating the issue!

Did you find this page helpful?