Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Was surprised today to see that a simple query like the following doesn't work:
Schema:
module default { scalar type Country extending enum<Full, ReadOnly, None>; }
Rust:
The error is that it expected an enum, and got an...Enumeration.
called `Result::unwrap()` on an `Err` value: Error(Inner { code: 4278386176, messages: ["\nEdgeDB returned unexpected type Enumeration(EnumerationTypeDescriptor { id: 16e1e80c-94fe-11ee-96e2-dd6c21ea77c9, members: [\"Full\", \"ReadOnly\", \"None\"] })\nClient expected enum"], error: None, headers: {}, fields: {("descriptor", TypeId { t: 116367074156074466779343831034874852404 }): Any { .. }, ("capabilities", TypeId { t: 264000494568981768888535343960226937934 }): Any { .. }} })
Turns out that it's just that check_descriptor() simply isn't complete yet. A check to make sure that the value is found inside the
members
(which holds the possible enum values) should do the trick while the cast in the query itself (in this case a<Country>
).After that the error when an incorrect enum value was passed in was still the above, so changed it to output an
InvalidReferenceError
(that's what the REPL gives in the same case) with some context so now it looks like this:called `Result::unwrap()` on an `Err` value: Error(Inner { code: 67305472, messages: ["Expected one of: 'Full', 'ReadOnly', 'None', while enum value 'RRRRRRRRRRRRRRRRRReadOnly' was provided"], error: None, headers: {}, fields: {("descriptor", TypeId { t: 254184924864600833047165177448722979326 }): Any { .. }, ("capabilities", TypeId { t: 267257778208590603416093306289546576982 }): Any { .. }} })