Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(mysql): Fix the generation of between keyword in CTE
  • Loading branch information
eyasy1217 committed Jan 28, 2024
commit 5c8869c975f49cb624f1a0ab8e7c748470a25dc4
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;