-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression: inference of subquery aliased field name and type (number
instead of boolean
)
#362
Comments
fixed in 3.6.3 |
Hmm, still seeing this with // 💥 Query has incorrect type annotation.
// Expected: { rsvped: boolean }[]
// Actual: { id: number }[]
await sql<{ rsvped: boolean }[]>`
SELECT
x.*
FROM
(
SELECT
event_rsvps.id IS NOT NULL AS rsvped
FROM
event_rsvps
) x
` Here's the minimal table definition, in case that works for reproducing for you: CREATE TABLE event_rsvps (
id integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY
); |
does it still happening on 3.6.6? for some reason I was unable to reproduce it |
number
instead of boolean
)
I still see it on 3.6.6, yeah. Is Eg:
|
yes |
Can you try @ts-safeql/eslint-plugin@3.6.7? |
Still seeing the failure with Code for copy+paste: await sql`
CREATE TABLE event_rsvps (
id integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
user_id integer NOT NULL REFERENCES users (id) ON DELETE cascade,
event_id integer NOT NULL REFERENCES events (id) ON DELETE cascade,
company_cohort_access_level_paid_id integer REFERENCES company_cohort_access_levels_paid (id),
UNIQUE (user_id, event_id)
)
`;
await sql<{ rsvped: boolean }[]>`
SELECT
x.*
FROM
(
SELECT
event_rsvps.id IS NOT NULL AS rsvped
FROM
event_rsvps
) x
`; |
Interestingly, But the simple query appears to continue to fail. |
Had some time this morning to tackle this issue again. Looking back, implementing nested source resolution was a mistake—it only worked for actual columns, not expressions like |
Describe the bug
SafeQL infers that the field in the subquery is
id
and not the aliased namersvped
:Workaround
x.rsvped
instead ofx.*
)boolean
type toboolean | null
(not accurate, but I think this is a separate SafeQL nullability inference error)To Reproduce
See above
Expected behavior
Inference of the aliased name
rsvped
in the subqueryScreenshots
--
Desktop (please complete the following information):
Additional context
Originally introduced in this PR:
The text was updated successfully, but these errors were encountered: