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

spanner/spansql: The table name within ALTER DATABASE statement should be escaped with backquote #5972

Closed
gecko655 opened this issue May 2, 2022 · 0 comments · Fixed by #6621
Assignees
Labels
api: spanner Issues related to the Spanner API. priority: p3 Desirable enhancement or fix. May not be included in next release.

Comments

@gecko655
Copy link
Contributor

gecko655 commented May 2, 2022

Client

Cloud Spanner

Environment

Go playground

Go Environment
(This is the environment of my PC, not Go playground)

❯ go version
go version go1.17.5 darwin/arm64

❯ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/[UserName]/Library/Caches/go-build"
GOENV="/Users/[UserName]/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/[UserName]/.asdf/installs/golang/1.17.5/packages/pkg/mod"
GOOS="darwin"
GOPATH="/Users/[UserName]/.asdf/installs/golang/1.17.5/packages"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/[UserName]/.asdf/installs/golang/1.17.5/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/[UserName]/.asdf/installs/golang/1.17.5/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.17.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/[UserName]/git/google-cloud-go/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_c/7hkzyhtj5mxc38jm7661stc00000gq/T/go-build755299587=/tmp/go-build -gno-record-gcc-switches -fno-common"

Code

package main

import (
	"fmt"

	"cloud.google.com/go/spanner/spansql"
)

func main() {
	ddl, _ := spansql.ParseDDL("test", "ALTER DATABASE `test-db` SET OPTIONS (optimizer_version=4, version_retention_period = '7d', enable_key_visualizer=true)")
	fmt.Println(ddl.List[0].SQL())
}

https://go.dev/play/p/dqrlf-0YbE6

Expected behavior

Output a valid SQL statement.

ALTER DATABASE `test-db` SET OPTIONS (optimizer_version=4, version_retention_period='7d', enable_key_visualizer=true)

Actual behavior

Output an invalid SQL statement.
The table name with hyphens should be escaped with backquotes.

ALTER DATABASE test-db SET OPTIONS (optimizer_version=4, version_retention_period='7d', enable_key_visualizer=true)

Screenshots

スクリーンショット 2022-05-02 21 23 24

@gecko655 gecko655 added the triage me I really want to be triaged. label May 2, 2022
@product-auto-label product-auto-label bot added the api: spanner Issues related to the Spanner API. label May 2, 2022
@rahul2393 rahul2393 added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed triage me I really want to be triaged. labels May 5, 2022
@rahul2393 rahul2393 assigned rahul2393 and unassigned rahul2393 Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. priority: p3 Desirable enhancement or fix. May not be included in next release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants