forked from sqlc-dev/sqlc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): Add validation for GROUP BY clause column references (s…
…qlc-dev#1285) * fix(compiler): Add validation for GROUP BY clause column references * Add MySQL test
- Loading branch information
Showing
8 changed files
with
125 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
internal/endtoend/testdata/invalid_group_by_reference/mysql/query.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CREATE TABLE authors ( | ||
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
name text NOT NULL, | ||
bio text, | ||
UNIQUE(name) | ||
); | ||
|
||
-- name: ListAuthors :many | ||
SELECT * | ||
FROM authors | ||
GROUP BY invalid_reference; |
12 changes: 12 additions & 0 deletions
12
internal/endtoend/testdata/invalid_group_by_reference/mysql/sqlc.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": "1", | ||
"packages": [ | ||
{ | ||
"path": "go", | ||
"engine": "mysql", | ||
"name": "querytest", | ||
"schema": "query.sql", | ||
"queries": "query.sql" | ||
} | ||
] | ||
} |
2 changes: 2 additions & 0 deletions
2
internal/endtoend/testdata/invalid_group_by_reference/mysql/stderr.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# package querytest | ||
query.sql:9:1: column reference "invalid_reference" not found |
10 changes: 10 additions & 0 deletions
10
internal/endtoend/testdata/invalid_group_by_reference/postgresql/query.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CREATE TABLE authors ( | ||
id BIGSERIAL PRIMARY KEY, | ||
name text NOT NULL, | ||
bio text | ||
); | ||
|
||
-- name: ListAuthors :many | ||
SELECT * | ||
FROM authors | ||
GROUP BY invalid_reference; |
12 changes: 12 additions & 0 deletions
12
internal/endtoend/testdata/invalid_group_by_reference/postgresql/sqlc.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": "1", | ||
"packages": [ | ||
{ | ||
"path": "go", | ||
"engine": "postgresql", | ||
"name": "querytest", | ||
"schema": "query.sql", | ||
"queries": "query.sql" | ||
} | ||
] | ||
} |
2 changes: 2 additions & 0 deletions
2
internal/endtoend/testdata/invalid_group_by_reference/postgresql/stderr.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# package querytest | ||
query.sql:10:10: column reference "invalid_reference" not found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters