-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cant GetTyped if one of tarantool response keys is non-string typed #368
Comments
Please give an example of the code in which you decode the response with Ideally I would like to see a minimal reproducer. Now it’s not entirely clear to me what’s not working for you. |
I got it. You need to write a custom decoder for this cases, as example: type testReproducer368 struct {
Value int
Foo string
}
func (t *testReproducer368) DecodeMsgpack(d *msgpack.Decoder) error {
var (
err error
l int
)
if l, err = d.DecodeMapLen(); err != nil {
return err
}
for i := 0; i < l; i++ {
key, err := d.DecodeInterface()
if err != nil {
return err
}
value, err := d.DecodeInterface()
if err != nil {
return err
}
switch key {
case int8(34):
t.Value = int(value.(int8))
case "foo":
t.Foo = value.(string)
}
}
return nil
}
func TestReproducer368(t *testing.T) {
conn := test_helpers.ConnectWithValidation(t, dialer, opts)
defer conn.Close()
test := []testReproducer368{}
err := conn.Do(NewEvalRequest("return {[34] = 2, foo = 'bar'}")).GetTyped(&test)
require.NoError(t, err)
require.Equal(t, []testReproducer368{testReproducer368{2, "bar"}}, test)
} You could see examples of the custom decoders in the connector code or in the |
The reason in the |
msgpack: invalid code=1 decoding string/bytes length
https://github.com/vmihailenco/msgpack/blob/19c91dfdfa062658c39d9321be26163fc5833bd1/decode_string.go#L31
The text was updated successfully, but these errors were encountered: