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
I have a query using a CTE with a WHERE clause filtering a date range using BETWEEN, and sqlc generated the params struct with duplicate fields for the from and to dates.
constlistAuthorsWithCTE=`-- name: ListAuthorsWithCTE :manyWITH page AS (SELECT id FROM authors WHERE authors.created_at BETWEEN ? AND ?)SELECT authors.id, name, bio, created_at, page.id FROM authorsINNER JOIN page ON page.id = authors.idORDER BY name`typeListAuthorsWithCTEParamsstruct {
FromCreatedAt time.TimeFromCreatedAt_2 time.TimeToCreatedAt time.TimeToCreatedAt_2 time.Time
}
Note that changing the WHERE clause to use >= and < outputs the correct number of parameters.
Relevant log output
No response
Database schema
CREATETABLEauthors (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
bio VARCHAR(255),
created_at DATETIME NOT NULL
);
SQL queries
-- name: ListAuthorsWithCTE :many
WITH page AS (SELECT id FROM authors WHEREauthors.created_at BETWEEN ? AND ?)
SELECT*FROM authors
INNER JOIN page ONpage.id=authors.idORDER BY name;
Version
1.23.0
What happened?
I have a query using a CTE with a WHERE clause filtering a date range using BETWEEN, and sqlc generated the params struct with duplicate fields for the from and to dates.
And the database is queried with all of them.
Note that changing the WHERE clause to use >= and < outputs the correct number of parameters.
Relevant log output
No response
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/f475a847db9fef33de461eadc8638ca289c85e2cd7ab40df344454ccb721c836
What operating system are you using?
macOS
What database engines are you using?
MySQL
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: