From ede84cde60a754dff47dc8cc83ae5fc61692c801 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 3 Mar 2015 15:14:44 +0800 Subject: [PATCH] bug fixed --- session.go | 2 +- statement.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/session.go b/session.go index cf566902..4c414209 100644 --- a/session.go +++ b/session.go @@ -3367,7 +3367,7 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6 if session.Statement.ColumnStr == "" { colNames, args = buildUpdates(session.Engine, table, bean, false, false, false, false, session.Statement.allUseBool, session.Statement.useAllCols, - session.Statement.mustColumnMap, true) + session.Statement.mustColumnMap, session.Statement.columnMap, true) } else { colNames, args, err = genCols(table, session, bean, true, true) if err != nil { diff --git a/statement.go b/statement.go index f645a1d3..74a21e1e 100644 --- a/statement.go +++ b/statement.go @@ -286,7 +286,7 @@ func (statement *Statement) Table(tableNameOrBean interface{}) *Statement { func buildUpdates(engine *Engine, table *core.Table, bean interface{}, includeVersion bool, includeUpdated bool, includeNil bool, includeAutoIncr bool, allUseBool bool, useAllCols bool, - mustColumnMap map[string]bool, update bool) ([]string, []interface{}) { + mustColumnMap map[string]bool, columnMap map[string]bool, update bool) ([]string, []interface{}) { colNames := make([]string, 0) var args = make([]interface{}, 0) @@ -306,6 +306,9 @@ func buildUpdates(engine *Engine, table *core.Table, bean interface{}, if col.IsDeleted { continue } + if use, ok := columnMap[col.Name]; ok && !use { + continue + } if engine.dialect.DBType() == core.MSSQL && col.SQLType.Name == core.Text { continue