599 lines
33 KiB
JSON
599 lines
33 KiB
JSON
[
|
|
{
|
|
"description": "Basic Queryer Execution",
|
|
"database": {
|
|
"puncs": [],
|
|
"enums": [],
|
|
"relations": [],
|
|
"types": [
|
|
{
|
|
"name": "entity",
|
|
"hierarchy": [
|
|
"entity"
|
|
],
|
|
"grouped_fields": {
|
|
"entity": [
|
|
"id",
|
|
"name",
|
|
"archived",
|
|
"amount",
|
|
"created_at"
|
|
]
|
|
},
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"name": "text",
|
|
"archived": "boolean",
|
|
"amount": "numeric",
|
|
"created_at": "timestamptz"
|
|
},
|
|
"schemas": [
|
|
{
|
|
"$id": "entity",
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "string",
|
|
"format": "uuid"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"archived": {
|
|
"type": "boolean"
|
|
},
|
|
"amount": {
|
|
"type": "number"
|
|
},
|
|
"created_at": {
|
|
"type": "string",
|
|
"format": "date-time"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "Should execute a blanket SELECT query when no filters are present",
|
|
"action": "query",
|
|
"schema_id": "entity",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
"(SELECT jsonb_build_object('amount', t1_obj_t1.amount, 'archived', t1_obj_t1.archived, 'created_at', t1_obj_t1.created_at, 'id', t1_obj_t1.id, 'name', t1_obj_t1.name) FROM agreego.entity t1_obj_t1 WHERE NOT t1_obj_t1.archived)"
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Should execute a blanket SELECT query isolating root stems directly",
|
|
"action": "query",
|
|
"schema_id": "entity",
|
|
"stem": "",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
"(SELECT jsonb_build_object('amount', t1_obj_t1.amount, 'archived', t1_obj_t1.archived, 'created_at', t1_obj_t1.created_at, 'id', t1_obj_t1.id, 'name', t1_obj_t1.name) FROM agreego.entity t1_obj_t1 WHERE NOT t1_obj_t1.archived)"
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Should bind parameters with proper casting and ILIKE for generated generic SELECT string when using some filters",
|
|
"action": "query",
|
|
"schema_id": "entity",
|
|
"filters": {
|
|
"name": "Jane%",
|
|
"archived": false
|
|
},
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
"(SELECT jsonb_build_object('amount', t1_obj_t1.amount, 'archived', t1_obj_t1.archived, 'created_at', t1_obj_t1.created_at, 'id', t1_obj_t1.id, 'name', t1_obj_t1.name) 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#>>'{}')"
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"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%",
|
|
"amount": 100,
|
|
"created_at": "2023-01-01T00:00:00Z",
|
|
"archived": false
|
|
},
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
"(SELECT jsonb_build_object('amount', t1_obj_t1.amount, 'archived', t1_obj_t1.archived, 'created_at', t1_obj_t1.created_at, 'id', t1_obj_t1.id, 'name', t1_obj_t1.name) FROM agreego.entity t1_obj_t1 WHERE NOT t1_obj_t1.archived AND t1_obj_t1.amount = ($1#>>'{}')::numeric AND t1_obj_t1.archived = ($2#>>'{}')::boolean AND t1_obj_t1.created_at = ($3#>>'{}')::timestamptz AND t1_obj_t1.id = ($4#>>'{}')::uuid AND t1_obj_t1.name ILIKE $5#>>'{}')"
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "Complex Nested Queryer Execution",
|
|
"database": {
|
|
"puncs": [],
|
|
"enums": [],
|
|
"relations": [
|
|
{
|
|
"type": "relation",
|
|
"id": "00000000-0000-0000-0000-000000000001",
|
|
"constraint": "fk_contact_person",
|
|
"source_type": "contact",
|
|
"source_columns": [
|
|
"source_id"
|
|
],
|
|
"destination_type": "person",
|
|
"destination_columns": [
|
|
"id"
|
|
]
|
|
},
|
|
{
|
|
"type": "relation",
|
|
"id": "00000000-0000-0000-0000-000000000002",
|
|
"constraint": "fk_contact_phone",
|
|
"source_type": "contact",
|
|
"source_columns": [
|
|
"target_id"
|
|
],
|
|
"destination_type": "phone_number",
|
|
"destination_columns": [
|
|
"id"
|
|
]
|
|
}
|
|
],
|
|
"types": [
|
|
{
|
|
"name": "entity",
|
|
"hierarchy": [
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"archived"
|
|
],
|
|
"grouped_fields": {
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"archived"
|
|
]
|
|
},
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"type": "text",
|
|
"archived": "boolean"
|
|
},
|
|
"schemas": [
|
|
{
|
|
"$id": "entity",
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "string",
|
|
"format": "uuid"
|
|
},
|
|
"type": {
|
|
"type": "string"
|
|
},
|
|
"archived": {
|
|
"type": "boolean"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "person",
|
|
"hierarchy": [
|
|
"person",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"archived",
|
|
"first_name",
|
|
"last_name"
|
|
],
|
|
"grouped_fields": {
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"archived"
|
|
],
|
|
"person": [
|
|
"first_name",
|
|
"last_name"
|
|
]
|
|
},
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"type": "text",
|
|
"archived": "boolean",
|
|
"first_name": "text",
|
|
"last_name": "text"
|
|
},
|
|
"schemas": [
|
|
{
|
|
"$id": "base.person",
|
|
"$ref": "entity",
|
|
"properties": {
|
|
"first_name": {
|
|
"type": "string"
|
|
},
|
|
"last_name": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"$id": "full.person",
|
|
"$ref": "base.person",
|
|
"properties": {
|
|
"phone_numbers": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "contact",
|
|
"properties": {
|
|
"target": {
|
|
"$ref": "phone_number"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"email_addresses": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "contact",
|
|
"properties": {
|
|
"target": {
|
|
"$ref": "email_address"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"addresses": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "contact",
|
|
"properties": {
|
|
"target": {
|
|
"$ref": "address"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"contacts": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "contact",
|
|
"properties": {
|
|
"target": {
|
|
"oneOf": [
|
|
{
|
|
"$ref": "phone_number"
|
|
},
|
|
{
|
|
"$ref": "email_address"
|
|
},
|
|
{
|
|
"$ref": "address"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "relationship",
|
|
"relationship": true,
|
|
"hierarchy": [
|
|
"relationship",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"archived",
|
|
"source_id",
|
|
"source_type",
|
|
"target_id",
|
|
"target_type"
|
|
],
|
|
"grouped_fields": {
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"archived"
|
|
],
|
|
"relationship": [
|
|
"source_id",
|
|
"source_type",
|
|
"target_id",
|
|
"target_type"
|
|
]
|
|
},
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"type": "text",
|
|
"archived": "boolean",
|
|
"source_id": "uuid",
|
|
"source_type": "text",
|
|
"target_id": "uuid",
|
|
"target_type": "text"
|
|
},
|
|
"schemas": [
|
|
{
|
|
"$id": "relationship",
|
|
"$ref": "entity",
|
|
"properties": {}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "contact",
|
|
"relationship": true,
|
|
"hierarchy": [
|
|
"contact",
|
|
"relationship",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"archived",
|
|
"source_id",
|
|
"source_type",
|
|
"target_id",
|
|
"target_type",
|
|
"is_primary"
|
|
],
|
|
"grouped_fields": {
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"archived"
|
|
],
|
|
"relationship": [
|
|
"source_id",
|
|
"source_type",
|
|
"target_id",
|
|
"target_type"
|
|
],
|
|
"contact": [
|
|
"is_primary"
|
|
]
|
|
},
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"type": "text",
|
|
"archived": "boolean",
|
|
"source_id": "uuid",
|
|
"source_type": "text",
|
|
"target_id": "uuid",
|
|
"target_type": "text",
|
|
"is_primary": "boolean"
|
|
},
|
|
"schemas": [
|
|
{
|
|
"$id": "contact",
|
|
"$ref": "relationship",
|
|
"properties": {
|
|
"is_primary": {
|
|
"type": "boolean"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "phone_number",
|
|
"hierarchy": [
|
|
"phone_number",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"archived",
|
|
"number"
|
|
],
|
|
"grouped_fields": {
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"archived"
|
|
],
|
|
"phone_number": [
|
|
"number"
|
|
]
|
|
},
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"type": "text",
|
|
"archived": "boolean",
|
|
"number": "text"
|
|
},
|
|
"schemas": [
|
|
{
|
|
"$id": "phone_number",
|
|
"$ref": "entity",
|
|
"properties": {
|
|
"number": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "email_address",
|
|
"hierarchy": [
|
|
"email_address",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"archived",
|
|
"address"
|
|
],
|
|
"grouped_fields": {
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"archived"
|
|
],
|
|
"email_address": [
|
|
"address"
|
|
]
|
|
},
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"type": "text",
|
|
"archived": "boolean",
|
|
"address": "text"
|
|
},
|
|
"schemas": [
|
|
{
|
|
"$id": "email_address",
|
|
"$ref": "entity",
|
|
"properties": {
|
|
"address": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "address",
|
|
"hierarchy": [
|
|
"address",
|
|
"entity"
|
|
],
|
|
"fields": [
|
|
"id",
|
|
"type",
|
|
"archived",
|
|
"city"
|
|
],
|
|
"grouped_fields": {
|
|
"entity": [
|
|
"id",
|
|
"type",
|
|
"archived"
|
|
],
|
|
"address": [
|
|
"city"
|
|
]
|
|
},
|
|
"field_types": {
|
|
"id": "uuid",
|
|
"type": "text",
|
|
"archived": "boolean",
|
|
"city": "text"
|
|
},
|
|
"schemas": [
|
|
{
|
|
"$id": "address",
|
|
"$ref": "entity",
|
|
"properties": {
|
|
"city": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "Should execute table multi-joins on inheritance for basic schema",
|
|
"action": "query",
|
|
"schema_id": "base.person",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
"(SELECT jsonb_build_object('archived', t1_obj_t2.archived, 'first_name', t1_obj_t1.first_name, 'id', t1_obj_t2.id, 'last_name', t1_obj_t1.last_name, '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)"
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Should render a massive query handling full nested tree generation and JSON aggregation for complex relationships",
|
|
"action": "query",
|
|
"schema_id": "full.person",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
"(SELECT jsonb_build_object('addresses', (SELECT COALESCE(jsonb_agg(jsonb_build_object('archived', t1_obj_t2_addresses_t3.archived, 'id', t1_obj_t2_addresses_t3.id, 'is_primary', t1_obj_t2_addresses_t1.is_primary, 'target', (SELECT jsonb_build_object('archived', t1_obj_t2_addresses_t3_target_t2.archived, 'city', t1_obj_t2_addresses_t3_target_t1.city, 'id', t1_obj_t2_addresses_t3_target_t2.id, '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), 'archived', t1_obj_t2.archived, 'contacts', (SELECT COALESCE(jsonb_agg(jsonb_build_object('archived', t1_obj_t2_contacts_t3.archived, 'id', t1_obj_t2_contacts_t3.id, 'is_primary', t1_obj_t2_contacts_t1.is_primary, '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), 'email_addresses', (SELECT COALESCE(jsonb_agg(jsonb_build_object('archived', t1_obj_t2_email_addresses_t3.archived, 'id', t1_obj_t2_email_addresses_t3.id, 'is_primary', t1_obj_t2_email_addresses_t1.is_primary, '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, 'id', t1_obj_t2_email_addresses_t3_target_t2.id, '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, 'phone_numbers', (SELECT COALESCE(jsonb_agg(jsonb_build_object('archived', t1_obj_t2_phone_numbers_t3.archived, 'id', t1_obj_t2_phone_numbers_t3.id, 'is_primary', t1_obj_t2_phone_numbers_t1.is_primary, 'target', (SELECT jsonb_build_object('archived', t1_obj_t2_phone_numbers_t3_target_t2.archived, 'id', t1_obj_t2_phone_numbers_t3_target_t2.id, '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)"
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Should attach structural filters against the root entity object regardless of how deep the select statement builds child join maps",
|
|
"action": "query",
|
|
"schema_id": "full.person",
|
|
"filters": {
|
|
"first_name": "Jane%",
|
|
"last_name": "%Doe%",
|
|
"archived": true
|
|
},
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
"(SELECT jsonb_build_object('addresses', (SELECT COALESCE(jsonb_agg(jsonb_build_object('archived', t1_obj_t2_addresses_t3.archived, 'id', t1_obj_t2_addresses_t3.id, 'is_primary', t1_obj_t2_addresses_t1.is_primary, 'target', (SELECT jsonb_build_object('archived', t1_obj_t2_addresses_t3_target_t2.archived, 'city', t1_obj_t2_addresses_t3_target_t1.city, 'id', t1_obj_t2_addresses_t3_target_t2.id, '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), 'archived', t1_obj_t2.archived, 'contacts', (SELECT COALESCE(jsonb_agg(jsonb_build_object('archived', t1_obj_t2_contacts_t3.archived, 'id', t1_obj_t2_contacts_t3.id, 'is_primary', t1_obj_t2_contacts_t1.is_primary, '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), 'email_addresses', (SELECT COALESCE(jsonb_agg(jsonb_build_object('archived', t1_obj_t2_email_addresses_t3.archived, 'id', t1_obj_t2_email_addresses_t3.id, 'is_primary', t1_obj_t2_email_addresses_t1.is_primary, '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, 'id', t1_obj_t2_email_addresses_t3_target_t2.id, '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, 'phone_numbers', (SELECT COALESCE(jsonb_agg(jsonb_build_object('archived', t1_obj_t2_phone_numbers_t3.archived, 'id', t1_obj_t2_phone_numbers_t3.id, 'is_primary', t1_obj_t2_phone_numbers_t1.is_primary, 'target', (SELECT jsonb_build_object('archived', t1_obj_t2_phone_numbers_t3_target_t2.archived, 'id', t1_obj_t2_phone_numbers_t3_target_t2.id, '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#>>'{}')"
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Should extract the targeted subset payload specifically for a high-level nested list",
|
|
"action": "query",
|
|
"schema_id": "full.person",
|
|
"stem": "phone_numbers/contact",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
"(SELECT jsonb_build_object('archived', t1_obj_t3.archived, 'id', t1_obj_t3.id, 'is_primary', t1_obj_t1.is_primary, 'type', t1_obj_t3.type) FROM agreego.contact t1_obj_t1 JOIN agreego.relationship t1_obj_t2 ON t1_obj_t2.id = t1_obj_t1.id JOIN agreego.entity t1_obj_t3 ON t1_obj_t3.id = t1_obj_t2.id WHERE NOT t1_obj_t1.archived)"
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Should successfully execute nested path extraction for targeted root subgraphs on beats",
|
|
"action": "query",
|
|
"schema_id": "full.person",
|
|
"stem": "phone_numbers/contact/phone_number",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
"(SELECT jsonb_build_object('archived', t1_obj_t2.archived, 'id', t1_obj_t2.id, 'number', t1_obj_t1.number, 'type', t1_obj_t2.type) FROM agreego.phone_number t1_obj_t1 JOIN agreego.entity t1_obj_t2 ON t1_obj_t2.id = t1_obj_t1.id WHERE NOT t1_obj_t1.archived)"
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "Should successfully resolve unique execution plans across nested properties inside relationships containing oneOf configurations",
|
|
"action": "query",
|
|
"schema_id": "full.person",
|
|
"stem": "contacts/contact/email_address",
|
|
"expect": {
|
|
"success": true,
|
|
"sql": [
|
|
"(SELECT jsonb_build_object('address', t1_obj_t1.address, 'archived', t1_obj_t2.archived, 'id', t1_obj_t2.id, 'type', t1_obj_t2.type) FROM agreego.email_address t1_obj_t1 JOIN agreego.entity t1_obj_t2 ON t1_obj_t2.id = t1_obj_t1.id WHERE NOT t1_obj_t1.archived)"
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
] |