{ "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)" ] ] } }