We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug When comparing two not null timestamps, the result will never be null, but SafeQL interprets it at nullable.
To Reproduce Steps to reproduce the behavior: Create a table with a NOT NULL timestampz column:
NOT NULL
timestampz
CREATE TABLE token ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), expires_at TIMESTAMPZ NOT NULL DEFAULT NOW() );
Query that table, checking if the timestamp is in the past:
const tokenExpired = (await sql<{ expired: boolean; }[]>` SELECT expires_at < NOW() AS expired FROM token WHERE id = ${tokenId} `)[0]?.expired;
SafeQL now reports an error,
Query has incorrect type annotation. Expected: { expired: boolean; } Actual: { expired: boolean | null; }[]
Expected behavior SafeQL doesn't report an error.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered:
I also get this problem with a timestampz that is created as the result of adding an interval to a timestampz.
interval
Sorry, something went wrong.
Good catch. As a workaround for now, you could wrap the condition with coalesce. I will push a new version soon that should fix it.
coalesce
No branches or pull requests
Describe the bug
When comparing two not null timestamps, the result will never be null, but SafeQL interprets it at nullable.
To Reproduce
Steps to reproduce the behavior:
Create a table with a
NOT NULL
timestampz
column:Query that table, checking if the timestamp is in the past:
SafeQL now reports an error,
Expected behavior
SafeQL doesn't report an error.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: