RFC: Use provided type to create the dstTable rather than inferring from the SQL types #1872

Merged
lunny merged 18 commits from zeripath/xorm:dump-infer-from-type into master 2021-05-07 01:19:04 +00:00
Showing only changes of commit 4322c59c4f - Show all commits

View File

@ -448,21 +448,6 @@ func formatColumnValue(dstDialect dialects.Dialect, d interface{}, col *schemas.
return "NULL"
}
if dstDialect.URI().DBType == schemas.SQLITE || dstDialect.URI().DBType == schemas.MSSQL {
if dq, ok := d.(bool); ok {
if dq {
return "1"
}
return "0"
}
if val, ok := d.(reflect.Value); ok && val.Kind() == reflect.Bool {
if val.Bool() {
return "1"
}
return "0"
}
}
if dq, ok := d.(bool); ok && (dstDialect.URI().DBType == schemas.SQLITE ||
dstDialect.URI().DBType == schemas.MSSQL) {
if dq {
@ -637,7 +622,7 @@ func (engine *Engine) dumpTables(tables []*schemas.Table, w io.Writer, tp ...sch
if col == nil {
return errors.New("unknown column error")
}
temp += "," + formatColumnValue(dstDialect, val.Elem().FieldByName(col.FieldName), col)
temp += "," + formatColumnValue(dstDialect, val.Elem().FieldByName(col.FieldName).Interface(), col)
}
_, err = io.WriteString(w, temp[1:]+");\n")
if err != nil {