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

unsupported type []interface {}, a slice #57

Open
denwwer opened this issue Feb 1, 2017 · 1 comment
Open

unsupported type []interface {}, a slice #57

denwwer opened this issue Feb 1, 2017 · 1 comment

Comments

@denwwer
Copy link

denwwer commented Feb 1, 2017

Hi, I have issue with

// EnableInterpolation = true
data := []interface{}{1,"hello", true} // some data
db.Exec("INSERT INTO table (a, b, c) VALUES ($1, $2, $3)", data)
=> err: sql: converting Exec argument #0's type: unsupported type []interface {}, a slice

using driver github.com/jackc/pgx/stdlib, package gopkg.in/mgutz/dat.v2/dat
maybe someone was had this error, so can help me. Also it will be cool func .Values() to can handle slice

@mgutz
Copy link
Owner

mgutz commented Feb 6, 2017

First, I can't guarantee anything works with pgx/stdlib. I made a separate runner for it and found it to actually be slower with my test cases and discontinued supporting it.

Need to use spread operator, otherwise dat treats that as a single value

res, err := DB.SQL("INSERT INTO table (a, b, c) VALUES ($1, $2, $3)", data...).Exec()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants