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

Update reflectx to allow for optional nested structs #847

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Jan 23, 2023

  1. 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:
    ```sql
    select house.id, owner.*,
    from house
    left join owner on owner.id = house.owner
    ```
    
    ``` golang
    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
    }
    ```
    ntbosscher committed Jan 23, 2023
    Configuration menu
    Copy the full SHA
    0877ae6 View commit details
    Browse the repository at this point in the history