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

Function test_nested_ctes

tests/subquery_cte_test.rs:246–270  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

244
245#[test]
246fn test_nested_ctes() {
247 let conn = setup_test_db();
248
249 let sql = "WITH RECURSIVE
250 order_hierarchy AS (
251 SELECT id, total, 1 as level
252 FROM orders
253 WHERE customer_id = 1
254
255 UNION ALL
256
257 SELECT o.id, o.total + oh.total, oh.level + 1
258 FROM orders o
259 JOIN order_hierarchy oh ON o.customer_id = 1
260 WHERE oh.level < 5
261 )
262 SELECT level, total
263 FROM order_hierarchy";
264 let result = rewrite_query(&conn, sql).unwrap();
265
266 println!("Recursive CTE rewritten to: {result}");
267
268 // Recursive CTEs should still have decimal operations rewritten
269 assert!(result.contains("decimal_add"));
270}
271
272#[test]
273fn test_subquery_in_where_clause() {

Callers

nothing calls this directly

Calls 2

setup_test_dbFunction · 0.70
rewrite_queryFunction · 0.70

Tested by

no test coverage detected