Skip to content

Commit

Permalink
fix: encode missing entry as None + test
Browse files Browse the repository at this point in the history
  • Loading branch information
MrFoxPro committed Apr 22, 2024
1 parent 4d929c7 commit a82daa2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions edgedb-protocol/src/value_opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ impl QueryArgs for HashMap<&str, ValueOpt> {
let value = self.get(param_descriptor.name.as_str());

let Some(value) = value else {
if param_descriptor.cardinality.is_some_and(|cardinality| cardinality.is_optional()) {
shape_elements.push(ShapeElement::from(param_descriptor));
fields.push(None);
continue;
}
return Err(ClientEncodingError::with_message(format!(
"argument for ${} missing",
param_descriptor.name
Expand Down
4 changes: 3 additions & 1 deletion edgedb-tokio/tests/func/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ async fn simple() -> anyhow::Result<()> {
++ (<optional str>$question ?? ' the ultimate question of life')
++ ': '
++ <str><int64>$answer
++ ' and not '
++ <optional str>$not_an_answer
);",
&named_args! {
"msg1" => vec!["the".to_string(), "answer".to_string(), "to".to_string()],
Expand Down Expand Up @@ -147,7 +149,7 @@ async fn json() -> anyhow::Result<()> {
pub phone: String,
pub otp: i32,
}

let res = client.query::<OtpPhoneRequest, _>(
"select <json>(select test::OtpPhoneRequest { phone, otp } filter .phone = '0123456789')",
&()
Expand Down

0 comments on commit a82daa2

Please sign in to comment.