增加支持sql.NullString...Iterate方法。
This commit is contained in:
parent
d716685a9e
commit
916367d81e
12
statement.go
12
statement.go
|
@ -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)
|
||||
}
|
||||
|
@ -428,7 +429,7 @@ func buildConditions(engine *Engine, table *core.Table, bean interface{},
|
|||
}
|
||||
|
||||
if col.IsDeleted && !unscoped { // tag "deleted" is enabled
|
||||
colNames = append(colNames, fmt.Sprintf("(%v IS NULL or %v = '0001-01-01 00:00:00')",
|
||||
colNames = append(colNames, fmt.Sprintf("(%v IS NULL or %v = '0001-01-01 00:00:00')",
|
||||
colName, colName))
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue