Replies: 1 comment 3 replies
-
The DBA in me cries a little here. 😢 😉 While But beyond this, as an application developer, this proposed change also unsettles me. With the existing lax behavior, you at least know all columns returned from the database were matched to your struct. But with this typos or mismatched names would silently fail. You would have a zero value you weren't expecting. That seems dangerous. |
Beta Was this translation helpful? Give feedback.
-
Say I have a table
and a model
And I want to query and hydrate the model
Currently this gives the error
struct doesn't have corresponding row field color
(on lines 727-732 or rows.go). The example code is trivial, but, in a table with multiple columns where a few may not be selected it's annoying to have to explicitly list each field, it's much easier to issue aselect *
query.I guess the reasoning is that the software should select only the fields it needs, but, that seems like a decision that should be left up to the dev. Would you be willing to accept a PR to address this?
I was thinking to use the
lax
field and push it down to thelookupNamedStructFields
function, whenlax = false
the current behavior is used, whenlax = true
this method would ignore fields wheref.path == nil
Beta Was this translation helpful? Give feedback.
All reactions