Skip to content
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

config: Change database URL to URI #2407

Merged
merged 2 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/authors/sqlc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sql:
queries: postgresql/query.sql
engine: postgresql
database:
url: postgresql://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}/authors
uri: postgresql://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}/authors
rules:
- sqlc/db-prepare
gen:
Expand All @@ -15,7 +15,7 @@ sql:
queries: mysql/query.sql
engine: mysql
database:
url: root:${MYSQL_ROOT_PASSWORD}@tcp(${MYSQL_HOST}:${MYSQL_PORT})/authors?multiStatements=true&parseTime=true
uri: root:${MYSQL_ROOT_PASSWORD}@tcp(${MYSQL_HOST}:${MYSQL_PORT})/authors?multiStatements=true&parseTime=true
rules:
- sqlc/db-prepare
gen:
Expand All @@ -26,7 +26,7 @@ sql:
queries: sqlite/query.sql
engine: sqlite
database:
url: file:authors?mode=memory&cache=shared
uri: file:authors?mode=memory&cache=shared
rules:
- sqlc/db-prepare
gen:
Expand Down
2 changes: 1 addition & 1 deletion examples/batch/sqlc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"queries": "postgresql/query.sql",
"engine": "postgresql",
"database": {
"url": "postgresql://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}/batch"
"uri": "postgresql://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}/batch"
},
"rules": [
"sqlc/db-prepare"
Expand Down
6 changes: 3 additions & 3 deletions examples/booktest/sqlc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"queries": "postgresql/query.sql",
"engine": "postgresql",
"database": {
"url": "postgresql://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}/booktest"
"uri": "postgresql://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}/booktest"
},
"rules": [
"sqlc/db-prepare"
Expand All @@ -21,7 +21,7 @@
"queries": "mysql/query.sql",
"engine": "mysql",
"database": {
"url": "root:${MYSQL_ROOT_PASSWORD}@tcp(${MYSQL_HOST}:${MYSQL_PORT})/booktest?multiStatements=true&parseTime=true"
"uri": "root:${MYSQL_ROOT_PASSWORD}@tcp(${MYSQL_HOST}:${MYSQL_PORT})/booktest?multiStatements=true&parseTime=true"
},
"rules": [
"sqlc/db-prepare"
Expand All @@ -34,7 +34,7 @@
"queries": "sqlite/query.sql",
"engine": "sqlite",
"database": {
"url": "file:booktest?mode=memory&cache=shared"
"uri": "file:booktest?mode=memory&cache=shared"
},
"rules": [
"sqlc/db-prepare"
Expand Down
2 changes: 1 addition & 1 deletion examples/jets/sqlc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"queries": "postgresql/query-building.sql",
"engine": "postgresql",
"database": {
"url": "postgresql://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}/jets"
"uri": "postgresql://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}/jets"
},
"rules": [
"sqlc/db-prepare"
Expand Down
6 changes: 3 additions & 3 deletions examples/ondeck/sqlc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"queries": "postgresql/query",
"engine": "postgresql",
"database": {
"url": "postgresql://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}/ondeck"
"uri": "postgresql://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}/ondeck"
},
"rules": [
"sqlc/db-prepare"
Expand All @@ -24,7 +24,7 @@
"queries": "mysql/query",
"engine": "mysql",
"database": {
"url": "root:${MYSQL_ROOT_PASSWORD}@tcp(${MYSQL_HOST}:${MYSQL_PORT})/ondeck?multiStatements=true&parseTime=true"
"uri": "root:${MYSQL_ROOT_PASSWORD}@tcp(${MYSQL_HOST}:${MYSQL_PORT})/ondeck?multiStatements=true&parseTime=true"
},
"rules": [
"sqlc/db-prepare"
Expand All @@ -40,7 +40,7 @@
"queries": "sqlite/query",
"engine": "sqlite",
"database": {
"url": "file:ondeck?mode=memory&cache=shared"
"uri": "file:ondeck?mode=memory&cache=shared"
},
"rules": [
"sqlc/db-prepare"
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/vet.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (c *checker) checkSQL(ctx context.Context, s config.SQL) error {
if c.NoDatabase {
return fmt.Errorf("database: connections disabled via command line flag")
}
dburl, err := c.DSN(s.Database.URL)
dburl, err := c.DSN(s.Database.URI)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type Project struct {
}

type Database struct {
URL string `json:"url" yaml:"url"`
URI string `json:"uri" yaml:"uri"`
}

type Cloud struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/config/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func Validate(c *Config) error {
return fmt.Errorf("invalid config: emit_methods_with_db_argument and emit_prepared_queries settings are mutually exclusive")
}
if sql.Database != nil {
if sql.Database.URL == "" {
if sql.Database.URI == "" {
return fmt.Errorf("invalid config: database must have a non-empty URL")
kyleconroy marked this conversation as resolved.
Show resolved Hide resolved
}
}
Expand Down