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

fix(mysql): Fix the generation of between keyword in CTE #3164

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions internal/compiler/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ func (comp *Compiler) resolveCatalogRefs(qc *QueryCatalog, rvs []*ast.RangeVar,
IsSqlcSlice: p.IsSqlcSlice(),
},
})

break
}
}

Expand Down
47 changes: 47 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.

6 changes: 6 additions & 0 deletions internal/endtoend/testdata/between_args/mysql/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ WHERE p.price BETWEEN ? AND ?;
SELECT *
FROM products
WHERE price BETWEEN sqlc.arg(min_price) AND sqlc.arg(max_price);

-- name: GetBetweenPricesTableWithCTE :many
WITH cte AS (SELECT id FROM products WHERE products.price BETWEEN ? AND ?)
SELECT * FROM products
INNER JOIN cte ON products.id = cte.id
ORDER BY name;
Loading