improved Sync2 method
This commit is contained in:
parent
fef024b600
commit
af7dd2bcf7
25
engine.go
25
engine.go
|
@ -1081,8 +1081,11 @@ func (engine *Engine) Sync2(beans ...interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
structTables := make([]*core.Table, 0)
|
||||
|
||||
for _, bean := range beans {
|
||||
table := engine.autoMap(bean)
|
||||
structTables = append(structTables, table)
|
||||
|
||||
var oriTable *core.Table
|
||||
for _, tb := range tables {
|
||||
|
@ -1207,6 +1210,28 @@ func (engine *Engine) Sync2(beans ...interface{}) error {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, table := range tables {
|
||||
var oriTable *core.Table
|
||||
for _, structTable := range structTables {
|
||||
if table.Name == structTable.Name {
|
||||
oriTable = structTable
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if oriTable == nil {
|
||||
//engine.LogWarnf("Table %s has no struct to mapping it", table.Name)
|
||||
continue
|
||||
}
|
||||
|
||||
for _, colName := range table.ColumnsSeq() {
|
||||
if oriTable.GetColumn(colName) == nil {
|
||||
engine.LogWarnf("Table %s has column %s but struct has not related field",
|
||||
table.Name, colName)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue