增加支持sql.NullString...Iterate方法。

This commit is contained in:
haolei 2015-07-20 11:23:29 +08:00
parent d716685a9e
commit 916367d81e
1 changed files with 9 additions and 3 deletions

View File

@ -5,6 +5,7 @@
package xorm
import (
"database/sql/driver"
"encoding/json"
"errors"
"fmt"
@ -49,7 +50,7 @@ type Statement struct {
GroupByStr string
HavingStr string
ColumnStr string
selectStr string
selectStr string
columnMap map[string]bool
useAllCols bool
OmitStr string
@ -416,7 +417,7 @@ func buildConditions(engine *Engine, table *core.Table, bean interface{},
var colName string
if addedTableName {
colName = engine.Quote(tableName)+"."+engine.Quote(col.Name)
colName = engine.Quote(tableName) + "." + engine.Quote(col.Name)
} else {
colName = engine.Quote(col.Name)
}
@ -509,6 +510,11 @@ func buildConditions(engine *Engine, table *core.Table, bean interface{},
val = engine.FormatTime(col.SQLType.Name, t)
} else if _, ok := reflect.New(fieldType).Interface().(core.Conversion); ok {
continue
} else if valNul, ok := fieldValue.Interface().(driver.Valuer); ok {
val, _ = valNul.Value()
if val == nil {
continue
}
} else {
engine.autoMapType(fieldValue)
if table, ok := engine.Tables[fieldValue.Type()]; ok {