Skip to content

Commit 53660c4

Browse files
committed
working test
1 parent a7ca32b commit 53660c4

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

server/functions/bit.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ var bitout = framework.Function1{
6666
Parameters: [1]*pgtypes.DoltgresType{pgtypes.Bit},
6767
Strict: true,
6868
Callable: func(ctx *sql.Context, t [2]*pgtypes.DoltgresType, val any) (any, error) {
69-
bitStr := val.(tree.DBitArray)
70-
return bitStr.String(), nil
69+
bitStr := val.(*tree.DBitArray)
70+
return tree.AsStringWithFlags(bitStr, tree.FmtPgwireText), nil
7171
},
7272
}
7373

@@ -94,8 +94,11 @@ var bitsend = framework.Function1{
9494
Parameters: [1]*pgtypes.DoltgresType{pgtypes.Bit},
9595
Strict: true,
9696
Callable: func(ctx *sql.Context, _ [2]*pgtypes.DoltgresType, val any) (any, error) {
97-
bitStr := val.(tree.DBitArray)
98-
return bitStr.String(), nil
97+
bitStr := val.(*tree.DBitArray)
98+
str := tree.AsStringWithFlags(bitStr, tree.FmtPgwireText)
99+
wr := utils.NewWriter(uint64(4 + len(str)))
100+
wr.String(str)
101+
return wr.Data(), nil
99102
},
100103
}
101104

testing/go/types_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"testing"
1919

2020
"github.com/dolthub/go-mysql-server/sql"
21+
"github.com/jackc/pgx/v5/pgtype"
2122
)
2223

2324
func TestTypes(t *testing.T) {
@@ -88,8 +89,8 @@ var typesTests = []ScriptTest{
8889
{
8990
Query: "SELECT * FROM t_bit ORDER BY id;",
9091
Expected: []sql.Row{
91-
{1, []byte{0xDA}},
92-
{2, []byte{0x2B}},
92+
{1, pgtype.Bits{Bytes: []uint8{0xda}, Len: 8, Valid: true}},
93+
{2, pgtype.Bits{Bytes: []uint8{0x2b}, Len: 8, Valid: true}},
9394
},
9495
},
9596
},
@@ -3008,8 +3009,8 @@ var typesTests = []ScriptTest{
30083009
"create table t_uuid2 (id int primary key, v1 uuid, v2 uuid);",
30093010
"create index on t_uuid2(v1, v2);",
30103011
"insert into t_uuid2 values " +
3011-
"(1, 'f47ac10b58cc4372a567-0e02b2c3d479', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'), " +
3012-
"(2, 'dcf783c8-49c2-44b4-8b90-34ad8c52ea1e', 'f99802e8-0018-4913-806c-bcad5d246d46');",
3012+
"(1, 'f47ac10b58cc4372a567-0e02b2c3d479', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'), " +
3013+
"(2, 'dcf783c8-49c2-44b4-8b90-34ad8c52ea1e', 'f99802e8-0018-4913-806c-bcad5d246d46');",
30133014
},
30143015
Assertions: []ScriptTestAssertion{
30153016
{

0 commit comments

Comments
 (0)