Skip to content

Commit b396ab7

Browse files
authored
feat: Add support for BETWEEN sqlc.arg(min) AND sqlc.arg(max) (#2373)
issue #2277
1 parent 7098e18 commit b396ab7

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

internal/endtoend/testdata/between_args/mysql/go/query.sql.go

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/between_args/mysql/query.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ WHERE products.price BETWEEN ? AND ?;
1919
SELECT *
2020
FROM products as p
2121
WHERE p.price BETWEEN ? AND ?;
22+
23+
-- name: GetBetweenPricesNamed :many
24+
SELECT *
25+
FROM products
26+
WHERE price BETWEEN sqlc.arg(min_price) AND sqlc.arg(max_price);

internal/sql/astutils/rewrite.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,9 @@ func (a *application) apply(parent ast.Node, name string, iter *iterator, n ast.
400400
a.apply(n, "Refassgnexpr", nil, n.Refassgnexpr)
401401

402402
case *ast.BetweenExpr:
403-
// pass
403+
a.apply(n, "Expr", nil, n.Expr)
404+
a.apply(n, "Left", nil, n.Left)
405+
a.apply(n, "Right", nil, n.Right)
404406

405407
case *ast.BitString:
406408
// pass

0 commit comments

Comments
 (0)