Parse calls to trim(), which can take the form: - trim(side 'chars' from 'string') - trim('chars' from 'string') - trim(side from 'string') - trim(from 'string') - trim('string') - trim(side 'string')
(&mut self)
| 1108 | // - trim('string') |
| 1109 | // - trim(side 'string') |
| 1110 | fn parse_trim_expr(&mut self) -> Result<Expr<Raw>, ParserError> { |
| 1111 | self.expect_token(&Token::LParen)?; |
| 1112 | let name = match self.parse_one_of_keywords(&[BOTH, LEADING, TRAILING]) { |
| 1113 | None | Some(BOTH) => ident!("btrim"), |
| 1114 | Some(LEADING) => ident!("ltrim"), |
| 1115 | Some(TRAILING) => ident!("rtrim"), |
| 1116 | _ => unreachable!(), |
| 1117 | }; |
| 1118 | let mut exprs = Vec::new(); |
| 1119 | if self.parse_keyword(FROM) { |
| 1120 | // 'string' |
| 1121 | exprs.push(self.parse_expr()?); |
| 1122 | } else { |
| 1123 | // Either 'chars' or 'string' |
| 1124 | exprs.push(self.parse_expr()?); |
| 1125 | if self.parse_keyword(FROM) { |
| 1126 | // 'string'; previous must be 'chars' |
| 1127 | // Swap 'chars' and 'string' for compatibility with btrim, ltrim, and rtrim. |
| 1128 | exprs.insert(0, self.parse_expr()?); |
| 1129 | } |
| 1130 | } |
| 1131 | self.expect_token(&Token::RParen)?; |
| 1132 | Ok(Expr::Function(Function { |
| 1133 | name: RawItemName::Name(UnresolvedItemName::unqualified(name)), |
| 1134 | args: FunctionArgs::args(exprs), |
| 1135 | filter: None, |
| 1136 | over: None, |
| 1137 | distinct: false, |
| 1138 | })) |
| 1139 | } |
| 1140 | |
| 1141 | // Parse calls to position(), which has the special form position('string' in 'string'). |
| 1142 | fn parse_position_expr(&mut self) -> Result<Expr<Raw>, ParserError> { |
no test coverage detected