Skip to content

Commit

Permalink
Move deref up, alphabetize members
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhghomon committed Dec 11, 2023
1 parent 0e2e3cf commit 56fe4a4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions edgedb-protocol/src/query_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,18 @@ impl QueryArg for Value {
(Str(_), BaseScalar(d)) if d.id == codec::STD_STR => Ok(()),
(Uuid(_), BaseScalar(d)) if d.id == codec::STD_UUID => Ok(()),
(Enum(val), Enumeration(EnumerationTypeDescriptor { members, .. })) => {
if members.iter().any(|c| c == val.deref()) {
let val = val.deref();
if members.iter().any(|c| c == val) {
Ok(())
} else {
let members = members
let members = {
let mut members = members
.into_iter()
.map(|c| format!("'{c}'"))
.collect::<Vec<_>>()
.join(", ");
let val = val.to_string();
.collect::<Vec<_>>();
members.sort_unstable();
members.join(", ")
};
Err(InvalidReferenceError::with_message(format!(
"Expected one of: {members}, while enum value '{val}' was provided"
)))
Expand Down

0 comments on commit 56fe4a4

Please sign in to comment.