From c2dcb3514840d6807439f4b154a6802b00bf6d79 Mon Sep 17 00:00:00 2001 From: Zsombor Date: Wed, 16 Jan 2019 22:24:09 +0100 Subject: [PATCH] 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 --- Gopkg.lock | 4 ++-- Gopkg.toml | 2 +- vendor/github.com/go-xorm/xorm/engine.go | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index ca02fe933..88d3567b2 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -406,11 +406,11 @@ version = "v0.6.0" [[projects]] - digest = "1:d366480c27ab51b3f7e995f25503063e7a6ebc7feb269df2499c33471f35cd62" + digest = "1:f3015325cb2a17a6ff838358574921a343a0295059b7eb5bec07187131befc0b" name = "github.com/go-xorm/xorm" packages = ["."] pruneopts = "NUT" - revision = "1cd2662be938bfee0e34af92fe448513e0560fb1" + revision = "a6300f2a45e05a8f75f00a1d6188049fe7851915" [[projects]] branch = "master" diff --git a/Gopkg.toml b/Gopkg.toml index cd40aaedc..2eb81803a 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -38,7 +38,7 @@ ignored = ["google.golang.org/appengine*"] [[override]] name = "github.com/go-xorm/xorm" - revision = "1cd2662be938bfee0e34af92fe448513e0560fb1" + revision = "a6300f2a45e05a8f75f00a1d6188049fe7851915" [[override]] name = "github.com/go-xorm/builder" diff --git a/vendor/github.com/go-xorm/xorm/engine.go b/vendor/github.com/go-xorm/xorm/engine.go index 04af3f210..c1bf06e15 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 }