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

Proposal: database/sql/driver Execer should support more types #17300

Closed
herenow opened this issue Sep 30, 2016 · 4 comments
Closed

Proposal: database/sql/driver Execer should support more types #17300

herenow opened this issue Sep 30, 2016 · 4 comments

Comments

@herenow
Copy link

herenow commented Sep 30, 2016

What version of Go are you using (go version)?

go version go1.5 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/user/gocode"
GORACE=""
GOROOT="/Users/user/.gvm/gos/go1.5"
GOTOOLDIR="/Users/user/.gvm/gos/go1.5/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT=""
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

Proposal/issue

I maintain a database/sql driver for crate.io (Crate), at https://github.com/herenow/go-crate

Crate is a "sql" database, it has support for object/json columns, and prepared statements are "baked in", in the sense that it provides us with a REST api to perform our operations, where we pass it our prepared statement and the args/bulk_args. For example:

curl -sSXPOST '127.0.0.1:4200/_sql?pretty' -d@- <<- EOF
{
  stmt: "INSERT INTO logs (metadata) VALUES (?)",
  bulk_args: [
      { count: 1 },
      { count: 2 }
  ]
}
EOF

Currently it doesn't seem possible to support something like:

db.Exec(`INSERT INTO logs (metadata) VALUES (?)`, []map[string]interface{}{...})

Because database/sql/driver only supports []byte, bool, float64, int64, string, time.Time [1], is that right?

Would it make sense for us to add support for any generic interface or allow drivers to provide their own IsValue()? Are there any alternative solutions?

[1]

case []byte, bool, float64, int64, string, time.Time:

@odeke-em odeke-em changed the title Support more types in database/sql/driver Proposal: database/sql/driver Execer should support more types Oct 1, 2016
@odeke-em
Copy link
Member

odeke-em commented Oct 1, 2016

/cc @bradfitz

@quentinmit quentinmit modified the milestone: Proposal Oct 4, 2016
@kardianos
Copy link
Contributor

@herenow No guarantee, but I'd like to do something about this for go1.8.

@kardianos
Copy link
Contributor

This is a dup of #13567 .

@bradfitz
Copy link
Contributor

bradfitz commented Oct 9, 2016

Thanks. Closing as dup. We'll track in #13567

@bradfitz bradfitz closed this as completed Oct 9, 2016
@golang golang locked and limited conversation to collaborators Oct 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants