When comparing 2 columns with different types, the type of the first one is generated for both columns as input.
This is common use case when implementing keyset pagination on time, where some tie-breaker is needed.
Relevant log output
type ListAuthorsParams struct {
CreatedAt sql.NullTime
ID sql.NullTime
}
Both columns are generated as sql.NullTime even though ID should be generated as a string.
Database schema
CREATE TABLE authors (
id BIGSERIAL PRIMARY KEY,
name text NOT NULL,
bio text,
created_at timestamp with time zone
);
SQL queries
-- name: ListAuthors :many
SELECT * FROM authors
WHERE (created_at, id) < (@created_at, @id)
ORDER BY created_at DESC, id DESC
LIMIT 500;
Version
Other
What happened?
When comparing 2 columns with different types, the type of the first one is generated for both columns as input. This is common use case when implementing keyset pagination on time, where some tie-breaker is needed.
Relevant log output
Both columns are generated as sql.NullTime even though ID should be generated as a string.
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/35226bc3aac300aebd4eeaa42e2a258b4567e691ab99de4e701d32c37316da83
What operating system are you using?
macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go