-
Notifications
You must be signed in to change notification settings - Fork 54
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
Scan into struct for db.QueryRow #5
Comments
I'm glad you find the package useful. Unfortunately I don't think we can support |
Hmm, https://github.com/jmoiron/sqlx have something like that:
But I don't have time now to investigate how it works and personally I think |
|
Maybe something like this: But I don't know if I can copy some of Go |
Yeah that works, but that's wrapping query which isn't what I want to do in this library. It doesn't really work analogous to how the Scan function works. |
So, any suggestions how to change it or you don't want something like that in you package? |
That's exactly what |
I don't want to wrap any sort of DB object and run queries within this package, that's not the intent of the design. At that point sqlx or similar would be better choice. The only way I could see it working is if we could get columns from a sql.Row object, so if the Go developers could be convinced to add a Columns() method to it like sql.Rows has. The chances of that happening are pretty slim I think. |
To put it another way, the package is built to function around anything that implements sqlstruct.Rows, which sql.Row does not. If it did, then it would work :) |
Would that be sufficient: golang/go#5606 ? |
That wouldn't help here, that issue is for an API for database driver authors. You would need to file a new issue for adding the Columns() method to sql.Row. To be honest I think it's probably not worth the effort, you could just use a simple utility function in your code base, basically what you had here: #5 (comment) |
Thank you for your time. |
Hello,
Thank you for really useful package.
Maybe you can consider adding function to scan only one row into struct (for
db.QueryRow
).Cheers
The text was updated successfully, but these errors were encountered: