增加支持sql.NullString...Iterate方法。
This commit is contained in:
parent
d716685a9e
commit
916367d81e
12
statement.go
12
statement.go
|
@ -5,6 +5,7 @@
|
||||||
package xorm
|
package xorm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"database/sql/driver"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -49,7 +50,7 @@ type Statement struct {
|
||||||
GroupByStr string
|
GroupByStr string
|
||||||
HavingStr string
|
HavingStr string
|
||||||
ColumnStr string
|
ColumnStr string
|
||||||
selectStr string
|
selectStr string
|
||||||
columnMap map[string]bool
|
columnMap map[string]bool
|
||||||
useAllCols bool
|
useAllCols bool
|
||||||
OmitStr string
|
OmitStr string
|
||||||
|
@ -416,7 +417,7 @@ func buildConditions(engine *Engine, table *core.Table, bean interface{},
|
||||||
|
|
||||||
var colName string
|
var colName string
|
||||||
if addedTableName {
|
if addedTableName {
|
||||||
colName = engine.Quote(tableName)+"."+engine.Quote(col.Name)
|
colName = engine.Quote(tableName) + "." + engine.Quote(col.Name)
|
||||||
} else {
|
} else {
|
||||||
colName = engine.Quote(col.Name)
|
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
|
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))
|
colName, colName))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,6 +510,11 @@ func buildConditions(engine *Engine, table *core.Table, bean interface{},
|
||||||
val = engine.FormatTime(col.SQLType.Name, t)
|
val = engine.FormatTime(col.SQLType.Name, t)
|
||||||
} else if _, ok := reflect.New(fieldType).Interface().(core.Conversion); ok {
|
} else if _, ok := reflect.New(fieldType).Interface().(core.Conversion); ok {
|
||||||
continue
|
continue
|
||||||
|
} else if valNul, ok := fieldValue.Interface().(driver.Valuer); ok {
|
||||||
|
val, _ = valNul.Value()
|
||||||
|
if val == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
engine.autoMapType(fieldValue)
|
engine.autoMapType(fieldValue)
|
||||||
if table, ok := engine.Tables[fieldValue.Type()]; ok {
|
if table, ok := engine.Tables[fieldValue.Type()]; ok {
|
||||||
|
|
Loading…
Reference in New Issue