Fix "specific" match statement exiting early (#4492)

This commit is contained in:
Micha de Vries 2024-08-12 11:05:12 +02:00 committed by GitHub
parent d2c59f0b71
commit f8ba01a688
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -74,7 +74,7 @@ macro_rules! dispatch {
$($wrapper)*(|| $($function_path)::+($($ctx_arg,)* args))()$(.$await)*
},)+
_ => {
return Err($crate::err::Error::InvalidFunction{
Err($crate::err::Error::InvalidFunction{
name: String::from($name),
message: $message.to_string()
})

View file

@ -6237,6 +6237,9 @@ async fn function_idiom_chaining() -> Result<(), Error> {
true.is_bool();
true.doesnt_exist();
field.bla.nested.is_none();
// String is one of the types in the initial match statement,
// this test ensures that the dispatch macro does not exit early
"string".is_bool();
"#;
Test::new(sql)
.await?
@ -6245,6 +6248,7 @@ async fn function_idiom_chaining() -> Result<(), Error> {
.expect_val("false")?
.expect_val("true")?
.expect_error("There was a problem running the doesnt_exist() function. no such method found for the bool type")?
.expect_val("true")?;
.expect_val("true")?
.expect_val("false")?;
Ok(())
}