@@ -83,27 +83,27 @@ func (q *Query) BindG(ctx context.Context, obj interface{}) error {
83
83
//
84
84
// Example usage:
85
85
//
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
+ // }
103
103
//
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)
107
107
//
108
108
// For custom objects that want to use eager loading, please see the
109
109
// loadRelationships function.
@@ -368,6 +368,9 @@ func ptrFromMapping(val reflect.Value, mapping uint64, addressOf bool) reflect.V
368
368
369
369
val = val .Field (int (v ))
370
370
if val .Kind () == reflect .Ptr {
371
+ if val .IsNil () {
372
+ val = reflect .New (val .Type ().Elem ())
373
+ }
371
374
val = reflect .Indirect (val )
372
375
}
373
376
}
@@ -606,8 +609,7 @@ func parseNumeric(s string, t reflect.Type) interface{} {
606
609
reflect .Uint32 ,
607
610
reflect .Uint64 :
608
611
res , err = strconv .ParseUint (s , 0 , t .Bits ())
609
- case reflect .Float32 ,
610
- reflect .Float64 :
612
+ case reflect .Float32 , reflect .Float64 :
611
613
res , err = strconv .ParseFloat (s , t .Bits ())
612
614
}
613
615
if err != nil {
@@ -803,7 +805,7 @@ var specialWordReplacer = strings.NewReplacer(
803
805
804
806
// unTitleCase attempts to undo a title-cased string.
805
807
//
806
- // DO NOT USE THIS METHOD IF YOU CAN AVOID IT
808
+ // # DO NOT USE THIS METHOD IF YOU CAN AVOID IT
807
809
//
808
810
// Normally this would be easy but we have to deal with uppercased words
809
811
// of varying lengths. We almost never use this function so it
0 commit comments