diff --git a/edgedb-protocol/src/value_opt.rs b/edgedb-protocol/src/value_opt.rs index 1df03cf9..5e0ce1be 100644 --- a/edgedb-protocol/src/value_opt.rs +++ b/edgedb-protocol/src/value_opt.rs @@ -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 diff --git a/edgedb-tokio/tests/func/client.rs b/edgedb-tokio/tests/func/client.rs index c2c3ee6f..3f03993b 100644 --- a/edgedb-tokio/tests/func/client.rs +++ b/edgedb-tokio/tests/func/client.rs @@ -82,6 +82,8 @@ async fn simple() -> anyhow::Result<()> { ++ ($question ?? ' the ultimate question of life') ++ ': ' ++ $answer + ++ ' and not ' + ++ $not_an_answer );", &named_args! { "msg1" => vec!["the".to_string(), "answer".to_string(), "to".to_string()], @@ -147,7 +149,7 @@ async fn json() -> anyhow::Result<()> { pub phone: String, pub otp: i32, } - + let res = client.query::( "select (select test::OtpPhoneRequest { phone, otp } filter .phone = '0123456789')", &()