()
| 191 | |
| 192 | #[test] |
| 193 | fn test_cte_with_arithmetic_operations() { |
| 194 | let conn = setup_test_db(); |
| 195 | |
| 196 | let sql = "WITH customer_metrics AS ( |
| 197 | SELECT |
| 198 | customer_id, |
| 199 | SUM(total) as total_amount, |
| 200 | SUM(tax) as total_tax, |
| 201 | SUM(total + tax) as total_with_tax |
| 202 | FROM orders |
| 203 | GROUP BY customer_id |
| 204 | ) |
| 205 | SELECT |
| 206 | c.name, |
| 207 | cm.total_with_tax / cm.total_amount as tax_ratio |
| 208 | FROM customers c |
| 209 | JOIN customer_metrics cm ON c.id = cm.customer_id"; |
| 210 | let result = rewrite_query(&conn, sql).unwrap(); |
| 211 | |
| 212 | println!("CTE with arithmetic rewritten to: {result}"); |
| 213 | assert!(result.contains("decimal_add")); |
| 214 | assert!(result.contains("decimal_div")); |
| 215 | } |
| 216 | |
| 217 | #[test] |
| 218 | fn test_multiple_ctes() { |
nothing calls this directly
no test coverage detected