Skip to content

Commit

Permalink
enh: support websocket stmt query
Browse files Browse the repository at this point in the history
  • Loading branch information
huskar-t committed Jan 5, 2024
1 parent 9dd19ef commit c71fda8
Show file tree
Hide file tree
Showing 9 changed files with 3,130 additions and 9 deletions.
4 changes: 4 additions & 0 deletions common/param/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ func NewColumnType(size int) *ColumnType {
return &ColumnType{size: size, value: make([]*types.ColumnType, size)}
}

func NewColumnTypeWithValue(value []*types.ColumnType) *ColumnType {
return &ColumnType{size: len(value), value: value, column: len(value)}
}

func (c *ColumnType) AddBool() *ColumnType {
if c.column >= c.size {
return c
Expand Down
9 changes: 9 additions & 0 deletions common/param/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ func NewParam(size int) *Param {
}
}

func NewParamsWithRowValue(value []driver.Value) []*Param {
params := make([]*Param, len(value))
for i, d := range value {
params[i] = NewParam(1)
params[i].AddValue(d)
}
return params
}

func (p *Param) SetBool(offset int, value bool) {
if offset >= p.size {
return
Expand Down
4 changes: 2 additions & 2 deletions common/serializer/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func BMSetNull(c byte, n int) byte {
return c + (1 << (7 - BitPos(n)))
}

var ColumnNumerNotMatch = errors.New("number of columns does not match")
var ColumnNumberNotMatch = errors.New("number of columns does not match")
var DataTypeWrong = errors.New("wrong data type")

func SerializeRawBlock(params []*param.Param, colType *param.ColumnType) ([]byte, error) {
Expand All @@ -48,7 +48,7 @@ func SerializeRawBlock(params []*param.Param, colType *param.ColumnType) ([]byte
return nil, err
}
if len(colTypes) != columns {
return nil, ColumnNumerNotMatch
return nil, ColumnNumberNotMatch
}
var block []byte
//version int32
Expand Down
6 changes: 3 additions & 3 deletions taosSql/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ func (stmt *Stmt) CheckNamedValue(v *driver.NamedValue) error {
case reflect.Bool:
v.Value = types.TaosBool(rv.Bool())
case reflect.Float32, reflect.Float64:
v.Value = types.TaosBool(rv.Float() == 1)
v.Value = types.TaosBool(rv.Float() > 0)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
v.Value = types.TaosBool(rv.Int() == 1)
v.Value = types.TaosBool(rv.Int() > 0)
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
v.Value = types.TaosBool(rv.Uint() == 1)
v.Value = types.TaosBool(rv.Uint() > 0)
case reflect.String:
vv, err := strconv.ParseBool(rv.String())
if err != nil {
Expand Down
Loading

0 comments on commit c71fda8

Please sign in to comment.