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

Can't scan values using []byte or []string #90

Closed
ssttevee opened this issue Jul 8, 2019 · 1 comment
Closed

Can't scan values using []byte or []string #90

ssttevee opened this issue Jul 8, 2019 · 1 comment

Comments

@ssttevee
Copy link

ssttevee commented Jul 8, 2019

Using postgres,

var data []byte
db.From("table").Select("data").ScanVal(&data)

The above snippet fails with this error:

goqu: Cannot scan into a slice when calling ScanVal

I can work around this by wrapping it in a container type and using ScanStruct instead of ScanVal:

var container struct {
	Data []byte `db:"data"`
}

db.From("table").Select("data").ScanStruct(&container)

data := container.data

The same thing happens with pq.StringArray (and []string) even though it implements sql.Scanner.

doug-martin added a commit that referenced this issue Jul 11, 2019
* When a slice that is `*sql.RawBytes`, `*[]byte` or `sql.Scanner` no errors will be returned.
doug-martin added a commit that referenced this issue Jul 11, 2019
* When a slice that is `*sql.RawBytes`, `*[]byte` or `sql.Scanner` no errors will be returned.
@doug-martin doug-martin mentioned this issue Jul 11, 2019
doug-martin added a commit that referenced this issue Jul 11, 2019
* When a slice that is `*sql.RawBytes`, `*[]byte` or `sql.Scanner` no errors will be returned.
@doug-martin
Copy link
Owner

Fixed in the latest version

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

No branches or pull requests

2 participants