-
Notifications
You must be signed in to change notification settings - Fork 813
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing the code to make the subselect nullable
- Loading branch information
1 parent
ce1b4c5
commit 093ea55
Showing
30 changed files
with
417 additions
and
139 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
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
5 changes: 5 additions & 0 deletions
5
internal/endtoend/testdata/nullable_subselect/mysql/go/models.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
71 changes: 53 additions & 18 deletions
71
internal/endtoend/testdata/nullable_subselect/mysql/go/query.sql.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
13 changes: 8 additions & 5 deletions
13
internal/endtoend/testdata/nullable_subselect/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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
CREATE TABLE foo (a int not null, b int); | ||
-- name: FirstRowFromFooTable :many | ||
SELECT a, (SELECT a FROM foo limit 1) as "first" FROM foo; | ||
|
||
-- name: SubqueryWithWhereClause :many | ||
SELECT a, (SELECT COUNT(a) FROM foo WHERE a > 10) as "total" FROM foo; | ||
-- name: FirstRowFromEmptyTable :many | ||
SELECT a, (SELECT a FROM empty limit 1) as "first" FROM foo; | ||
|
||
-- name: SubqueryWithHavingClause :many | ||
SELECT a, (SELECT COUNT(a) FROM foo GROUP BY b HAVING COUNT(a) > 10) as "total" FROM foo; | ||
-- In MySQL, only count() returns 0 for empty table. | ||
-- https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html | ||
-- name: CountRowsEmptyTable :many | ||
SELECT a, (SELECT count(a) FROM empty) as "count" FROM foo; |
7 changes: 7 additions & 0 deletions
7
internal/endtoend/testdata/nullable_subselect/mysql/schema.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,7 @@ | ||
CREATE TABLE foo (a int not NULL, b int); | ||
|
||
INSERT INTO foo VALUES (1, 2); | ||
INSERT INTO foo VALUES (3, NULL); | ||
INSERT INTO foo VALUES (4, 5); | ||
|
||
CREATE TABLE empty (a int not NULL, b int); |
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
5 changes: 5 additions & 0 deletions
5
internal/endtoend/testdata/nullable_subselect/postgresql/pgx/v4/go/models.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
68 changes: 50 additions & 18 deletions
68
internal/endtoend/testdata/nullable_subselect/postgresql/pgx/v4/go/query.sql.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
13 changes: 8 additions & 5 deletions
13
internal/endtoend/testdata/nullable_subselect/postgresql/pgx/v4/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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
CREATE TABLE foo (a int not null, b int); | ||
-- name: FirstRowFromFooTable :many | ||
SELECT a, (SELECT a FROM foo limit 1) as "first" FROM foo; | ||
|
||
-- name: SubqueryWithWhereClause :many | ||
SELECT a, (SELECT COUNT(a) FROM foo WHERE a > 10) as "total" FROM foo; | ||
-- name: FirstRowFromEmptyTable :many | ||
SELECT a, (SELECT a FROM empty limit 1) as "first" FROM foo; | ||
|
||
-- name: SubqueryWithHavingClause :many | ||
SELECT a, (SELECT COUNT(a) FROM foo GROUP BY b HAVING COUNT(a) > 10) as "total" FROM foo; | ||
-- In PostgreSQL, only count() returns 0 for empty table. | ||
-- https://www.postgresql.org/docs/15/functions-aggregate.html | ||
-- name: CountRowsEmptyTable :many | ||
SELECT a, (SELECT count(a) FROM empty) as "count" FROM foo; |
7 changes: 7 additions & 0 deletions
7
internal/endtoend/testdata/nullable_subselect/postgresql/pgx/v4/schema.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,7 @@ | ||
CREATE TABLE foo (a int not NULL, b int); | ||
|
||
INSERT INTO foo VALUES (1, 2); | ||
INSERT INTO foo VALUES (3, NULL); | ||
INSERT INTO foo VALUES (4, 5); | ||
|
||
CREATE TABLE empty (a int not NULL, b int); |
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
5 changes: 5 additions & 0 deletions
5
internal/endtoend/testdata/nullable_subselect/postgresql/pgx/v5/go/models.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.