@@ -83,27 +83,27 @@ func (q *Query) BindG(ctx context.Context, obj interface{}) error {
8383//
8484// Example usage:
8585//
86- // type JoinStruct struct {
87- // // User1 can have it's struct fields bound to since it specifies
88- // // ,bind in the struct tag, it will look specifically for
89- // // fields that are prefixed with "user." returning from the query.
90- // // For example "user.id" column name will bind to User1.ID
91- // User1 *models.User `boil:"user,bind"`
92- // // User2 will follow the same rules as noted above except it will use
93- // // "friend." as the prefix it's looking for.
94- // User2 *models.User `boil:"friend,bind"`
95- // // RandomData will not be recursed into to look for fields to
96- // // bind and will not be bound to because of the - for the name.
97- // RandomData myStruct `boil:"-"`
98- // // Date will not be recursed into to look for fields to bind because
99- // // it does not specify ,bind in the struct tag. But it can be bound to
100- // // as it does not specify a - for the name.
101- // Date time.Time
102- // }
86+ // type JoinStruct struct {
87+ // // User1 can have it's struct fields bound to since it specifies
88+ // // ,bind in the struct tag, it will look specifically for
89+ // // fields that are prefixed with "user." returning from the query.
90+ // // For example "user.id" column name will bind to User1.ID
91+ // User1 *models.User `boil:"user,bind"`
92+ // // User2 will follow the same rules as noted above except it will use
93+ // // "friend." as the prefix it's looking for.
94+ // User2 *models.User `boil:"friend,bind"`
95+ // // RandomData will not be recursed into to look for fields to
96+ // // bind and will not be bound to because of the - for the name.
97+ // RandomData myStruct `boil:"-"`
98+ // // Date will not be recursed into to look for fields to bind because
99+ // // it does not specify ,bind in the struct tag. But it can be bound to
100+ // // as it does not specify a - for the name.
101+ // Date time.Time
102+ // }
103103//
104- // models.Users(
105- // qm.InnerJoin("users as friend on users.friend_id = friend.id")
106- // ).Bind(&joinStruct)
104+ // models.Users(
105+ // qm.InnerJoin("users as friend on users.friend_id = friend.id")
106+ // ).Bind(&joinStruct)
107107//
108108// For custom objects that want to use eager loading, please see the
109109// loadRelationships function.
@@ -368,6 +368,9 @@ func ptrFromMapping(val reflect.Value, mapping uint64, addressOf bool) reflect.V
368368
369369 val = val .Field (int (v ))
370370 if val .Kind () == reflect .Ptr {
371+ if val .IsNil () {
372+ val = reflect .New (val .Type ().Elem ())
373+ }
371374 val = reflect .Indirect (val )
372375 }
373376 }
@@ -606,8 +609,7 @@ func parseNumeric(s string, t reflect.Type) interface{} {
606609 reflect .Uint32 ,
607610 reflect .Uint64 :
608611 res , err = strconv .ParseUint (s , 0 , t .Bits ())
609- case reflect .Float32 ,
610- reflect .Float64 :
612+ case reflect .Float32 , reflect .Float64 :
611613 res , err = strconv .ParseFloat (s , t .Bits ())
612614 }
613615 if err != nil {
@@ -803,7 +805,7 @@ var specialWordReplacer = strings.NewReplacer(
803805
804806// unTitleCase attempts to undo a title-cased string.
805807//
806- // DO NOT USE THIS METHOD IF YOU CAN AVOID IT
808+ // # DO NOT USE THIS METHOD IF YOU CAN AVOID IT
807809//
808810// Normally this would be easy but we have to deal with uppercased words
809811// of varying lengths. We almost never use this function so it
0 commit comments