code tidy up for Type2SQLType and buildConditions
This commit is contained in:
parent
0c9b7b274f
commit
68862870a9
11
statement.go
11
statement.go
|
@ -348,8 +348,17 @@ func buildConditions(engine *Engine, table *Table, bean interface{}, includeVers
|
|||
if fieldValue.IsNil() || !fieldValue.IsValid() {
|
||||
continue
|
||||
} else {
|
||||
// TODO need to filter support types
|
||||
typeStr := fieldType.String()
|
||||
switch typeStr {
|
||||
case "*string", "*bool", "*float32", "*float64", "*int64", "*uint64", "*int", "*int16", "*int32 ", "*int8 ", "*uint", "*uint16", "*uint32", "*uint8":
|
||||
val = fieldValue.Elem()
|
||||
case "*complex64", "*complex128":
|
||||
continue // TODO
|
||||
case "*time.Time":
|
||||
continue // TODO
|
||||
default:
|
||||
continue // TODO
|
||||
}
|
||||
}
|
||||
default:
|
||||
val = fieldValue.Interface()
|
||||
|
|
20
table.go
20
table.go
|
@ -157,23 +157,25 @@ func Type2SQLType(t reflect.Type) (st SQLType) {
|
|||
func ptrType2SQLType(t reflect.Type) (st SQLType, has bool) {
|
||||
typeStr := t.String()
|
||||
has = true
|
||||
if typeStr == "*string" {
|
||||
|
||||
switch typeStr {
|
||||
case "*string":
|
||||
st = SQLType{Varchar, 255, 0}
|
||||
} else if typeStr == "*bool" {
|
||||
case "*bool":
|
||||
st = SQLType{Bool, 0, 0}
|
||||
} else if typeStr == "*complex64" || typeStr == "*complex128" {
|
||||
case "*complex64", "*complex128":
|
||||
st = SQLType{Varchar, 64, 0}
|
||||
} else if typeStr == "*float32" {
|
||||
case "*float32":
|
||||
st = SQLType{Float, 0, 0}
|
||||
} else if typeStr == "*float64" {
|
||||
case "*float64":
|
||||
st = SQLType{Varchar, 64, 0}
|
||||
} else if typeStr == "*int64" || typeStr == "*uint64" {
|
||||
case "*int64", "*uint64":
|
||||
st = SQLType{BigInt, 0, 0}
|
||||
} else if typeStr == "*time.Time" {
|
||||
case "*time.Time":
|
||||
st = SQLType{DateTime, 0, 0}
|
||||
} else if intTypes.Search(typeStr) < len(intTypes) || uintTypes.Search(typeStr) < len(uintTypes) {
|
||||
case "*int", "*int16", "*int32", "*int8", "*uint", "*uint16", "*uint32", "*uint8":
|
||||
st = SQLType{Int, 0, 0}
|
||||
} else {
|
||||
default:
|
||||
has = false
|
||||
}
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue