Skip to content
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

Add support for BETWEEN sqlc.arg(min) AND sqlc.arg(max) #2373

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions internal/endtoend/testdata/between_args/mysql/go/query.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions internal/endtoend/testdata/between_args/mysql/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ WHERE products.price BETWEEN ? AND ?;
SELECT *
FROM products as p
WHERE p.price BETWEEN ? AND ?;

-- name: GetBetweenPricesNamed :many
SELECT *
FROM products
WHERE price BETWEEN sqlc.arg(min_price) AND sqlc.arg(max_price);
4 changes: 3 additions & 1 deletion internal/sql/astutils/rewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ func (a *application) apply(parent ast.Node, name string, iter *iterator, n ast.
a.apply(n, "Refassgnexpr", nil, n.Refassgnexpr)

case *ast.BetweenExpr:
// pass
a.apply(n, "Expr", nil, n.Expr)
a.apply(n, "Left", nil, n.Left)
a.apply(n, "Right", nil, n.Right)

case *ast.BitString:
// pass
Expand Down