diff options
author | Zsombor <gzsombor@users.noreply.github.com> | 2019-01-16 22:24:09 +0100 |
---|---|---|
committer | techknowlogick <hello@techknowlogick.com> | 2019-01-16 16:24:09 -0500 |
commit | c2dcb3514840d6807439f4b154a6802b00bf6d79 (patch) | |
tree | 3f80d4c322a1f2c19e65a59895affcf34d60fd7e /vendor/github.com/go-xorm/xorm | |
parent | 19e651c0dd81601551acbf4f818c24670515192b (diff) | |
download | gitea-c2dcb3514840d6807439f4b154a6802b00bf6d79.tar.gz gitea-c2dcb3514840d6807439f4b154a6802b00bf6d79.zip |
Fixing #5728: (#5747)
* Format boolean values to true/false even when it is returned as byte-slice,
* Fix the sequence generation, the proper sequence name is used (instead of 'table_id_seq'), and fix the next value be max+1 always
Diffstat (limited to 'vendor/github.com/go-xorm/xorm')
-rw-r--r-- | vendor/github.com/go-xorm/xorm/engine.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/vendor/github.com/go-xorm/xorm/engine.go b/vendor/github.com/go-xorm/xorm/engine.go index 04af3f210c..c1bf06e15c 100644 --- a/vendor/github.com/go-xorm/xorm/engine.go +++ b/vendor/github.com/go-xorm/xorm/engine.go @@ -527,7 +527,11 @@ func (engine *Engine) dumpTables(tables []*core.Table, w io.Writer, tp ...core.D } else if col.SQLType.IsNumeric() { switch reflect.TypeOf(d).Kind() { case reflect.Slice: - temp += fmt.Sprintf(", %s", string(d.([]byte))) + if col.SQLType.Name == core.Bool { + temp += fmt.Sprintf(", %v", strconv.FormatBool(d.([]byte)[0] != byte('0'))) + } else { + 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)) @@ -564,7 +568,7 @@ func (engine *Engine) dumpTables(tables []*core.Table, w io.Writer, tp ...core.D // FIXME: Hack for postgres if string(dialect.DBType()) == core.POSTGRES && table.AutoIncrColumn() != nil { - _, err = io.WriteString(w, "SELECT setval('table_id_seq', COALESCE((SELECT MAX("+table.AutoIncrColumn().Name+") FROM "+dialect.Quote(table.Name)+"), 1), false);\n") + _, err = io.WriteString(w, "SELECT setval('"+table.Name+"_id_seq', COALESCE((SELECT MAX("+table.AutoIncrColumn().Name+") + 1 FROM "+dialect.Quote(table.Name)+"), 1), false);\n") if err != nil { return err } |