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

How load collections? #94

Closed
gebv opened this issue Dec 1, 2015 · 5 comments
Closed

How load collections? #94

gebv opened this issue Dec 1, 2015 · 5 comments

Comments

@gebv
Copy link

gebv commented Dec 1, 2015

Need to load ids. How to do it?

ids := []int64{}
Query(pg.LoadInto(&ids), "SELECT id FROM table")
// unsupported pg.valuesLoader

Query(&ids, "SELECT id FROM table")
// unsupported []int64
@gebv
Copy link
Author

gebv commented Dec 1, 2015

Ok. Need type of Ints.
If floats?

@vmihailenco
Copy link
Member

For now the only way is to write something similar to pg.Ints - https://github.com/go-pg/pg/blob/master/loader.go#L121-L150. It is not too complicated.

I will consider supporting []int/[]float/[]string natively, but I am not sure if this is the right change...

@gebv
Copy link
Author

gebv commented Dec 2, 2015

Yeah, maybe you're right. The wrapper best solution

@gebv gebv closed this as completed Dec 2, 2015
@vmihailenco
Copy link
Member

Let's keep this open. Probably it will be easy change :)

@vmihailenco vmihailenco reopened this Dec 2, 2015
@vmihailenco
Copy link
Member

This is supported in v4 - https://github.com/go-pg/pg/blob/master/db_test.go#L105-L116

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