Skip to content
Permalink
Browse files
fix(spanner/spansql): only add comma after other option (#4551)
Co-authored-by: Hengfeng Li <hengfeng@google.com>
  • Loading branch information
olavloite and hengfengli committed Aug 5, 2021
1 parent 4952003 commit 3ac1e007163803d315dcf5db612fe003f6eab978
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
@@ -185,27 +185,26 @@ func (do DatabaseOptions) SQL() string {
hasOpt = true
if *do.OptimizerVersion == 0 {
str += "optimizer_version=null"

} else {
str += fmt.Sprintf("optimizer_version=%v", *do.OptimizerVersion)
}
}
if do.VersionRetentionPeriod != nil {
hasOpt = true
if hasOpt {
str += ", "
}
hasOpt = true
if *do.VersionRetentionPeriod == "" {
str += "version_retention_period=null"
} else {
str += fmt.Sprintf("version_retention_period='%s'", *do.VersionRetentionPeriod)
}
}
if do.EnableKeyVisualizer != nil {
hasOpt = true
if hasOpt {
str += ", "
}
hasOpt = true
if *do.EnableKeyVisualizer {
str += "enable_key_visualizer=true"
} else {
@@ -288,6 +288,28 @@ func TestSQL(t *testing.T) {
"ALTER TABLE WithRowDeletionPolicy REPLACE ROW DELETION POLICY ( OLDER_THAN ( DelTimestamp, INTERVAL 30 DAY ))",
reparseDDL,
},
{
&AlterDatabase{
Name: "dbname",
Alteration: SetDatabaseOptions{Options: DatabaseOptions{
EnableKeyVisualizer: func(b bool) *bool { return &b }(true),
}},
Position: line(1),
},
"ALTER DATABASE dbname SET OPTIONS (enable_key_visualizer=true)",
reparseDDL,
},
{
&AlterDatabase{
Name: "dbname",
Alteration: SetDatabaseOptions{Options: DatabaseOptions{
OptimizerVersion: func(i int) *int { return &i }(2),
}},
Position: line(1),
},
"ALTER DATABASE dbname SET OPTIONS (optimizer_version=2)",
reparseDDL,
},
{
&AlterDatabase{
Name: "dbname",

0 comments on commit 3ac1e00

Please sign in to comment.