Skip to content

Commit

Permalink
CheckNamedValue: minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kshvakov committed Aug 30, 2017
1 parent 9dffd58 commit 0c1ee71
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,20 @@ func (ch *clickhouse) Rollback() error {

func (ch *clickhouse) CheckNamedValue(nv *driver.NamedValue) error {
switch v := nv.Value.(type) {
case IP, *types.Array, UUID:
return nil
case int8, int16, int32, int64, uint8, uint16, uint32, uint64, float32, float64, string, time.Time:
return nil
case
[]int, []int8, []int16, []int32, []int64,
[]uint, []uint8, []uint16, []uint32, []uint64,
[]float32, []float64,
[]string:
nv.Value = types.NewArray(v)
case Date:
nv.Value = v.convert()
case DateTime:
nv.Value = v.convert()
case IP, *types.Array, UUID:
nv.Value = v
case net.IP:
nv.Value = IP(v)
default:
Expand Down Expand Up @@ -200,8 +208,6 @@ func (ch *clickhouse) CheckNamedValue(nv *driver.NamedValue) error {
nv.Value = float64(value.Float())
case reflect.String:
nv.Value = value.String()
case reflect.Slice:
nv.Value = types.NewArray(value.Interface())
}
}
return nil
Expand Down

0 comments on commit 0c1ee71

Please sign in to comment.