`Queryable` not implemented for `Value`
It seems, the Queryable trait isn't implemented for edgedb_protocol::value::Value.
Value would be quite valuable for debugging, logging, and so on.
Unfortunately it's not possible in the way trait is defined now. You can query a Value because query* methods are defined in terms of QueryResult trait instead of queryable, although that only works for top level result.
Do you need to put Value somewhere inside other derived Queryable?
Do you need to put Value somewhere inside other derived Queryable?
Yes, I was trying to return (Vec<Value>, Vec<Value>, Vec<Value>) from EdgeDb. The Values represent different kinds of errors, that I only wanted to print to the terminal (so I wanted to avoid implementing structs for them).
After that didn't work, I just returned one Value, but ergonomics were so bad, that I changed my mind and implemented structs that derive Queryable, which is probably better anyway (and wasn't that that bad, in regard to ergonomics).
Another solution, I just realized, could have been to convert my error objects to JSON strings, and return that from EdgeDB.
Feel free to close the issue, if you don't plan to change the current implementation of the trait.
I think this issue can stay for the reference. Because I'm still not sure what the best way to handle this.
The core issue here is that:
- To unpack
Valuewe need to know structure of the value that is encoded in descriptors and then decoded intoCodecs. - When we do statically typed unpacking we don't create a tree of
Codecsand don't propagate it through the decoder code soQueryableis potentially faster way to decode data. - And then there is
QueryResulttrait that handles codecs optionally.
Maybe Queryable can implement two modes, or maybe the overhead is not significant. Or maybe there are other solutions.