mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 20:19:57 +00:00
Add db-connect, a SQL over HTTPS server
This commit is contained in:
43
vendor/github.com/kshvakov/clickhouse/lib/column/uint8.go
generated
vendored
Normal file
43
vendor/github.com/kshvakov/clickhouse/lib/column/uint8.go
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
package column
|
||||
|
||||
import (
|
||||
"github.com/kshvakov/clickhouse/lib/binary"
|
||||
)
|
||||
|
||||
type UInt8 struct{ base }
|
||||
|
||||
func (UInt8) Read(decoder *binary.Decoder) (interface{}, error) {
|
||||
v, err := decoder.UInt8()
|
||||
if err != nil {
|
||||
return uint8(0), err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func (u *UInt8) Write(encoder *binary.Encoder, v interface{}) error {
|
||||
switch v := v.(type) {
|
||||
case bool:
|
||||
return encoder.Bool(v)
|
||||
case uint8:
|
||||
return encoder.UInt8(v)
|
||||
case int64:
|
||||
return encoder.UInt8(uint8(v))
|
||||
case int:
|
||||
return encoder.UInt8(uint8(v))
|
||||
|
||||
// this relies on Nullable never sending nil values through
|
||||
case *bool:
|
||||
return encoder.Bool(*v)
|
||||
case *uint8:
|
||||
return encoder.UInt8(*v)
|
||||
case *int64:
|
||||
return encoder.UInt8(uint8(*v))
|
||||
case *int:
|
||||
return encoder.UInt8(uint8(*v))
|
||||
}
|
||||
|
||||
return &ErrUnexpectedType{
|
||||
T: v,
|
||||
Column: u,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user