Open
Description
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:
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):
- OS: macOS
- PostgreSQL version: 16.1