(&self, args: &[Expr])
| 779 | } |
| 780 | |
| 781 | fn map_to_sql(&self, args: &[Expr]) -> Result<ast::Expr> { |
| 782 | assert_eq_or_internal_err!(args.len(), 2, "map must have exactly 2 arguments"); |
| 783 | |
| 784 | let ast::Expr::Array(Array { elem: keys, .. }) = self.expr_to_sql(&args[0])? |
| 785 | else { |
| 786 | return internal_err!( |
| 787 | "map expects first argument to be an array, but received: {:?}", |
| 788 | &args[0] |
| 789 | ); |
| 790 | }; |
| 791 | |
| 792 | let ast::Expr::Array(Array { elem: values, .. }) = self.expr_to_sql(&args[1])? |
| 793 | else { |
| 794 | return internal_err!( |
| 795 | "map expects second argument to be an array, but received: {:?}", |
| 796 | &args[1] |
| 797 | ); |
| 798 | }; |
| 799 | |
| 800 | let entries = keys |
| 801 | .into_iter() |
| 802 | .zip(values) |
| 803 | .map(|(key, value)| ast::MapEntry { |
| 804 | key: Box::new(key), |
| 805 | value: Box::new(value), |
| 806 | }) |
| 807 | .collect(); |
| 808 | |
| 809 | Ok(ast::Expr::Map(ast::Map { entries })) |
| 810 | } |
| 811 | |
| 812 | pub fn sort_to_sql(&self, sort: &Sort) -> Result<ast::OrderByExpr> { |
| 813 | let Sort { |
no test coverage detected