Fix exporting into Postgres, problems: (#1186)
* UUID and BOOL type shouldn't have a length field * Incorrect quoting cause that the column names are selected instead of the column values
This commit is contained in:
parent
a8f0a7110a
commit
1cd2662be9
|
@ -822,7 +822,7 @@ func (db *postgres) SqlType(c *core.Column) string {
|
||||||
case core.NVarchar:
|
case core.NVarchar:
|
||||||
res = core.Varchar
|
res = core.Varchar
|
||||||
case core.Uuid:
|
case core.Uuid:
|
||||||
res = core.Uuid
|
return core.Uuid
|
||||||
case core.Blob, core.TinyBlob, core.MediumBlob, core.LongBlob:
|
case core.Blob, core.TinyBlob, core.MediumBlob, core.LongBlob:
|
||||||
return core.Bytea
|
return core.Bytea
|
||||||
case core.Double:
|
case core.Double:
|
||||||
|
@ -834,6 +834,10 @@ func (db *postgres) SqlType(c *core.Column) string {
|
||||||
res = t
|
res = t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.EqualFold(res, "bool") {
|
||||||
|
// for bool, we don't need length information
|
||||||
|
return res
|
||||||
|
}
|
||||||
hasLen1 := (c.Length > 0)
|
hasLen1 := (c.Length > 0)
|
||||||
hasLen2 := (c.Length2 > 0)
|
hasLen2 := (c.Length2 > 0)
|
||||||
|
|
||||||
|
|
|
@ -481,7 +481,8 @@ func (engine *Engine) dumpTables(tables []*core.Table, w io.Writer, tp ...core.D
|
||||||
}
|
}
|
||||||
|
|
||||||
cols := table.ColumnsSeq()
|
cols := table.ColumnsSeq()
|
||||||
colNames := dialect.Quote(strings.Join(cols, dialect.Quote(", ")))
|
colNames := engine.dialect.Quote(strings.Join(cols, engine.dialect.Quote(", ")))
|
||||||
|
destColNames := dialect.Quote(strings.Join(cols, dialect.Quote(", ")))
|
||||||
|
|
||||||
rows, err := engine.DB().Query("SELECT " + colNames + " FROM " + engine.Quote(table.Name))
|
rows, err := engine.DB().Query("SELECT " + colNames + " FROM " + engine.Quote(table.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -496,7 +497,7 @@ func (engine *Engine) dumpTables(tables []*core.Table, w io.Writer, tp ...core.D
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = io.WriteString(w, "INSERT INTO "+dialect.Quote(table.Name)+" ("+colNames+") VALUES (")
|
_, err = io.WriteString(w, "INSERT INTO "+dialect.Quote(table.Name)+" ("+destColNames+") VALUES (")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue