You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SafeQL 3.6.2 - 3.6.4 infer id as string instead of number - when CTE is used with coalesce() or joins:
// 💥 Query has incorrect type annotation.// Expected: { id: number; slug: string | null }[]// Actual: { id: string; slug: string | null }[]awaitsql<{id: number;slug: string|null;}[]>` WITH x AS (SELECT * FROM curricula_appointments) SELECT x.id, -- Inferred incorrectly as string coalesce(appointments.slug, lectures.slug) AS slug FROM x INNER JOIN appointments ON x.appointment_id = appointments.id LEFT JOIN lectures ON appointments.lecture_id = lectures.id`
Removing coalesce() but keeping the aliased slug field changes id type to string | null:
// 💥 Query has incorrect type annotation.// Expected: { id: number; slug: string | null }[]// Actual: { id: string | null; slug: string | null }[]awaitsql<{id: number;slug: string|null}[]>` WITH x AS ( SELECT * FROM curricula_appointments ) SELECT x.id, lectures.slug AS slug FROM x INNER JOIN appointments ON x.appointment_id = appointments.id LEFT JOIN lectures ON appointments.lecture_id = lectures.id`
Removing the slug field altogether returns id to number:
// ✅awaitsql<{id: number;}[]>` WITH x AS (SELECT * FROM curricula_appointments) SELECT x.id FROM x INNER JOIN appointments ON x.appointment_id = appointments.id LEFT JOIN lectures ON appointments.lecture_id = lectures.id`
To Reproduce
Steps to reproduce the behavior:
See above
Expected behavior
id should be inferred as a number (id integer PRIMARY KEY)
Screenshots
--
Desktop (please complete the following information):
Describe the bug
SafeQL 3.6.2 - 3.6.4 infer
id
asstring
instead ofnumber
- when CTE is used withcoalesce()
or joins:Removing
coalesce()
but keeping the aliasedslug
field changesid
type tostring | null
:Removing the
slug
field altogether returnsid
tonumber
:To Reproduce
Steps to reproduce the behavior:
See above
Expected behavior
id
should be inferred as a number (id integer PRIMARY KEY
)Screenshots
--
Desktop (please complete the following information):
Additional context
Possibly originally introduced in this PR:
The text was updated successfully, but these errors were encountered: