Skip to content

Commit

Permalink
add _bytesToBlr()
Browse files Browse the repository at this point in the history
  • Loading branch information
nakagami committed Aug 26, 2015
1 parent cbe300d commit 4581392
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ func _int32ToBlr(i32 int32) ([]byte, []byte) {
return blr, v
}

func _strToBlr(s string, p *wireProtocol, transHandle int32) ([]byte, []byte) {
v := str_to_bytes(s)
func _bytesToBlr(v []byte, p *wireProtocol, transHandle int32) ([]byte, []byte) {
nbytes := len(v)
pad_length := ((4 - nbytes) & 3)
padding := make([]byte, pad_length)
Expand All @@ -173,6 +172,11 @@ func _strToBlr(s string, p *wireProtocol, transHandle int32) ([]byte, []byte) {
return blr, v
}

func _strToBlr(s string, p *wireProtocol, transHandle int32) ([]byte, []byte) {
v := str_to_bytes(s)
return _bytesToBlr(v, p, transHandle)
}

func _convert_date(t time.Time) []byte {
i := int(t.Month()) + 9
jy := t.Year() + (i / 12) - 1
Expand Down
2 changes: 1 addition & 1 deletion wireprotocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ func (p *wireProtocol) paramsToBlr(transHandle int32, params []driver.Value, pro
v = []byte{}
blr = []byte{14, 0, 0}
case []byte:
blr, v = _strToBlr(string(f), p, transHandle)
blr, v = _bytesToBlr(f, p, transHandle)
default:
// can't convert directory
blr, v = _strToBlr(fmt.Sprintf("%v", f), p, transHandle)
Expand Down

0 comments on commit 4581392

Please sign in to comment.