Closed michaelgmiller closed 6 years ago
Do you mean the table in the db has a column of type bytea, or a column of an array type? I haven't experimented with those at all.
Or are you trying to write a []byte slice to a text column? Proteus currently treats slices as a way to specify multiple values for an IN clause. If you want to insert text, you can declare your []byte parameter to be a string and do a type convert when passing in a value.
"Do you mean the table in the db has a column of type bytea," - yep, that's exactly it! The table also has a JSONB column, but I see that's covered by https://github.com/jonbodner/proteus/issues/11.
Hrm. Yeah, I need to think about a clean way to handle this case. Any suggestions? I could add another struct tag to indicate that a slice parameter is not an in clause. I could say that a slice of bytes is a special case and never make it an in clause.
Hmm maybe a tag for a custom scanner would be good? Then you could easily extend support for JSONB, I think?
On Wed, May 9, 2018 at 3:07 PM Jon Bodner notifications@github.com wrote:
Hrm. Yeah, I need to think about a clean way to handle this case. Any suggestions? I could add another struct tag to indicate that a slice parameter is not an in clause. I could say that a slice of bytes is a special case and never make it an in clause.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jonbodner/proteus/issues/24#issuecomment-387732056, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDISnAitYqhCFCvY54SY3_hKNnJ35z0ks5twun2gaJpZM4TzK88 .
Or if it's easier to add, you could special case it (assuming JSONB columns can be loaded as a string for the time being). Hoping to get started on a project that uses this functionality next week, so let me know if I can help in any way or you want to run any designs by me!
They can. We currently use strings for json blobs.
lør. 19. maj 2018 kl. 21.10 skrev michaelgmiller notifications@github.com:
Or if it's easier to add, you could special case it (assuming JSONB columns can be loaded as a string for the time being). Hoping to get started on a project that uses this functionality next week, so let me know if I can help in any way or you want to run any designs by me!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jonbodner/proteus/issues/24#issuecomment-390426162, or mute the thread https://github.com/notifications/unsubscribe-auth/AGkBnvgJRyvnm_tasQwmethQIYE6kwuUks5t0G4ngaJpZM4TzK88 .
-- Hilsen Bjørn Sørensen Tlf.: (+45) 28447177
Awesome! I think special casing byte slices makes sense then.
ok, let me see what I can do. If you can give me a simple test schema (just a table) so I can add it as a test case, that'd be great.
Related topic: now that I have some time to think about Proteus again, I'm thinking about handling features that are common across databases, but not reflected in the go's sql API. Things like bulk loading, nested transaction (savepoints), maybe JSON types. It will probably involve passing in adapters that implement additional optional interfaces, and I'll write the adapters for MySQL/Postgres/SQLite. If you have ideas for features that could/should be added that fall into this category, let me know.
Can you try using proteus at commit tag 6333b874635f4cb304d362b1af3392b94723e5e4 and see if it works for you? I've tested with the blob type in sqlite and it passes my test. This also includes code that adds support for prof
tags embedded fields.
Haven't gotten my tests fully working yet, but it seems to solve the initial issue! Feel free to merge and I can let you know if we see any problems down the road.
Thanks for the quick fix!!
OK did some more testing and this seems to work :) Thanks again for the quick fix!! Excited to see it merged in!
Done #26 addresses this, tagged as v0.8.0
I have a Dao with a
[]byte
column. When I try to insert, I getReceived unexpected error pq: INSERT has more expressions than target columns
If I remove the reference to the
[]byte
column, things work as requested. Does Proteus support inserting to[]byte
columns?