Skip to content

Commit 47dc55b

Browse files
committed
fix wire protocol conv
1 parent bb52372 commit 47dc55b

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

enginetest/queries/script_queries.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,7 @@ var ScriptTests = []ScriptTest{
133133
Query: `SELECT archived FROM report_card WHERE id = 1
134134
UNION ALL
135135
SELECT 48 FROM report_card WHERE id = 1`,
136-
Expected: []sql.Row{{int64(0)}, {int64(48)}},
137-
// Server engine returns BIT over the wire as []byte/unsigned, so skip result check here
138-
SkipResultCheckOnServerEngine: true,
136+
Expected: []sql.Row{{int64(0)}, {int64(48)}},
139137
},
140138
},
141139
},
@@ -187,7 +185,6 @@ var ScriptTests = []ScriptTest{
187185
{int64(5), int64(1), "Card1", uint64(0), int64(0), int64(2)},
188186
{int64(7), int64(2), "Collection1", uint64(0), nil, int64(2)},
189187
},
190-
SkipResultCheckOnServerEngine: true,
191188
},
192189
},
193190
},

sql/types/bit.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,7 @@ func (t BitType_) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Va
199199
}
200200
bitVal := value.(uint64)
201201

202-
var data []byte
203-
for i := uint64(0); i < uint64(t.numOfBits); i += 8 {
204-
data = append(data, byte(bitVal>>i))
205-
}
206-
for i, j := 0, len(data)-1; i < j; i, j = i+1, j-1 {
207-
data[i], data[j] = data[j], data[i]
208-
}
209-
val := data
210-
211-
return sqltypes.MakeTrusted(sqltypes.Bit, val), nil
202+
return sqltypes.NewUint64(bitVal), nil
212203
}
213204

214205
// String implements Type interface.
@@ -218,7 +209,8 @@ func (t BitType_) String() string {
218209

219210
// Type implements Type interface.
220211
func (t BitType_) Type() query.Type {
221-
return sqltypes.Bit
212+
// Use Uint64 for MySQL driver compatibility
213+
return sqltypes.Uint64
222214
}
223215

224216
// ValueType implements Type interface.

0 commit comments

Comments
 (0)