-
Notifications
You must be signed in to change notification settings - Fork 60
example for connection.GetTyped() and a tuple with slice/array members #196
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
Comments
Update for others who might be having similar issues: Since I'm just storing a Secondly, while I didn't find it in any of the examples, I did realize that |
Thank you for highlighting the problem. We probably need to add examples for A quick example for the issue (just an example, we need to find an elegant solution): diff --git a/config.lua b/config.lua
index abea457..cedd60d 100644
--- a/config.lua
+++ b/config.lua
@@ -11,6 +11,12 @@ box.once("init", function()
})
s:create_index('primary', {type = 'tree', parts = {1, 'uint'}, if_not_exists = true})
+ local s = box.schema.space.create('test_string_byte', {
+ id = 667,
+ if_not_exists = true,
+ })
+ s:create_index('primary', {type = 'tree', parts = {1, 'string'}, if_not_exists = true})
+
local sp = box.schema.space.create('SQL_TEST', {
id = 519,
if_not_exists = true,
diff --git a/example_test.go b/example_test.go
index cd4c787..5d7d552 100644
--- a/example_test.go
+++ b/example_test.go
@@ -18,6 +18,32 @@ type Tuple struct {
Name string
}
+type TupleStringByte struct {
+ Key string
+ Value []byte
+}
+
+func ExampleStringKey() {
+ conn := example_connect()
+ defer conn.Close()
+
+ _, err := conn.Replace("test_string_byte", []interface{}{"asd", []byte{0x01, 0x02, 0x03, 0x04, 0x00, 0x00}})
+ if err != nil {
+ fmt.Printf("error in replace is %v", err)
+ return
+ }
+
+ var res []TupleStringByte
+ err = conn.SelectTyped("test_string_byte", 0, 0, 100, tarantool.IterEq, tarantool.StringKey{"asd"}, &res)
+ if err != nil {
+ fmt.Printf("error in select is %v", err)
+ return
+ }
+ fmt.Printf("response is %#v\n", res)
+ // Output:
+ // response is []tarantool_test.TupleByte{tarantool_test.TupleByte{Key:"asd", Value:[]uint8{0x1, 0x2, 0x3, 0x4, 0x0, 0x0}}}
+}
+
func example_connect() *tarantool.Connection {
conn, err := tarantool.Connect(server, opts)
if err != nil { |
The patch adds examples for: * Connection.GetTyped() method * IntKey type * UintKey type * StringKey type * IntIntKey type Closes #196
The patch adds examples for: * Connection.GetTyped() method * IntKey type * UintKey type * StringKey type * IntIntKey type Closes #196
The patch adds examples for: * Connection.GetTyped() method * IntKey type * UintKey type * StringKey type * IntIntKey type Closes #196
The patch adds examples for: * Connection.GetTyped() method * IntKey type * UintKey type * StringKey type * IntIntKey type Closes #196
So far I've been unable to work out how to implement MsgPack decoder for the simple tuple:
and the examples don't really show how to do this. no matter what I try, I'm met with
ER_INVALID_MSGPACK: Invalid MsgPack - packet body
Can someone point me in the right direction?
The text was updated successfully, but these errors were encountered: