database/sql: missing escape functions
### What version of Go are you using (`go version`)? go version go1.7.4 linux/amd64 ### What operating system and processor architecture are you using (`go env`)? GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/nefthy/go-test/" GORACE="" GOROOT="/usr/lib/go" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" CC="x86_64-pc-linux-gnu-gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/home/nefthy/go-test/tmp/go-build451484149=/tmp/go-build -gno-record-gcc-switches" CXX="x86_64-pc-linux-gnu-g++" CGO_ENABLED="1" ### What did you do? There are situations when strings need to be escaped in queries that can not be done with placeholders. An example the following queries cannot be expressed with ? placeholders: ```sql SELECT id, ? FROM table -- Must be escaped as an identifier SELECT id FROM ? -- Also identifier quoting SELECT id FROM table WHERE ? LIKE ? -- With either the first or second parameter being a column reference ``` Using Sprintf is no option, since the identifiers need to be properly quoted. The quoting and escaping is inherently vendor specific and may even depend on configuration on a per database/connection basis (hello there MySql...). ### What did you expect to see? The driver must export Quoting which are passed along by the database/sql Api. As far as I can tell the folling functions are needed - QuoteString: quotes and escapes a string so it can be used as a string literal (ex: mysql_
Posted by nefthy on Dec 30, 2016, 3:05 PM
Tags
Related issues
- Custom games stuck on "finding server" for all european servers
- Feature request: add ACP (Agent Client Protocol) stdio JSON-RPC mode
- Forza Horizon 6 (2483190)
- Turn off integrated browser for default
- Weekly updates are too frequent
- [BUG] Max 20x plan: 100% usage after 2 hours of light work (5 commits, no agents)
Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments
github (Sysadmin)
Custom games stuck on "finding server" for all european servers
Feature request: add ACP (Agent Client Protocol) stdio JSON-RPC mode
Forza Horizon 6 (2483190)
Turn off integrated browser for default
Weekly updates are too frequent
[BUG] Max 20x plan: 100% usage after 2 hours of light work (5 commits, no agents)
Add gemini-3.1-pro-preview
[TF2] Feature request: Bring Back Quickplay
database/sql: missing escape functions
### What version of Go are you using (`go version`)? go version go1.7.4 linux/amd64 ### What operating system and processor architecture are you using (`go env`)? GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/nefthy/go-test/" GORACE="" GOROOT="/usr/lib/go" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" CC="x86_64-pc-linux-gnu-gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/home/nefthy/go-test/tmp/go-build451484149=/tmp/go-build -gno-record-gcc-switches" CXX="x86_64-pc-linux-gnu-g++" CGO_ENABLED="1" ### What did you do? There are situations when strings need to be escaped in queries that can not be done with placeholders. An example the following queries cannot be expressed with ? placeholders: ```sql SELECT id, ? FROM table -- Must be escaped as an identifier SELECT id FROM ? -- Also identifier quoting SELECT id FROM table WHERE ? LIKE ? -- With either the first or second parameter being a column reference ``` Using Sprintf is no option, since the identifiers need to be properly quoted. The quoting and escaping is inherently vendor specific and may even depend on configuration on a per database/connection basis (hello there MySql...). ### What did you expect to see? The driver must export Quoting which are passed along by the database/sql Api. As far as I can tell the folling functions are needed - QuoteString: quotes and escapes a string so it can be used as a string literal (ex: mysql_
Comments (0)
No comments yet. Start the discussion.