Is your feature request related to a problem? Please describe.
It is sometimes hard to understand how to reproduce issues if the reporter doesn't include a code block or their query requires a specific database schema.
Describe the solution you'd like
Issue and PR descriptions could have 2 Before/After (only "Before" for issues) code blocks showing a TS code example, with:
- self-contained query, ideally without schema setup required
- TypeScript type
- SafeQL error message
I've done some in my issues like this before:
Before
// 💥 Query has incorrect type annotation.
// Expected: { latest_is_completed: boolean | null }[]
// Actual: { latest_is_completed: boolean }[]
await sql<{ latest_is_completed: boolean | null }[]>`
WITH
videos (id) AS (
VALUES
(1)
),
video_progress_edits (video_id, new_is_completed) AS (
VALUES
(2, TRUE)
)
SELECT
latest_video_progress_edit.new_is_completed AS latest_is_completed
FROM
videos
LEFT JOIN LATERAL (
SELECT
video_progress_edits.new_is_completed
FROM
video_progress_edits
WHERE
video_progress_edits.video_id = videos.id
) latest_video_progress_edit ON TRUE
`;
After
// ✅
await sql<{ latest_is_completed: boolean | null }[]>`
WITH
videos (id) AS (
VALUES
(1)
),
video_progress_edits (video_id, new_is_completed) AS (
VALUES
(2, TRUE)
)
SELECT
latest_video_progress_edit.new_is_completed AS latest_is_completed
FROM
videos
LEFT JOIN LATERAL (
SELECT
video_progress_edits.new_is_completed
FROM
video_progress_edits
WHERE
video_progress_edits.video_id = videos.id
) latest_video_progress_edit ON TRUE
`;
Describe alternatives you've considered
- Provide an even more robust alternative
- Do nothing
Additional context
I have been asking for this from issue reporters in a few places:
Is your feature request related to a problem? Please describe.
It is sometimes hard to understand how to reproduce issues if the reporter doesn't include a code block or their query requires a specific database schema.
Describe the solution you'd like
Issue and PR descriptions could have 2 Before/After (only "Before" for issues) code blocks showing a TS code example, with:
I've done some in my issues like this before:
LEFT JOIN LATERALnot nullable #418LEFT JOIN LATERALnot nullable #418 (comment)Before
After
Describe alternatives you've considered
Additional context
I have been asking for this from issue reporters in a few places: