Skip to content

Commit

Permalink
add support for boolean in ws stmt arguments payload
Browse files Browse the repository at this point in the history
  • Loading branch information
Stenimated authored and haaawk committed Apr 9, 2024
1 parent 8e79a99 commit b3f915f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libsql/internal/ws/websockets.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ func convertValue(v any) (map[string]interface{}, error) {
} else if float, ok := v.(float64); ok {
res["type"] = "float"
res["value"] = float
} else if boolean, ok := v.(bool); ok {
res["type"] = "integer"
if boolean {
res["value"] = "1"
} else {
res["value"] = "0"
}
} else {
return nil, fmt.Errorf("unsupported value type: %s", v)
}
Expand Down
18 changes: 18 additions & 0 deletions libsql/internal/ws/websockets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ func TestConvertValue(t *testing.T) {
},
err: nil,
},
{
name: "boolean_true",
value: true,
want: map[string]any{
"type": "integer",
"value": "1",
},
err: nil,
},
{
name: "boolean_false",
value: false,
want: map[string]any{
"type": "integer",
"value": "0",
},
err: nil,
},
{
name: "unsupported",
value: struct{}{},
Expand Down

0 comments on commit b3f915f

Please sign in to comment.