Convert expression to string for default column naming
(&self, expr: &Expression)
| 5571 | |
| 5572 | /// Convert expression to string for default column naming |
| 5573 | fn expression_to_string(&self, expr: &Expression) -> String { |
| 5574 | match expr { |
| 5575 | Expression::PropertyAccess(prop) => format!("{}.{}", prop.object, prop.property), |
| 5576 | Expression::Variable(var) => var.name.clone(), |
| 5577 | Expression::FunctionCall(func) => { |
| 5578 | if func.arguments.is_empty() { |
| 5579 | format!("{}()", func.name) |
| 5580 | } else { |
| 5581 | format!("{}(...)", func.name) |
| 5582 | } |
| 5583 | } |
| 5584 | Expression::Binary(binary) => { |
| 5585 | format!( |
| 5586 | "{}_{}_{}", |
| 5587 | self.expression_to_string(&binary.left), |
| 5588 | match &binary.operator { |
| 5589 | crate::ast::Operator::Plus => "plus", |
| 5590 | crate::ast::Operator::Minus => "minus", |
| 5591 | crate::ast::Operator::Star => "times", |
| 5592 | crate::ast::Operator::Slash => "div", |
| 5593 | crate::ast::Operator::Percent => "mod", |
| 5594 | crate::ast::Operator::And => "and", |
| 5595 | crate::ast::Operator::Or => "or", |
| 5596 | crate::ast::Operator::Xor => "xor", |
| 5597 | _ => "op", |
| 5598 | }, |
| 5599 | self.expression_to_string(&binary.right) |
| 5600 | ) |
| 5601 | } |
| 5602 | Expression::Literal(_) => "literal".to_string(), |
| 5603 | _ => "expression".to_string(), |
| 5604 | } |
| 5605 | } |
| 5606 | |
| 5607 | /// Evaluate a function call expression |
| 5608 | fn evaluate_function_call( |
no test coverage detected