more tests progress
This commit is contained in:
@ -8,28 +8,34 @@
|
||||
{
|
||||
"type": "relation",
|
||||
"id": "00000000-0000-0000-0000-000000000001",
|
||||
"constraint": "fk_contact_person",
|
||||
"source_type": "contact",
|
||||
"constraint": "fk_relationship_source_entity",
|
||||
"source_type": "relationship",
|
||||
"source_columns": [
|
||||
"source_id"
|
||||
"source_id",
|
||||
"source_type"
|
||||
],
|
||||
"destination_type": "person",
|
||||
"destination_type": "entity",
|
||||
"destination_columns": [
|
||||
"id"
|
||||
]
|
||||
"id",
|
||||
"type"
|
||||
],
|
||||
"prefix": "source"
|
||||
},
|
||||
{
|
||||
"type": "relation",
|
||||
"id": "00000000-0000-0000-0000-000000000002",
|
||||
"constraint": "fk_contact_phone",
|
||||
"source_type": "contact",
|
||||
"constraint": "fk_relationship_target_entity",
|
||||
"source_type": "relationship",
|
||||
"source_columns": [
|
||||
"target_id"
|
||||
"target_id",
|
||||
"target_type"
|
||||
],
|
||||
"destination_type": "phone_number",
|
||||
"destination_type": "entity",
|
||||
"destination_columns": [
|
||||
"id"
|
||||
]
|
||||
"id",
|
||||
"type"
|
||||
],
|
||||
"prefix": "target"
|
||||
}
|
||||
],
|
||||
"types": [
|
||||
@ -461,7 +467,7 @@
|
||||
},
|
||||
"tests": [
|
||||
{
|
||||
"description": "Should execute a blanket SELECT query when no filters are present",
|
||||
"description": "Simple entity select",
|
||||
"action": "query",
|
||||
"schema_id": "entity",
|
||||
"expect": {
|
||||
@ -481,7 +487,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Should execute a blanket SELECT query isolating root stems directly",
|
||||
"description": "Simple entity select on root stem",
|
||||
"action": "query",
|
||||
"schema_id": "entity",
|
||||
"stem": "",
|
||||
@ -502,65 +508,60 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Should bind parameters with proper casting and ILIKE for generated generic SELECT string when using some filters",
|
||||
"description": "Simple entity select with multiple filters",
|
||||
"action": "query",
|
||||
"schema_id": "entity",
|
||||
"filters": {
|
||||
"name": "Jane%",
|
||||
"archived": false
|
||||
"id": {
|
||||
"$eq": "123e4567-e89b-12d3-a456-426614174000",
|
||||
"$ne": "123e4567-e89b-12d3-a456-426614174001",
|
||||
"$in": [
|
||||
"123e4567-e89b-12d3-a456-426614174000"
|
||||
],
|
||||
"$nin": [
|
||||
"123e4567-e89b-12d3-a456-426614174001"
|
||||
]
|
||||
},
|
||||
"name": {
|
||||
"$eq": "Jane%",
|
||||
"$ne": "John%",
|
||||
"$gt": "A",
|
||||
"$gte": "B",
|
||||
"$lt": "Z",
|
||||
"$lte": "Y",
|
||||
"$in": [
|
||||
"Jane",
|
||||
"John"
|
||||
],
|
||||
"$nin": [
|
||||
"Bob",
|
||||
"Alice"
|
||||
]
|
||||
},
|
||||
"created_at": {
|
||||
"$eq": "2023-01-01T00:00:00Z",
|
||||
"$ne": "2023-01-02T00:00:00Z",
|
||||
"$gt": "2022-01-01T00:00:00Z",
|
||||
"$gte": "2022-01-02T00:00:00Z",
|
||||
"$lt": "2024-01-01T00:00:00Z",
|
||||
"$lte": "2024-01-02T00:00:00Z"
|
||||
},
|
||||
"archived": {
|
||||
"$eq": false,
|
||||
"$ne": true
|
||||
}
|
||||
},
|
||||
"expect": {
|
||||
"success": true,
|
||||
"sql": [
|
||||
[
|
||||
"(SELECT jsonb_build_object(",
|
||||
" 'archived', t1_obj_t1.archived,",
|
||||
" 'created_at', t1_obj_t1.created_at,",
|
||||
" 'id', t1_obj_t1.id,",
|
||||
" 'name', t1_obj_t1.name,",
|
||||
" 'type', t1_obj_t1.type)",
|
||||
" FROM agreego.entity t1_obj_t1",
|
||||
" WHERE",
|
||||
" NOT t1_obj_t1.archived",
|
||||
" AND t1_obj_t1.archived = ($1#>>'{}')::boolean",
|
||||
" AND t1_obj_t1.name ILIKE $2#>>'{}')"
|
||||
"DUMMY TO FAIL AND DUMP SQL"
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Should bind all parameters with proper casting for complex generic SELECT string",
|
||||
"action": "query",
|
||||
"schema_id": "entity",
|
||||
"filters": {
|
||||
"id": "123e4567-e89b-12d3-a456-426614174000",
|
||||
"name": "Jane%",
|
||||
"created_at": "2023-01-01T00:00:00Z",
|
||||
"archived": false
|
||||
},
|
||||
"expect": {
|
||||
"success": true,
|
||||
"sql": [
|
||||
[
|
||||
"(SELECT jsonb_build_object(",
|
||||
" 'archived', t1_obj_t1.archived,",
|
||||
" 'created_at', t1_obj_t1.created_at,",
|
||||
" 'id', t1_obj_t1.id,",
|
||||
" 'name', t1_obj_t1.name,",
|
||||
" 'type', t1_obj_t1.type)",
|
||||
" FROM agreego.entity t1_obj_t1",
|
||||
" WHERE",
|
||||
" NOT t1_obj_t1.archived",
|
||||
" AND t1_obj_t1.archived = ($1#>>'{}')::boolean",
|
||||
" AND t1_obj_t1.created_at = ($2#>>'{}')::timestamptz",
|
||||
" AND t1_obj_t1.id = ($3#>>'{}')::uuid",
|
||||
" AND t1_obj_t1.name ILIKE $4#>>'{}')"
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Should execute table multi-joins on inheritance for basic schema",
|
||||
"description": "Person select on base schema",
|
||||
"action": "query",
|
||||
"schema_id": "base.person",
|
||||
"expect": {
|
||||
@ -584,7 +585,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Should render a massive query handling full nested tree generation and JSON aggregation for complex relationships",
|
||||
"description": "Person select on full schema",
|
||||
"action": "query",
|
||||
"schema_id": "full.person",
|
||||
"expect": {
|
||||
@ -715,147 +716,79 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Should attach structural filters against the root entity object regardless of how deep the select statement builds child join maps",
|
||||
"description": "Person select on full schema with filters",
|
||||
"action": "query",
|
||||
"schema_id": "full.person",
|
||||
"filters": {
|
||||
"first_name": "Jane%",
|
||||
"last_name": "%Doe%",
|
||||
"archived": true
|
||||
"age": {
|
||||
"$eq": 30,
|
||||
"$gt": 20,
|
||||
"$gte": 20,
|
||||
"$in": [
|
||||
30,
|
||||
40
|
||||
],
|
||||
"$lt": 50,
|
||||
"$lte": 50,
|
||||
"$ne": 25,
|
||||
"$nin": [
|
||||
1,
|
||||
2
|
||||
]
|
||||
},
|
||||
"archived": {
|
||||
"$eq": true,
|
||||
"$ne": false
|
||||
},
|
||||
"created_at": {
|
||||
"$eq": "2020-01-01T00:00:00Z",
|
||||
"$gt": "2019-01-01T00:00:00Z",
|
||||
"$gte": "2019-01-01T00:00:00Z",
|
||||
"$lt": "2021-01-01T00:00:00Z",
|
||||
"$lte": "2021-01-01T00:00:00Z",
|
||||
"$ne": "2022-01-01T00:00:00Z"
|
||||
},
|
||||
"first_name": {
|
||||
"$eq": "Jane%",
|
||||
"$gt": "A",
|
||||
"$gte": "A",
|
||||
"$in": [
|
||||
"Jane",
|
||||
"John"
|
||||
],
|
||||
"$lt": "Z",
|
||||
"$lte": "Z",
|
||||
"$ne": "Doe",
|
||||
"$nin": [
|
||||
"Bob"
|
||||
]
|
||||
},
|
||||
"last_name": {
|
||||
"$eq": "%Doe%",
|
||||
"$ne": "%Smith%"
|
||||
},
|
||||
"id": {
|
||||
"$eq": "00000000-0000-0000-0000-000000000001",
|
||||
"$in": [
|
||||
"00000000-0000-0000-0000-000000000001"
|
||||
],
|
||||
"$ne": "00000000-0000-0000-0000-000000000002",
|
||||
"$nin": [
|
||||
"00000000-0000-0000-0000-000000000002"
|
||||
]
|
||||
}
|
||||
},
|
||||
"expect": {
|
||||
"success": true,
|
||||
"sql": [
|
||||
[
|
||||
"(SELECT jsonb_build_object(",
|
||||
" 'addresses',",
|
||||
" (SELECT COALESCE(jsonb_agg(jsonb_build_object(",
|
||||
" 'archived', t1_obj_t2_addresses_t3.archived,",
|
||||
" 'created_at', t1_obj_t2_addresses_t3.created_at,",
|
||||
" 'id', t1_obj_t2_addresses_t3.id,",
|
||||
" 'is_primary', t1_obj_t2_addresses_t1.is_primary,",
|
||||
" 'name', t1_obj_t2_addresses_t3.name,",
|
||||
" 'target',",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'archived', t1_obj_t2_addresses_t3_target_t2.archived,",
|
||||
" 'city', t1_obj_t2_addresses_t3_target_t1.city,",
|
||||
" 'created_at', t1_obj_t2_addresses_t3_target_t2.created_at,",
|
||||
" 'id', t1_obj_t2_addresses_t3_target_t2.id,",
|
||||
" 'name', t1_obj_t2_addresses_t3_target_t2.name,",
|
||||
" 'type', t1_obj_t2_addresses_t3_target_t2.type",
|
||||
" )",
|
||||
" FROM agreego.address t1_obj_t2_addresses_t3_target_t1",
|
||||
" JOIN agreego.entity t1_obj_t2_addresses_t3_target_t2 ON t1_obj_t2_addresses_t3_target_t2.id = t1_obj_t2_addresses_t3_target_t1.id",
|
||||
" WHERE",
|
||||
" NOT t1_obj_t2_addresses_t3_target_t1.archived",
|
||||
" AND t1_obj_t2_addresses_t3_target_t1.parent_id = t1_obj_t2_addresses_t3.id",
|
||||
" ),",
|
||||
" 'type', t1_obj_t2_addresses_t3.type",
|
||||
" )), '[]'::jsonb)",
|
||||
" FROM agreego.contact t1_obj_t2_addresses_t1",
|
||||
" JOIN agreego.relationship t1_obj_t2_addresses_t2 ON t1_obj_t2_addresses_t2.id = t1_obj_t2_addresses_t1.id",
|
||||
" JOIN agreego.entity t1_obj_t2_addresses_t3 ON t1_obj_t2_addresses_t3.id = t1_obj_t2_addresses_t2.id",
|
||||
" WHERE",
|
||||
" NOT t1_obj_t2_addresses_t1.archived",
|
||||
" AND t1_obj_t2_addresses_t1.parent_id = t1_obj_t2.id),",
|
||||
" 'age', t1_obj_t1.age,",
|
||||
" 'archived', t1_obj_t2.archived,",
|
||||
" 'contacts',",
|
||||
" (SELECT COALESCE(jsonb_agg(jsonb_build_object(",
|
||||
" 'archived', t1_obj_t2_contacts_t3.archived,",
|
||||
" 'created_at', t1_obj_t2_contacts_t3.created_at,",
|
||||
" 'id', t1_obj_t2_contacts_t3.id,",
|
||||
" 'is_primary', t1_obj_t2_contacts_t1.is_primary,",
|
||||
" 'name', t1_obj_t2_contacts_t3.name,",
|
||||
" 'target', t1_obj_t2_contacts_t3.target,",
|
||||
" 'type', t1_obj_t2_contacts_t3.type",
|
||||
" )), '[]'::jsonb)",
|
||||
" FROM agreego.contact t1_obj_t2_contacts_t1",
|
||||
" JOIN agreego.relationship t1_obj_t2_contacts_t2 ON t1_obj_t2_contacts_t2.id = t1_obj_t2_contacts_t1.id",
|
||||
" JOIN agreego.entity t1_obj_t2_contacts_t3 ON t1_obj_t2_contacts_t3.id = t1_obj_t2_contacts_t2.id",
|
||||
" WHERE",
|
||||
" NOT t1_obj_t2_contacts_t1.archived",
|
||||
" AND t1_obj_t2_contacts_t1.parent_id = t1_obj_t2.id),",
|
||||
" 'created_at', t1_obj_t2.created_at,",
|
||||
" 'email_addresses',",
|
||||
" (SELECT COALESCE(jsonb_agg(jsonb_build_object(",
|
||||
" 'archived', t1_obj_t2_email_addresses_t3.archived,",
|
||||
" 'created_at', t1_obj_t2_email_addresses_t3.created_at,",
|
||||
" 'id', t1_obj_t2_email_addresses_t3.id,",
|
||||
" 'is_primary', t1_obj_t2_email_addresses_t1.is_primary,",
|
||||
" 'name', t1_obj_t2_email_addresses_t3.name,",
|
||||
" 'target',",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'address', t1_obj_t2_email_addresses_t3_target_t1.address,",
|
||||
" 'archived', t1_obj_t2_email_addresses_t3_target_t2.archived,",
|
||||
" 'created_at', t1_obj_t2_email_addresses_t3_target_t2.created_at,",
|
||||
" 'id', t1_obj_t2_email_addresses_t3_target_t2.id,",
|
||||
" 'name', t1_obj_t2_email_addresses_t3_target_t2.name,",
|
||||
" 'type', t1_obj_t2_email_addresses_t3_target_t2.type",
|
||||
" )",
|
||||
" FROM agreego.email_address t1_obj_t2_email_addresses_t3_target_t1",
|
||||
" JOIN agreego.entity t1_obj_t2_email_addresses_t3_target_t2 ON t1_obj_t2_email_addresses_t3_target_t2.id = t1_obj_t2_email_addresses_t3_target_t1.id",
|
||||
" WHERE",
|
||||
" NOT t1_obj_t2_email_addresses_t3_target_t1.archived",
|
||||
" AND t1_obj_t2_email_addresses_t3_target_t1.parent_id = t1_obj_t2_email_addresses_t3.id",
|
||||
" ),",
|
||||
" 'type', t1_obj_t2_email_addresses_t3.type",
|
||||
" )), '[]'::jsonb)",
|
||||
" FROM agreego.contact t1_obj_t2_email_addresses_t1",
|
||||
" JOIN agreego.relationship t1_obj_t2_email_addresses_t2 ON t1_obj_t2_email_addresses_t2.id = t1_obj_t2_email_addresses_t1.id",
|
||||
" JOIN agreego.entity t1_obj_t2_email_addresses_t3 ON t1_obj_t2_email_addresses_t3.id = t1_obj_t2_email_addresses_t2.id",
|
||||
" WHERE",
|
||||
" NOT t1_obj_t2_email_addresses_t1.archived",
|
||||
" AND t1_obj_t2_email_addresses_t1.parent_id = t1_obj_t2.id),",
|
||||
" 'first_name', t1_obj_t1.first_name,",
|
||||
" 'id', t1_obj_t2.id,",
|
||||
" 'last_name', t1_obj_t1.last_name,",
|
||||
" 'name', t1_obj_t2.name,",
|
||||
" 'phone_numbers',",
|
||||
" (SELECT COALESCE(jsonb_agg(jsonb_build_object(",
|
||||
" 'archived', t1_obj_t2_phone_numbers_t3.archived,",
|
||||
" 'created_at', t1_obj_t2_phone_numbers_t3.created_at,",
|
||||
" 'id', t1_obj_t2_phone_numbers_t3.id,",
|
||||
" 'is_primary', t1_obj_t2_phone_numbers_t1.is_primary,",
|
||||
" 'name', t1_obj_t2_phone_numbers_t3.name,",
|
||||
" 'target',",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'archived', t1_obj_t2_phone_numbers_t3_target_t2.archived,",
|
||||
" 'created_at', t1_obj_t2_phone_numbers_t3_target_t2.created_at,",
|
||||
" 'id', t1_obj_t2_phone_numbers_t3_target_t2.id,",
|
||||
" 'name', t1_obj_t2_phone_numbers_t3_target_t2.name,",
|
||||
" 'number', t1_obj_t2_phone_numbers_t3_target_t1.number,",
|
||||
" 'type', t1_obj_t2_phone_numbers_t3_target_t2.type",
|
||||
" )",
|
||||
" FROM agreego.phone_number t1_obj_t2_phone_numbers_t3_target_t1",
|
||||
" JOIN agreego.entity t1_obj_t2_phone_numbers_t3_target_t2 ON t1_obj_t2_phone_numbers_t3_target_t2.id = t1_obj_t2_phone_numbers_t3_target_t1.id",
|
||||
" WHERE",
|
||||
" NOT t1_obj_t2_phone_numbers_t3_target_t1.archived",
|
||||
" AND t1_obj_t2_phone_numbers_t3_target_t1.parent_id = t1_obj_t2_phone_numbers_t3.id",
|
||||
" ),",
|
||||
" 'type', t1_obj_t2_phone_numbers_t3.type",
|
||||
" )), '[]'::jsonb)",
|
||||
" FROM agreego.contact t1_obj_t2_phone_numbers_t1",
|
||||
" JOIN agreego.relationship t1_obj_t2_phone_numbers_t2 ON t1_obj_t2_phone_numbers_t2.id = t1_obj_t2_phone_numbers_t1.id",
|
||||
" JOIN agreego.entity t1_obj_t2_phone_numbers_t3 ON t1_obj_t2_phone_numbers_t3.id = t1_obj_t2_phone_numbers_t2.id",
|
||||
" WHERE",
|
||||
" NOT t1_obj_t2_phone_numbers_t1.archived",
|
||||
" AND t1_obj_t2_phone_numbers_t1.parent_id = t1_obj_t2.id),",
|
||||
" 'type', t1_obj_t2.type",
|
||||
")",
|
||||
"FROM agreego.person t1_obj_t1",
|
||||
"JOIN agreego.entity t1_obj_t2 ON t1_obj_t2.id = t1_obj_t1.id",
|
||||
"WHERE",
|
||||
" NOT t1_obj_t1.archived",
|
||||
" AND t1_obj_t2.archived = ($1#>>'{}')::boolean",
|
||||
" AND t1_obj_t1.first_name ILIKE $2#>>'{}'",
|
||||
" AND t1_obj_t1.last_name ILIKE $3#>>'{}')"
|
||||
"DUMMY TO FAIL AND DUMP SQL"
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Should extract the targeted subset payload specifically for a high-level nested list",
|
||||
"description": "Full person stem query on phone number contact",
|
||||
"action": "query",
|
||||
"schema_id": "full.person",
|
||||
"stem": "phone_numbers/contact",
|
||||
@ -879,7 +812,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Should successfully execute nested path extraction for targeted root subgraphs on beats",
|
||||
"description": "Full person stem query on phone number contact on phone number",
|
||||
"action": "query",
|
||||
"schema_id": "full.person",
|
||||
"stem": "phone_numbers/contact/phone_number",
|
||||
@ -902,7 +835,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Should successfully resolve unique execution plans across nested properties inside relationships containing oneOf configurations",
|
||||
"description": "Full person stem query on contact email address",
|
||||
"action": "query",
|
||||
"schema_id": "full.person",
|
||||
"stem": "contacts/contact/email_address",
|
||||
|
||||
Reference in New Issue
Block a user