-
Notifications
You must be signed in to change notification settings - Fork 813
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
Generate nullable value from subselect statements #2275
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- name: FirstRowFromFooTable :many | ||
SELECT a, (SELECT a FROM foo limit 1) as "first" FROM foo; | ||
|
||
-- name: FirstRowFromEmptyTable :many | ||
SELECT a, (SELECT a FROM empty limit 1) as "first" 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; |
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); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": "1", | ||
"packages": [ | ||
{ | ||
"path": "go", | ||
"engine": "mysql", | ||
"name": "querytest", | ||
"schema": "schema.sql", | ||
"queries": "query.sql" | ||
} | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've researched about cases a subselect returns null.
A column of no rows returns null. but if
count()
return 0.According to above documentation,
total()
also returns 0 in sqlite.Other aggregate functions returns null.