Skip to content

Commit

Permalink
Add support for BETWEEN sqlc.arg(min) AND sqlc.arg(max)
Browse files Browse the repository at this point in the history
issue #2277
  • Loading branch information
Jille committed Jun 27, 2023
1 parent 7e81fac commit 203d8b5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
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

0 comments on commit 203d8b5

Please sign in to comment.