MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / test_with_and_next_composition

Function test_with_and_next_composition

graphlite/tests/pattern_tests.rs:811–1062  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

809 Remove #[ignore] to test WITH patterns (Pattern 1 should work). \
810 NEXT patterns (Pattern 2 & 3) may fail if NEXT not yet implemented."]
811fn test_with_and_next_composition() {
812 let fixture = TestFixture::with_fraud_data().expect("Failed to create test fixture");
813
814 log::debug!("\n=== Testing WITH and NEXT Clause Composition ===\n");
815
816 // Test 1: WITH clause chaining (intra-query transformation)
817 // This tests MATCH -> WITH -> MATCH -> RETURN pattern
818 log::debug!("Test 1: WITH clause chaining (intra-query)");
819 let with_chain_query = "
820 MATCH (a:Account)-[t:Transaction]->(m:Merchant)
821 WITH a, m, count(t) as transaction_count, sum(t.amount) as total_spent
822 WHERE transaction_count > 5
823 MATCH (m)<-[:Transaction]-(other:Account)
824 WHERE other <> a
825 RETURN a.account_number as account_id,
826 m.name as merchant_name,
827 transaction_count,
828 total_spent,
829 count(DISTINCT other) as fellow_customers
830 ORDER BY total_spent DESC
831 LIMIT 10
832 ";
833
834 let with_result = fixture.query(with_chain_query);
835 match &with_result {
836 Ok(r) => {
837 log::debug!("✅ WITH chaining works: {} rows", r.rows.len());
838 assert!(r.rows.len() <= 10, "LIMIT 10 should be respected");
839
840 // Verify expected columns
841 if let Some(first_row) = r.rows.first() {
842 assert!(
843 first_row.values.contains_key("account_id"),
844 "Should have account_id"
845 );
846 assert!(
847 first_row.values.contains_key("merchant_name"),
848 "Should have merchant_name"
849 );
850 assert!(
851 first_row.values.contains_key("transaction_count"),
852 "Should have transaction_count"
853 );
854 assert!(
855 first_row.values.contains_key("total_spent"),
856 "Should have total_spent"
857 );
858 assert!(
859 first_row.values.contains_key("fellow_customers"),
860 "Should have fellow_customers"
861 );
862
863 log::debug!(" Sample row: account={:?}, merchant={:?}, tx_count={:?}, total={:?}, fellow={:?}",
864 first_row.values.get("account_id"),
865 first_row.values.get("merchant_name"),
866 first_row.values.get("transaction_count"),
867 first_row.values.get("total_spent"),
868 first_row.values.get("fellow_customers")

Callers

nothing calls this directly

Calls 3

queryMethod · 0.45
firstMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected