diff --git a/fixtures/queryer.json b/fixtures/queryer.json index 89bc6f6..143690f 100644 --- a/fixtures/queryer.json +++ b/fixtures/queryer.json @@ -1408,6 +1408,44 @@ ] } }, + { + "description": "Person ad-hoc email addresses select", + "action": "query", + "schema_id": "full.person/email_addresses", + "expect": { + "success": true, + "sql": [ + [ + "(SELECT jsonb_build_object(", + " 'archived', entity_3.archived,", + " 'created_at', entity_3.created_at,", + " 'id', entity_3.id,", + " 'is_primary', contact_1.is_primary,", + " 'name', entity_3.name,", + " 'target',", + " (SELECT jsonb_build_object(", + " 'address', email_address_4.address,", + " 'archived', entity_5.archived,", + " 'created_at', entity_5.created_at,", + " 'id', entity_5.id,", + " 'name', entity_5.name,", + " 'type', entity_5.type", + " )", + " FROM agreego.email_address email_address_4", + " JOIN agreego.entity entity_5 ON entity_5.id = email_address_4.id", + " WHERE", + " NOT entity_5.archived", + " AND relationship_2.target_id = entity_5.id),", + " 'type', entity_3.type", + ")", + "FROM agreego.contact contact_1", + "JOIN agreego.relationship relationship_2 ON relationship_2.id = contact_1.id", + "JOIN agreego.entity entity_3 ON entity_3.id = relationship_2.id", + "WHERE NOT entity_3.archived)" + ] + ] + } + }, { "description": "Order select with customer and lines", "action": "query", diff --git a/fixtures/t1.json b/fixtures/t1.json new file mode 100644 index 0000000..5c24c38 --- /dev/null +++ b/fixtures/t1.json @@ -0,0 +1,38 @@ +{ + "description": "Person ad-hoc email addresses select", + "action": "query", + "schema_id": "full.person/email_addresses", + "expect": { + "success": true, + "sql": [ + [ + "(SELECT jsonb_build_object(", + " 'archived', entity_3.archived,", + " 'created_at', entity_3.created_at,", + " 'id', entity_3.id,", + " 'is_primary', contact_1.is_primary,", + " 'name', entity_3.name,", + " 'target',", + " (SELECT jsonb_build_object(", + " 'address', email_address_4.address,", + " 'archived', entity_5.archived,", + " 'created_at', entity_5.created_at,", + " 'id', entity_5.id,", + " 'name', entity_5.name,", + " 'type', entity_5.type", + " )", + " FROM agreego.email_address email_address_4", + " JOIN agreego.entity entity_5 ON entity_5.id = email_address_4.id", + " WHERE", + " NOT entity_5.archived", + " AND relationship_2.target_id = entity_5.id),", + " 'type', entity_3.type", + ")", + "FROM agreego.contact contact_1", + "JOIN agreego.relationship relationship_2 ON relationship_2.id = contact_1.id", + "JOIN agreego.entity entity_3 ON entity_3.id = relationship_2.id", + "WHERE NOT entity_3.archived)" + ] + ] + } +} diff --git a/src/tests/fixtures.rs b/src/tests/fixtures.rs index aa64c67..7bd1c65 100644 --- a/src/tests/fixtures.rs +++ b/src/tests/fixtures.rs @@ -1451,6 +1451,12 @@ fn test_queryer_0_6() { crate::tests::runner::run_test_case(&path, 0, 6).unwrap(); } +#[test] +fn test_queryer_0_7() { + let path = format!("{}/fixtures/queryer.json", env!("CARGO_MANIFEST_DIR")); + crate::tests::runner::run_test_case(&path, 0, 7).unwrap(); +} + #[test] fn test_not_0_0() { let path = format!("{}/fixtures/not.json", env!("CARGO_MANIFEST_DIR"));