Replace parallel condition/result vectors with single CaseWhen vector in Expr::Case (#1733)

This commit is contained in:
Ophir LOJKINE 2025-02-22 07:23:36 +01:00 committed by GitHub
parent 7fc37a76e5
commit 72312ba82a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 160 additions and 50 deletions

View file

@ -2065,11 +2065,11 @@ impl<'a> Parser<'a> {
self.expect_keyword_is(Keyword::WHEN)?;
}
let mut conditions = vec![];
let mut results = vec![];
loop {
conditions.push(self.parse_expr()?);
let condition = self.parse_expr()?;
self.expect_keyword_is(Keyword::THEN)?;
results.push(self.parse_expr()?);
let result = self.parse_expr()?;
conditions.push(CaseWhen { condition, result });
if !self.parse_keyword(Keyword::WHEN) {
break;
}
@ -2083,7 +2083,6 @@ impl<'a> Parser<'a> {
Ok(Expr::Case {
operand,
conditions,
results,
else_result,
})
}