()
| 216 | |
| 217 | #[test] |
| 218 | fn test_multiple_ctes() { |
| 219 | let conn = setup_test_db(); |
| 220 | |
| 221 | let sql = "WITH |
| 222 | high_value_customers AS ( |
| 223 | SELECT customer_id |
| 224 | FROM orders |
| 225 | GROUP BY customer_id |
| 226 | HAVING SUM(total) > 5000 |
| 227 | ), |
| 228 | customer_discounts AS ( |
| 229 | SELECT c.id, c.discount_rate * 0.01 as discount_decimal |
| 230 | FROM customers c |
| 231 | ) |
| 232 | SELECT |
| 233 | c.name, |
| 234 | cd.discount_decimal |
| 235 | FROM customers c |
| 236 | JOIN high_value_customers hvc ON c.id = hvc.customer_id |
| 237 | JOIN customer_discounts cd ON c.id = cd.id"; |
| 238 | let result = rewrite_query(&conn, sql).unwrap(); |
| 239 | |
| 240 | println!("Multiple CTEs rewritten to: {result}"); |
| 241 | assert!(result.contains("decimal_mul")); |
| 242 | assert!(result.contains("decimal_gt")); |
| 243 | } |
| 244 | |
| 245 | #[test] |
| 246 | fn test_nested_ctes() { |
nothing calls this directly
no test coverage detected