From 90c454a96a583339a09c28341be765bfb289ff69 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 13 Jan 2016 09:58:40 +0800 Subject: [PATCH] bug fixed for Sync2 when mysql engine is myisam --- VERSION | 2 +- helpers.go | 4 ++++ session.go | 6 +++--- xorm.go | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 0e249f88..591caabc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -xorm v0.4.5.0112 +xorm v0.4.5.0113 diff --git a/helpers.go b/helpers.go index 62cc4383..7fa85d11 100644 --- a/helpers.go +++ b/helpers.go @@ -105,6 +105,10 @@ func isPKZero(pk core.PK) bool { return false } +func equalNoCase(s1, s2 string) bool { + return strings.ToLower(s1) == strings.ToLower(s2) +} + func indexNoCase(s, sep string) int { return strings.Index(strings.ToLower(s), strings.ToLower(sep)) } diff --git a/session.go b/session.go index 132a396d..eb0b7855 100644 --- a/session.go +++ b/session.go @@ -3998,7 +3998,7 @@ func (s *Session) Sync2(beans ...interface{}) error { var oriTable *core.Table for _, tb := range tables { - if tb.Name == table.Name { + if equalNoCase(tb.Name, table.Name) { oriTable = tb break } @@ -4023,7 +4023,7 @@ func (s *Session) Sync2(beans ...interface{}) error { for _, col := range table.Columns() { var oriCol *core.Column for _, col2 := range oriTable.Columns() { - if col.Name == col2.Name { + if equalNoCase(col.Name, col2.Name) { oriCol = col2 break } @@ -4146,7 +4146,7 @@ func (s *Session) Sync2(beans ...interface{}) error { for _, table := range tables { var oriTable *core.Table for _, structTable := range structTables { - if table.Name == structTable.Name { + if equalNoCase(table.Name, structTable.Name) { oriTable = structTable break } diff --git a/xorm.go b/xorm.go index 3be9b661..ea616a34 100644 --- a/xorm.go +++ b/xorm.go @@ -17,7 +17,7 @@ import ( ) const ( - Version string = "0.4.5.0112" + Version string = "0.4.5.0113" ) func regDrvsNDialects() bool {