Skip to content

Commit

Permalink
fix(spanner): fix escaping of database name in spanner ddl with POSTG…
Browse files Browse the repository at this point in the history
…RES dialect (GoogleCloudPlatform#5938)
  • Loading branch information
rahul2393 authored and betsy-lichtenberg committed Apr 25, 2022
1 parent 48db71a commit 139556e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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

0 comments on commit 139556e

Please sign in to comment.