Skip to content

Commit e1f1d44

Browse files
authored
Add end-to-end tests for comparisons and count(*) (#794)
* endtoend: Post comparisons test to MySQL * endtoend: Add simple test for count(*)
1 parent a83184b commit e1f1d44

File tree

20 files changed

+425
-0
lines changed

20 files changed

+425
-0
lines changed

internal/endtoend/testdata/comparisons/mysql/go/models.go

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/comparisons/sqlc.json renamed to internal/endtoend/testdata/comparisons/mysql/sqlc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{
55
"path": "go",
66
"name": "querytest",
7+
"engine": "mysql",
78
"schema": "query.sql",
89
"queries": "query.sql"
910
}

internal/endtoend/testdata/comparisons/postgresql/go/db.go

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/comparisons/postgresql/go/query.sql.go

Lines changed: 197 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- Comparison Functions and Operators
2+
-- https://www.postgresql.org/docs/current/functions-comparison.html
3+
4+
CREATE TABLE bar (id serial not null);
5+
6+
-- name: GreaterThan :many
7+
SELECT count(*) > 0 FROM bar;
8+
9+
-- name: LessThan :many
10+
SELECT count(*) < 0 FROM bar;
11+
12+
-- name: GreaterThanOrEqual :many
13+
SELECT count(*) >= 0 FROM bar;
14+
15+
-- name: LessThanOrEqual :many
16+
SELECT count(*) <= 0 FROM bar;
17+
18+
-- name: NotEqual :many
19+
SELECT count(*) != 0 FROM bar;
20+
21+
-- name: AlsoNotEqual :many
22+
SELECT count(*) <> 0 FROM bar;
23+
24+
-- name: Equal :many
25+
SELECT count(*) = 0 FROM bar;
26+
27+
28+
29+
30+
31+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "1",
3+
"packages": [
4+
{
5+
"path": "go",
6+
"name": "querytest",
7+
"engine": "postgresql",
8+
"schema": "query.sql",
9+
"queries": "query.sql"
10+
}
11+
]
12+
}

internal/endtoend/testdata/count_star/mysql/go/db.go

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/count_star/mysql/go/models.go

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/count_star/mysql/go/query.sql.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CREATE TABLE bar (id serial not null);
2+
3+
-- name: CountStar :one
4+
SELECT count(*) FROM bar;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "1",
3+
"packages": [
4+
{
5+
"path": "go",
6+
"name": "querytest",
7+
"engine": "mysql",
8+
"schema": "query.sql",
9+
"queries": "query.sql"
10+
}
11+
]
12+
}

internal/endtoend/testdata/count_star/postgresql/go/db.go

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)