dump support bool

This commit is contained in:
Lunny Xiao 2017-01-20 10:12:06 +08:00
parent 263f9d3fa5
commit c360c20aa5
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 12 additions and 0 deletions

View File

@ -488,6 +488,18 @@ func (engine *Engine) dumpTables(tables []*core.Table, w io.Writer, tp ...core.D
switch reflect.TypeOf(d).Kind() { switch reflect.TypeOf(d).Kind() {
case reflect.Slice: case reflect.Slice:
temp += fmt.Sprintf(", %s", string(d.([]byte))) temp += fmt.Sprintf(", %s", string(d.([]byte)))
case reflect.Int16, reflect.Int8, reflect.Int32, reflect.Int64, reflect.Int:
if col.SQLType.Name == core.Bool {
temp += fmt.Sprintf(", %v", strconv.FormatBool(reflect.ValueOf(d).Int() > 0))
} else {
temp += fmt.Sprintf(", %v", d)
}
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
if col.SQLType.Name == core.Bool {
temp += fmt.Sprintf(", %v", strconv.FormatBool(reflect.ValueOf(d).Uint() > 0))
} else {
temp += fmt.Sprintf(", %v", d)
}
default: default:
temp += fmt.Sprintf(", %v", d) temp += fmt.Sprintf(", %v", d)
} }