[
    {
        "description": "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"
                    ],
                    "grouped_fields": {
                        "entity": [
                            "id",
                            "type",
                            "name",
                            "archived",
                            "created_at"
                        ]
                    },
                    "field_types": {
                        "id": "uuid",
                        "name": "text",
                        "archived": "boolean",
                        "created_at": "timestamptz",
                        "type": "text"
                    },
                    "schemas": [
                        {
                            "$id": "entity",
                            "type": "object",
                            "properties": {
                                "id": {
                                    "type": "string",
                                    "format": "uuid"
                                },
                                "type": {
                                    "type": "string"
                                },
                                "name": {
                                    "type": "string"
                                },
                                "archived": {
                                    "type": "boolean"
                                },
                                "created_at": {
                                    "type": "string",
                                    "format": "date-time"
                                }
                            }
                        }
                    ],
                    "fields": [
                        "id",
                        "type",
                        "name",
                        "archived",
                        "created_at"
                    ]
                },
                {
                    "name": "person",
                    "hierarchy": [
                        "person",
                        "entity"
                    ],
                    "fields": [
                        "first_name",
                        "last_name",
                        "id",
                        "type",
                        "name",
                        "age",
                        "archived",
                        "created_at"
                    ],
                    "grouped_fields": {
                        "entity": [
                            "id",
                            "type",
                            "name",
                            "archived",
                            "created_at"
                        ],
                        "person": [
                            "first_name",
                            "last_name",
                            "age"
                        ]
                    },
                    "field_types": {
                        "id": "uuid",
                        "type": "text",
                        "archived": "boolean",
                        "first_name": "text",
                        "last_name": "text",
                        "name": "text",
                        "age": "numeric",
                        "created_at": "timestamptz"
                    },
                    "schemas": [
                        {
                            "$id": "base.person",
                            "$ref": "entity",
                            "properties": {
                                "first_name": {
                                    "type": "string"
                                },
                                "last_name": {
                                    "type": "string"
                                },
                                "age": {
                                    "type": "number"
                                }
                            }
                        },
                        {
                            "$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": [
                        "source_id",
                        "source_type",
                        "target_id",
                        "target_type",
                        "id",
                        "type",
                        "name",
                        "archived",
                        "created_at"
                    ],
                    "grouped_fields": {
                        "entity": [
                            "id",
                            "type",
                            "name",
                            "archived",
                            "created_at"
                        ],
                        "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",
                        "name": "text",
                        "created_at": "timestamptz"
                    },
                    "schemas": [
                        {
                            "$id": "relationship",
                            "$ref": "entity",
                            "properties": {}
                        }
                    ]
                },
                {
                    "name": "contact",
                    "relationship": true,
                    "hierarchy": [
                        "contact",
                        "relationship",
                        "entity"
                    ],
                    "fields": [
                        "is_primary",
                        "source_id",
                        "source_type",
                        "target_id",
                        "target_type",
                        "id",
                        "type",
                        "name",
                        "archived",
                        "created_at"
                    ],
                    "grouped_fields": {
                        "entity": [
                            "id",
                            "type",
                            "name",
                            "archived",
                            "created_at"
                        ],
                        "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",
                        "name": "text",
                        "created_at": "timestamptz"
                    },
                    "schemas": [
                        {
                            "$id": "contact",
                            "$ref": "relationship",
                            "properties": {
                                "is_primary": {
                                    "type": "boolean"
                                }
                            }
                        }
                    ]
                },
                {
                    "name": "phone_number",
                    "hierarchy": [
                        "phone_number",
                        "entity"
                    ],
                    "fields": [
                        "number",
                        "id",
                        "type",
                        "name",
                        "archived",
                        "created_at"
                    ],
                    "grouped_fields": {
                        "entity": [
                            "id",
                            "type",
                            "name",
                            "archived",
                            "created_at"
                        ],
                        "phone_number": [
                            "number"
                        ]
                    },
                    "field_types": {
                        "id": "uuid",
                        "type": "text",
                        "archived": "boolean",
                        "number": "text",
                        "name": "text",
                        "created_at": "timestamptz"
                    },
                    "schemas": [
                        {
                            "$id": "phone_number",
                            "$ref": "entity",
                            "properties": {
                                "number": {
                                    "type": "string"
                                }
                            }
                        }
                    ]
                },
                {
                    "name": "email_address",
                    "hierarchy": [
                        "email_address",
                        "entity"
                    ],
                    "fields": [
                        "address",
                        "id",
                        "type",
                        "name",
                        "archived",
                        "created_at"
                    ],
                    "grouped_fields": {
                        "entity": [
                            "id",
                            "type",
                            "name",
                            "archived",
                            "created_at"
                        ],
                        "email_address": [
                            "address"
                        ]
                    },
                    "field_types": {
                        "id": "uuid",
                        "type": "text",
                        "archived": "boolean",
                        "address": "text",
                        "name": "text",
                        "created_at": "timestamptz"
                    },
                    "schemas": [
                        {
                            "$id": "email_address",
                            "$ref": "entity",
                            "properties": {
                                "address": {
                                    "type": "string"
                                }
                            }
                        }
                    ]
                },
                {
                    "name": "address",
                    "hierarchy": [
                        "address",
                        "entity"
                    ],
                    "fields": [
                        "city",
                        "id",
                        "type",
                        "name",
                        "archived",
                        "created_at"
                    ],
                    "grouped_fields": {
                        "entity": [
                            "id",
                            "type",
                            "name",
                            "archived",
                            "created_at"
                        ],
                        "address": [
                            "city"
                        ]
                    },
                    "field_types": {
                        "id": "uuid",
                        "type": "text",
                        "archived": "boolean",
                        "city": "text",
                        "name": "text",
                        "created_at": "timestamptz"
                    },
                    "schemas": [
                        {
                            "$id": "address",
                            "$ref": "entity",
                            "properties": {
                                "city": {
                                    "type": "string"
                                }
                            }
                        }
                    ]
                }
            ]
        },
        "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(",
                            "  '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)"
                        ]
                    ]
                }
            },
            {
                "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(",
                            "  '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)"
                        ]
                    ]
                }
            },
            {
                "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(",
                            "  '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#>>'{}')"
                        ]
                    ]
                }
            },
            {
                "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",
                "action": "query",
                "schema_id": "base.person",
                "expect": {
                    "success": true,
                    "sql": [
                        [
                            "(SELECT jsonb_build_object(",
                            "  'age', t1_obj_t1.age,",
                            "  'archived', t1_obj_t2.archived,",
                            "  'created_at', t1_obj_t2.created_at,",
                            "  'first_name', t1_obj_t1.first_name,",
                            "  'id', t1_obj_t2.id,",
                            "  'last_name', t1_obj_t1.last_name,",
                            "  'name', t1_obj_t2.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,",
                            "    '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)"
                        ]
                    ]
                }
            },
            {
                "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,",
                            "    '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#>>'{}')"
                        ]
                    ]
                }
            },
            {
                "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,",
                            "  'created_at', t1_obj_t3.created_at,",
                            "  'id', t1_obj_t3.id,",
                            "  'is_primary', t1_obj_t1.is_primary,",
                            "  'name', t1_obj_t3.name,",
                            "  '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,",
                            "  'created_at', t1_obj_t2.created_at,",
                            "  'id', t1_obj_t2.id,",
                            "  'name', t1_obj_t2.name,",
                            "  '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,",
                            "  'created_at', t1_obj_t2.created_at,",
                            "  'id', t1_obj_t2.id,",
                            "  'name', t1_obj_t2.name,",
                            "  '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)"
                        ]
                    ]
                }
            }
        ]
    }
]