MCPcopy Create free account
hub / github.com/erans/pgsqlite / test_cte_with_arithmetic_operations

Function test_cte_with_arithmetic_operations

tests/subquery_cte_test.rs:193–215  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

191
192#[test]
193fn 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]
218fn test_multiple_ctes() {

Callers

nothing calls this directly

Calls 2

setup_test_dbFunction · 0.70
rewrite_queryFunction · 0.70

Tested by

no test coverage detected