(&mut self, expr: &Expr<Aug>)
| 447 | } |
| 448 | |
| 449 | fn rewrite_expr(&mut self, expr: &Expr<Aug>) -> Option<(Ident, Expr<Aug>)> { |
| 450 | match expr { |
| 451 | Expr::Function(function) => self.rewrite_function(function), |
| 452 | // Rewrites special keywords that SQL considers to be function calls |
| 453 | // to actual function calls. For example, `SELECT current_timestamp` |
| 454 | // is rewritten to `SELECT current_timestamp()`. |
| 455 | Expr::Identifier(ident) if ident.len() == 1 => { |
| 456 | let ident = normalize::ident(ident[0].clone()); |
| 457 | let fn_ident = match ident.as_str() { |
| 458 | "current_role" => Some("current_user"), |
| 459 | "current_schema" | "current_timestamp" | "current_user" | "session_user" |
| 460 | | "current_catalog" => Some(ident.as_str()), |
| 461 | _ => None, |
| 462 | }; |
| 463 | match fn_ident { |
| 464 | None => None, |
| 465 | Some(fn_ident) => { |
| 466 | let expr = Expr::call_nullary( |
| 467 | self.scx |
| 468 | .dangerous_resolve_name(vec![PG_CATALOG_SCHEMA, fn_ident]), |
| 469 | ); |
| 470 | Some((Ident::new_unchecked(ident), expr)) |
| 471 | } |
| 472 | } |
| 473 | } |
| 474 | _ => None, |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | impl<'ast> VisitMut<'ast, Aug> for FuncRewriter<'_> { |
no test coverage detected