You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cbor: cannot unmarshal array into Go struct field
connection.RPCResponse[[]github.com/surrealdb/surrealdb%2ego.QueryResult[github.com/surrealdb/surrealdb%2ego.Result[[]olive/models.AttributeResponse]]].result of
type surrealdb.Result[[]olive/models.AttributeResponse] (cannot decode CBOR array to struct without toarray option)
results, err:=surrealdb.Query[[]AttributeResponse](db.DB, query, nil)
ifresults==nil {
// handle this to prevent panics
}
attributeResponses, err:= (*results)[0] // there was only one query, so this should eixst
More specifically, the TResult of the .Query (between the []) should be an array.
That does result in some ugly parsing/validating/error-checking code, so I wouldn't be surprised if this changed again in a future update.
Why is the SurrealDB team silent on this? It's a crucial issue. In real life scenario there would be many such cases like mine where nested structure is having more than 2 levels.
Describe the bug
When I try to call the
Query
method as below:I am getting the following error:
Steps to reproduce
Mentioned above
Expected behaviour
Nested struct should be supported
SurrealDB version
surreal 2.0.4, surrealdb.go 0.3.0, windows 11
Contact Details
[email protected]
Is there an existing issue for this?
Code of Conduct
The text was updated successfully, but these errors were encountered: