Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
2 changes: 1 addition & 1 deletion 2 internal/compiler/find_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (p paramSearch) Visit(node ast.Node) astutils.Visitor {
if n.Sel == nil {
p.parent = node
} else {
if sel, ok := n.Sel.(*ast.SelectStmt); ok && sel.FromClause != nil {
if sel, ok := n.Sel.(*ast.SelectStmt); ok && sel.FromClause != nil && len(sel.FromClause.Items) > 0 {
from := sel.FromClause
if schema, ok := from.Items[0].(*ast.RangeVar); ok && schema != nil {
p.rangeVar = &ast.RangeVar{
Expand Down
31 changes: 31 additions & 0 deletions 31 internal/endtoend/testdata/in_union/mysql/go/db.go

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

25 changes: 25 additions & 0 deletions 25 internal/endtoend/testdata/in_union/mysql/go/models.go

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

38 changes: 38 additions & 0 deletions 38 internal/endtoend/testdata/in_union/mysql/go/query.sql.go

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

3 changes: 3 additions & 0 deletions 3 internal/endtoend/testdata/in_union/mysql/query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- name: GetAuthors :many
SELECT * FROM authors
WHERE author_id IN (SELECT author_id FROM book1 UNION SELECT author_id FROM book2);
15 changes: 15 additions & 0 deletions 15 internal/endtoend/testdata/in_union/mysql/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CREATE TABLE authors (
id int PRIMARY KEY,
name text NOT NULL,
bio text
);
CREATE TABLE book1 (
author_id int PRIMARY KEY,
name text,
FOREIGN KEY (`author_id`) REFERENCES `authors` (`id`) ON DELETE CASCADE
);
CREATE TABLE book2 (
author_id int PRIMARY KEY,
name text,
FOREIGN KEY (`author_id`) REFERENCES `authors` (`id`) ON DELETE CASCADE
);
12 changes: 12 additions & 0 deletions 12 internal/endtoend/testdata/in_union/mysql/sqlc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "1",
"packages": [
{
"engine": "mysql",
"path": "go",
"name": "querytest",
"schema": "schema.sql",
"queries": "query.sql"
}
]
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.