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

fix(spanner): fix escaping of database name in spanner ddl with POSTGRES dialect #5938

Merged
merged 2 commits into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion mmv1/templates/terraform/encoders/spanner_database.go.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
obj["createStatement"] = fmt.Sprintf("CREATE DATABASE `%s`", obj["name"])
if dialect, ok := obj["databaseDialect"]; ok && dialect == "POSTGRESQL" {
obj["createStatement"] = fmt.Sprintf("CREATE DATABASE %s", obj["name"])
obj["createStatement"] = fmt.Sprintf("CREATE DATABASE \"%s\"", obj["name"])
}
delete(obj, "name")
delete(obj, "instance")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ resource "google_spanner_instance" "basic" {

resource "google_spanner_database" "basic_spangres" {
instance = google_spanner_instance.basic.name
name = "%s_spangres"
name = "%s-spangres"
database_dialect = "POSTGRESQL"
deletion_protection = false
}
Expand All @@ -188,7 +188,7 @@ resource "google_spanner_instance" "basic" {

resource "google_spanner_database" "basic_spangres" {
instance = google_spanner_instance.basic.name
name = "%s_spangres"
name = "%s-spangres"
database_dialect = "POSTGRESQL"
ddl = [
"CREATE TABLE t1 (t1 bigint NOT NULL PRIMARY KEY)",
Expand Down