diff --git a/VERSION b/VERSION index dceee401..f8acb767 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -xorm v0.5.2.0310 +xorm v0.5.2.0314 diff --git a/session.go b/session.go index c71b38c6..09b80916 100644 --- a/session.go +++ b/session.go @@ -4041,6 +4041,16 @@ func (session *Session) tbName(table *core.Table) string { return tbName } +// tbName get some table's table name +func (session *Session) tbNameNoSchema(table *core.Table) string { + if len(session.Statement.AltTableName) > 0 { + return session.Statement.AltTableName + } + + return table.Name +} + +// Sync2 func (s *Session) Sync2(beans ...interface{}) error { engine := s.Engine @@ -4055,7 +4065,7 @@ func (s *Session) Sync2(beans ...interface{}) error { v := rValue(bean) table := engine.mapType(v) structTables = append(structTables, table) - var tbName = s.tbName(table) + var tbName = s.tbNameNoSchema(table) var oriTable *core.Table for _, tb := range tables { @@ -4209,7 +4219,7 @@ func (s *Session) Sync2(beans ...interface{}) error { for _, table := range tables { var oriTable *core.Table for _, structTable := range structTables { - if equalNoCase(table.Name, s.tbName(structTable)) { + if equalNoCase(table.Name, s.tbNameNoSchema(structTable)) { oriTable = structTable break } diff --git a/xorm.go b/xorm.go index d03918e9..61f431d9 100644 --- a/xorm.go +++ b/xorm.go @@ -17,7 +17,7 @@ import ( ) const ( - Version string = "0.5.2.0310" + Version string = "0.5.2.0314" ) func regDrvsNDialects() bool {