Skip to content

v1.4.0

Latest
Compare
Choose a tag to compare
@ntbosscher ntbosscher released this 16 Jul 13:08
Update reflectx to allow for optional nested structs

Nested structs are now only instantiated when one of the database columns in that nested struct is not nil. This allows objects scanned in left/outer joins to keep their natural types (instead of setting everything to NullableX).

Example:

select house.id, owner.*,
from house
left join owner on owner.id = house.owner

type House struct {
 ID      int
 Owner   *Person // if left join gives nulls, Owner will be nil
}

type Owner struct {
 ID int  // no need to set this to sql.NullInt
}