Closed oleggator closed 2 years ago
The schema parsing logic relies on the fact that index field description is always an array. But it may also be a map. This PR fixes that.
Example:
box.cfg { listen = 3301 } box.schema.user.grant('guest', 'super', nil, nil, { if_not_exists = true }) local space = box.schema.create_space('some_space', { if_not_exists = true }) local index = space:create_index('primary', { if_not_exists = true, parts = { { field = 1, type = 'string', is_nullable = false }, }, }) local format = box.space[289]:select { space.id, index.id } print(require('yaml').encode(format))
package main import ( "github.com/viciious/go-tarantool" "log" ) func main() { _, err := tarantool.Connect("guest@localhost:3301", &tarantool.Options{}) if err != nil { log.Fatalln(err) } }
This code will cause such error:
panic: interface conversion: interface {} is map[string]interface {}, not []interface {} goroutine 1 [running]: github.com/viciious/go-tarantool.(*Connection).pullSchema(0xc000120000) /Users/o.utkin/go/pkg/mod/github.com/viciious/go-tarantool@v0.0.0-20220525112527-ba97bae22168/connection.go:382 +0x50e github.com/viciious/go-tarantool.connect({0x121fcd8?, 0xc0000c8008?}, {0xc0000dc120?, 0x0?}, {0xc0000dc12c?, 0x5?}, {0x3b9aca00, 0x3b9aca00, {0x0, 0x0}, ...}) /Users/o.utkin/go/pkg/mod/github.com/viciious/go-tarantool@v0.0.0-20220525112527-ba97bae22168/connection.go:100 +0xe5 github.com/viciious/go-tarantool.ConnectContext({0x121fcd8, 0xc0000c8008}, {0x11ca4b5?, 0x10403f1?}, 0xc0ffffffff?) /Users/o.utkin/go/pkg/mod/github.com/viciious/go-tarantool@v0.0.0-20220525112527-ba97bae22168/connection.go:82 +0x20e github.com/viciious/go-tarantool.Connect(...) /Users/o.utkin/go/pkg/mod/github.com/viciious/go-tarantool@v0.0.0-20220525112527-ba97bae22168/connection.go:87 main.main() /xxx/cmd/replicationinfo/main.go:9 +0x77
Thanks a lot! Do you mind adding a test case for this?
Done.
Thanks!
The schema parsing logic relies on the fact that index field description is always an array. But it may also be a map. This PR fixes that.
Example:
This code will cause such error: