Skip to content

Commit 41c1520

Browse files
authored
feat(cmd/vet): Prepare queries against a database (#2387)
* feat(cmd/vet): Prepare queries against a database If configured, prepare queries against a running database * test: Attempt to create a database for each example * test(examples): Run vet for all examples * Don't create databases twice
1 parent 4c66700 commit 41c1520

File tree

22 files changed

+398
-85
lines changed

22 files changed

+398
-85
lines changed

examples/authors/sqlc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"schema": "postgresql/schema.sql",
66
"queries": "postgresql/query.sql",
77
"engine": "postgresql",
8+
"database": {
9+
"url": "'postgresql://%s:%s@%s:%s/authors'.format([env.PG_USER, env.PG_PASSWORD, env.PG_HOST, env.PG_PORT])"
10+
},
811
"gen": {
912
"go": {
1013
"package": "authors",

examples/batch/sqlc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"schema": "postgresql/schema.sql",
88
"queries": "postgresql/query.sql",
99
"engine": "postgresql",
10+
"database": {
11+
"url": "'postgresql://%s:%s@%s:%s/batch'.format([env.PG_USER, env.PG_PASSWORD, env.PG_HOST, env.PG_PORT])"
12+
},
1013
"sql_package": "pgx/v4",
1114
"emit_json_tags": true,
1215
"emit_prepared_queries": true,

examples/booktest/sqlc.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"path": "postgresql",
77
"schema": "postgresql/schema.sql",
88
"queries": "postgresql/query.sql",
9-
"engine": "postgresql"
9+
"engine": "postgresql",
10+
"database": {
11+
"url": "'postgresql://%s:%s@%s:%s/booktest'.format([env.PG_USER, env.PG_PASSWORD, env.PG_HOST, env.PG_PORT])"
12+
}
1013
},
1114
{
1215
"name": "booktest",
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/jets/sqlc.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
"version": "1",
33
"packages": [
44
{
5-
"path": ".",
5+
"path": "postgresql",
66
"name": "jets",
7-
"schema": "schema.sql",
8-
"queries": "query-building.sql",
9-
"engine": "postgresql"
7+
"schema": "postgresql/schema.sql",
8+
"queries": "postgresql/query-building.sql",
9+
"engine": "postgresql",
10+
"database": {
11+
"url": "'postgresql://%s:%s@%s:%s/jets'.format([env.PG_USER, env.PG_PASSWORD, env.PG_HOST, env.PG_PORT])"
12+
}
1013
}
1114
]
1215
}

examples/kotlin/sqlc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
]
4040
},
4141
{
42-
"schema": "src/main/resources/jets/schema.sql",
43-
"queries": "src/main/resources/jets/query-building.sql",
42+
"schema": "src/main/resources/jets/postgresql/schema.sql",
43+
"queries": "src/main/resources/jets/postgresql/query-building.sql",
4444
"engine": "postgresql",
4545
"codegen": [
4646
{

0 commit comments

Comments
 (0)