Skip to content

Commit c603f9e

Browse files
committed
refactor_database_file
1 parent bd04034 commit c603f9e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

database.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,10 +1215,10 @@ func StructScan(s interface{}, columns []string, fieldsIndex map[string]int, ind
12151215
r = append(r, x)
12161216
} else {
12171217
var str string
1218-
swapValues[index] = reflect.New(reflect.TypeOf(str)).Elem().Addr().Interface()
1218+
y := reflect.New(reflect.TypeOf(str))
1219+
swapValues[index] = y.Elem().Addr().Interface()
12191220
r = append(r, swapValues[index])
12201221
}
1221-
12221222
}
12231223
}
12241224
return
@@ -1237,11 +1237,17 @@ func SwapValuesToBool(s interface{}, swap *map[int]interface{}) {
12371237
maps.Field(index).SetBool(*dbValue2)
12381238
}
12391239
} else {
1240-
var isBool bool
1241-
boolStr := modelType.Field(index).Tag.Get("true")
12421240
dbValue, ok := element.(*string)
12431241
if ok {
1244-
isBool = *dbValue == boolStr
1242+
var isBool bool
1243+
if *dbValue == "true" {
1244+
isBool = true
1245+
} else if *dbValue == "false" {
1246+
isBool = false
1247+
} else {
1248+
boolStr := modelType.Field(index).Tag.Get("true")
1249+
isBool = *dbValue == boolStr
1250+
}
12451251
if maps.Field(index).Kind() == reflect.Ptr {
12461252
maps.Field(index).Set(reflect.ValueOf(&isBool))
12471253
} else {

0 commit comments

Comments
 (0)