thehornta
thehornta
Explore posts from servers
PPrisma
Created by thehornta on 12/14/2024 in #help-and-questions
ERROR: could not determine data type of parameter $5
Hi, I'm trying out the TypedSQL feature, but I'm receiving an error when trying to generate prisma with --sql. Can anyone spot what I'm doing incorrectly?
-- @param {Int} $1:userId
-- @param {Int} $2:parentEntryId
-- @param {Int} $3:pageSize
-- @param {Int} $4:page
-- @param {String} $5:query
-- @param {String} $6:sort

WITH EntryWithFiles AS (
SELECT
e.id,
e.name,
e.created_at,
e.user_id,
e.parent_entry_id,
CASE
WHEN f.id IS NOT NULL THEN 'folder'
ELSE 'file'
END as "entryType",
COALESCE(files.size, null) as size,
COALESCE(files.status, null) as status,
COALESCE(files.type, null) as file_type,
COUNT(*) OVER() as total_count
FROM entry e
LEFT JOIN folder f ON f.id = e.id AND f.user_id = e.user_id
LEFT JOIN LATERAL (
SELECT f.size, f.status, f.type
FROM file f
WHERE f.id = e.id AND f.user_id = e.user_id
LIMIT 1
) files ON true
WHERE
e.user_id = $1
AND e.parent_entry_id = $2
AND CASE
WHEN $5 IS NOT NULL THEN
e.name ILIKE CONCAT('%',$5,'%')
ELSE true
END
)
SELECT *
FROM EntryWithFiles
ORDER BY
CASE WHEN $6 = 'newest' THEN created_at END DESC,
CASE WHEN $6 = 'oldest' THEN created_at END ASC,
-- For a-z, sort folders first, then by name
CASE WHEN $6 = 'a-z' THEN
CASE "entryType"
WHEN 'folder' THEN 0
ELSE 1
END
END ASC,
CASE WHEN $6 = 'a-z' THEN name END ASC,
-- For z-a, sort folders last, then by name
CASE WHEN $6 = 'z-a' THEN
CASE "entryType"
WHEN 'folder' THEN 1
ELSE 0
END
END ASC,
CASE WHEN $6 = 'z-a' THEN name END DESC,
CASE WHEN $6 = 'smallest' THEN size END ASC,
CASE WHEN $6 = 'largest' THEN size END DESC
LIMIT $3
OFFSET ($4 - 1) * $3;
-- @param {Int} $1:userId
-- @param {Int} $2:parentEntryId
-- @param {Int} $3:pageSize
-- @param {Int} $4:page
-- @param {String} $5:query
-- @param {String} $6:sort

WITH EntryWithFiles AS (
SELECT
e.id,
e.name,
e.created_at,
e.user_id,
e.parent_entry_id,
CASE
WHEN f.id IS NOT NULL THEN 'folder'
ELSE 'file'
END as "entryType",
COALESCE(files.size, null) as size,
COALESCE(files.status, null) as status,
COALESCE(files.type, null) as file_type,
COUNT(*) OVER() as total_count
FROM entry e
LEFT JOIN folder f ON f.id = e.id AND f.user_id = e.user_id
LEFT JOIN LATERAL (
SELECT f.size, f.status, f.type
FROM file f
WHERE f.id = e.id AND f.user_id = e.user_id
LIMIT 1
) files ON true
WHERE
e.user_id = $1
AND e.parent_entry_id = $2
AND CASE
WHEN $5 IS NOT NULL THEN
e.name ILIKE CONCAT('%',$5,'%')
ELSE true
END
)
SELECT *
FROM EntryWithFiles
ORDER BY
CASE WHEN $6 = 'newest' THEN created_at END DESC,
CASE WHEN $6 = 'oldest' THEN created_at END ASC,
-- For a-z, sort folders first, then by name
CASE WHEN $6 = 'a-z' THEN
CASE "entryType"
WHEN 'folder' THEN 0
ELSE 1
END
END ASC,
CASE WHEN $6 = 'a-z' THEN name END ASC,
-- For z-a, sort folders last, then by name
CASE WHEN $6 = 'z-a' THEN
CASE "entryType"
WHEN 'folder' THEN 1
ELSE 0
END
END ASC,
CASE WHEN $6 = 'z-a' THEN name END DESC,
CASE WHEN $6 = 'smallest' THEN size END ASC,
CASE WHEN $6 = 'largest' THEN size END DESC
LIMIT $3
OFFSET ($4 - 1) * $3;
5 replies
TTCTheo's Typesafe Cult
Created by thehornta on 4/7/2024 in #questions
404 Not Found when rendering <UploadButton>
No description
1 replies
TTCTheo's Typesafe Cult
Created by thehornta on 3/9/2024 in #questions
Prisma extension for remapping all fields of certain prisma type
Can I make an extension that remaps all fields of say a String or Number to something else regardless what field or model it's in? I'm using the temporal polyfill and want to remap all my DateTime @db.date to Temporal.PlainDate but I'm stuck. The remapped field names should keep their name. I only want the value to change.
1 replies
CDCloudflare Developers
Created by thehornta on 7/27/2023 in #general-help
Link to Direct Creator Uploads (using tus for resumable, multi-part uploads) is dead
I think the link on this page https://developers.cloudflare.com/stream/uploading-videos/direct-creator-uploads called Direct Creator Uploads (using tus for resumable, multi-part uploads) is dead because it takes me to the overview page in the workers dashboard and I cant find anything related to streams to begin create a worker from.
1 replies
TTCTheo's Typesafe Cult
Created by thehornta on 5/3/2023 in #questions
Generating image background job
I'm making a game where you can create levels in HTML5 Canvas and upload them to the api. I will need to generate an image for the level and I thought about using playwright to take a screenshots of the game via this playwright browser instance. Doing this in a serverless function doesn't really scale because it can take some time to generate it so I thought about having a background job for this. What are some helpful services to aid doing this?
1 replies