more tests
This commit is contained in:
@ -25,19 +25,19 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "get_light_organizations",
|
||||
"name": "get_light_organization",
|
||||
"schemas": [
|
||||
{
|
||||
"$id": "get_light_organizations.response",
|
||||
"$id": "get_light_organization.response",
|
||||
"$family": "light.organization"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "get_full_organizations",
|
||||
"name": "get_full_organization",
|
||||
"schemas": [
|
||||
{
|
||||
"$id": "get_full_organizations.response",
|
||||
"$id": "get_full_organization.response",
|
||||
"$family": "full.organization"
|
||||
}
|
||||
]
|
||||
@ -897,11 +897,27 @@
|
||||
},
|
||||
{
|
||||
"name": "widget",
|
||||
"hierarchy": ["widget", "entity"],
|
||||
"fields": ["id", "type", "kind", "archived", "created_at"],
|
||||
"hierarchy": [
|
||||
"widget",
|
||||
"entity"
|
||||
],
|
||||
"fields": [
|
||||
"id",
|
||||
"type",
|
||||
"kind",
|
||||
"archived",
|
||||
"created_at"
|
||||
],
|
||||
"grouped_fields": {
|
||||
"entity": ["id", "type", "archived", "created_at"],
|
||||
"widget": ["kind"]
|
||||
"entity": [
|
||||
"id",
|
||||
"type",
|
||||
"archived",
|
||||
"created_at"
|
||||
],
|
||||
"widget": [
|
||||
"kind"
|
||||
]
|
||||
},
|
||||
"field_types": {
|
||||
"id": "uuid",
|
||||
@ -910,27 +926,35 @@
|
||||
"archived": "boolean",
|
||||
"created_at": "timestamptz"
|
||||
},
|
||||
"variations": ["widget"],
|
||||
"variations": [
|
||||
"widget"
|
||||
],
|
||||
"schemas": [
|
||||
{
|
||||
"$id": "widget",
|
||||
"type": "entity",
|
||||
"properties": {
|
||||
"kind": { "type": "string" }
|
||||
"kind": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$id": "stock.widget",
|
||||
"type": "widget",
|
||||
"properties": {
|
||||
"kind": { "const": "stock" }
|
||||
"kind": {
|
||||
"const": "stock"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$id": "tasks.widget",
|
||||
"type": "widget",
|
||||
"properties": {
|
||||
"kind": { "const": "tasks" }
|
||||
"kind": {
|
||||
"const": "tasks"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -1597,50 +1621,60 @@
|
||||
"success": true,
|
||||
"sql": [
|
||||
[
|
||||
"(SELECT jsonb_strip_nulls((SELECT COALESCE(jsonb_agg(jsonb_build_object(",
|
||||
" 'id', organization_1.id,",
|
||||
" 'type', CASE",
|
||||
" WHEN organization_1.type = 'bot' THEN",
|
||||
" ((SELECT jsonb_build_object(",
|
||||
" 'archived', entity_5.archived,",
|
||||
" 'created_at', entity_5.created_at,",
|
||||
" 'id', entity_5.id,",
|
||||
" 'name', organization_4.name,",
|
||||
" 'token', bot_3.token,",
|
||||
" 'type', entity_5.type",
|
||||
" )",
|
||||
" FROM agreego.bot bot_3",
|
||||
" JOIN agreego.organization organization_4 ON organization_4.id = bot_3.id",
|
||||
" JOIN agreego.entity entity_5 ON entity_5.id = organization_4.id",
|
||||
" WHERE NOT entity_5.archived))",
|
||||
" WHEN organization_1.type = 'organization' THEN",
|
||||
" ((SELECT jsonb_build_object(",
|
||||
" 'archived', entity_7.archived,",
|
||||
" 'created_at', entity_7.created_at,",
|
||||
" 'id', entity_7.id,",
|
||||
" 'name', organization_6.name,",
|
||||
" 'type', entity_7.type",
|
||||
" )",
|
||||
" FROM agreego.organization organization_6",
|
||||
" JOIN agreego.entity entity_7 ON entity_7.id = organization_6.id",
|
||||
" WHERE NOT entity_7.archived))",
|
||||
" WHEN organization_1.type = 'person' THEN",
|
||||
" ((SELECT jsonb_build_object(",
|
||||
" 'age', person_8.age,",
|
||||
" 'archived', entity_10.archived,",
|
||||
" 'created_at', entity_10.created_at,",
|
||||
" 'first_name', person_8.first_name,",
|
||||
" 'id', entity_10.id,",
|
||||
" 'last_name', person_8.last_name,",
|
||||
" 'name', organization_9.name,",
|
||||
" 'type', entity_10.type",
|
||||
" )",
|
||||
" FROM agreego.person person_8",
|
||||
" JOIN agreego.organization organization_9 ON organization_9.id = person_8.id",
|
||||
" JOIN agreego.entity entity_10 ON entity_10.id = organization_9.id",
|
||||
" WHERE NOT entity_10.archived))",
|
||||
" ELSE NULL END",
|
||||
")), '[]'::jsonb)",
|
||||
"(SELECT jsonb_strip_nulls((SELECT COALESCE(jsonb_agg(",
|
||||
" CASE",
|
||||
" WHEN organization_1.type = 'bot' THEN (",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'archived', entity_5.archived,",
|
||||
" 'created_at', entity_5.created_at,",
|
||||
" 'id', entity_5.id,",
|
||||
" 'name', organization_4.name,",
|
||||
" 'role', bot_3.role,",
|
||||
" 'token', bot_3.token,",
|
||||
" 'type', entity_5.type",
|
||||
" )",
|
||||
" FROM agreego.bot bot_3",
|
||||
" JOIN agreego.organization organization_4 ON organization_4.id = bot_3.id",
|
||||
" JOIN agreego.entity entity_5 ON entity_5.id = organization_4.id",
|
||||
" WHERE",
|
||||
" NOT entity_5.archived",
|
||||
" AND entity_5.id = entity_2.id)",
|
||||
" )",
|
||||
" WHEN organization_1.type = 'organization' THEN (",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'archived', entity_7.archived,",
|
||||
" 'created_at', entity_7.created_at,",
|
||||
" 'id', entity_7.id,",
|
||||
" 'name', organization_6.name,",
|
||||
" 'type', entity_7.type",
|
||||
" )",
|
||||
" FROM agreego.organization organization_6",
|
||||
" JOIN agreego.entity entity_7 ON entity_7.id = organization_6.id",
|
||||
" WHERE",
|
||||
" NOT entity_7.archived",
|
||||
" AND entity_7.id = entity_2.id)",
|
||||
" )",
|
||||
" WHEN organization_1.type = 'person' THEN (",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'age', person_8.age,",
|
||||
" 'archived', entity_10.archived,",
|
||||
" 'created_at', entity_10.created_at,",
|
||||
" 'first_name', person_8.first_name,",
|
||||
" 'id', entity_10.id,",
|
||||
" 'last_name', person_8.last_name,",
|
||||
" 'name', organization_9.name,",
|
||||
" 'type', entity_10.type",
|
||||
" )",
|
||||
" FROM agreego.person person_8",
|
||||
" JOIN agreego.organization organization_9 ON organization_9.id = person_8.id",
|
||||
" JOIN agreego.entity entity_10 ON entity_10.id = organization_9.id",
|
||||
" WHERE",
|
||||
" NOT entity_10.archived",
|
||||
" AND entity_10.id = entity_2.id)",
|
||||
" )",
|
||||
" ELSE NULL",
|
||||
" END",
|
||||
"), '[]'::jsonb)",
|
||||
"FROM agreego.organization organization_1",
|
||||
"JOIN agreego.entity entity_2 ON entity_2.id = organization_1.id",
|
||||
"WHERE NOT entity_2.archived)))"
|
||||
@ -1651,12 +1685,47 @@
|
||||
{
|
||||
"description": "Light organizations select via a punc response with family",
|
||||
"action": "query",
|
||||
"schema_id": "get_light_organizations.response",
|
||||
"schema_id": "get_light_organization.response",
|
||||
"expect": {
|
||||
"success": true,
|
||||
"sql": [
|
||||
[
|
||||
"FIX ME"
|
||||
"(SELECT jsonb_strip_nulls((SELECT ",
|
||||
" CASE",
|
||||
" WHEN organization_1.type = 'bot' THEN (",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'archived', entity_5.archived,",
|
||||
" 'created_at', entity_5.created_at,",
|
||||
" 'id', entity_5.id,",
|
||||
" 'name', organization_4.name,",
|
||||
" 'token', bot_3.token,",
|
||||
" 'type', entity_5.type",
|
||||
" )",
|
||||
" FROM agreego.bot bot_3",
|
||||
" JOIN agreego.organization organization_4 ON organization_4.id = bot_3.id",
|
||||
" JOIN agreego.entity entity_5 ON entity_5.id = organization_4.id",
|
||||
" WHERE NOT entity_5.archived AND entity_5.id = entity_2.id)",
|
||||
" )",
|
||||
" WHEN organization_1.type = 'person' THEN (",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'archived', entity_8.archived,",
|
||||
" 'created_at', entity_8.created_at,",
|
||||
" 'first_name', person_6.first_name,",
|
||||
" 'id', entity_8.id,",
|
||||
" 'last_name', person_6.last_name,",
|
||||
" 'name', organization_7.name,",
|
||||
" 'type', entity_8.type",
|
||||
" )",
|
||||
" FROM agreego.person person_6",
|
||||
" JOIN agreego.organization organization_7 ON organization_7.id = person_6.id",
|
||||
" JOIN agreego.entity entity_8 ON entity_8.id = organization_7.id",
|
||||
" WHERE NOT entity_8.archived AND entity_8.id = entity_2.id)",
|
||||
" )",
|
||||
" ELSE NULL",
|
||||
" END",
|
||||
"FROM agreego.organization organization_1",
|
||||
"JOIN agreego.entity entity_2 ON entity_2.id = organization_1.id",
|
||||
"WHERE NOT entity_2.archived)))"
|
||||
]
|
||||
]
|
||||
}
|
||||
@ -1664,123 +1733,176 @@
|
||||
{
|
||||
"description": "Full organizations select via a punc response with family",
|
||||
"action": "query",
|
||||
"schema_id": "get_full_organizations.response",
|
||||
"schema_id": "get_full_organization.response",
|
||||
"expect": {
|
||||
"success": true,
|
||||
"sql": [
|
||||
[
|
||||
"(SELECT jsonb_strip_nulls((SELECT jsonb_build_object(",
|
||||
" 'addresses', (SELECT COALESCE(jsonb_agg(jsonb_build_object(",
|
||||
"(SELECT jsonb_strip_nulls((SELECT CASE",
|
||||
" WHEN organization_1.type = 'person' THEN (",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'addresses',",
|
||||
" (SELECT COALESCE(jsonb_agg(jsonb_build_object(",
|
||||
" 'archived', entity_8.archived,",
|
||||
" 'created_at', entity_8.created_at,",
|
||||
" 'id', entity_8.id,",
|
||||
" 'is_primary', contact_6.is_primary,",
|
||||
" 'target',",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'archived', entity_10.archived,",
|
||||
" 'city', address_9.city,",
|
||||
" 'created_at', entity_10.created_at,",
|
||||
" 'id', entity_10.id,",
|
||||
" 'type', entity_10.type",
|
||||
" )",
|
||||
" FROM agreego.address address_9",
|
||||
" JOIN agreego.entity entity_10 ON entity_10.id = address_9.id",
|
||||
" WHERE",
|
||||
" NOT entity_10.archived",
|
||||
" AND relationship_7.target_id = entity_10.id),",
|
||||
" 'type', entity_8.type",
|
||||
" )), '[]'::jsonb)",
|
||||
" FROM agreego.contact contact_6",
|
||||
" JOIN agreego.relationship relationship_7 ON relationship_7.id = contact_6.id",
|
||||
" JOIN agreego.entity entity_8 ON entity_8.id = relationship_7.id",
|
||||
" WHERE",
|
||||
" NOT entity_8.archived",
|
||||
" AND relationship_7.target_type = 'address'",
|
||||
" AND relationship_7.source_id = entity_5.id),",
|
||||
" 'age', person_3.age,",
|
||||
" 'archived', entity_5.archived,",
|
||||
" 'contacts',",
|
||||
" (SELECT COALESCE(jsonb_agg(jsonb_build_object(",
|
||||
" 'archived', entity_13.archived,",
|
||||
" 'created_at', entity_13.created_at,",
|
||||
" 'id', entity_13.id,",
|
||||
" 'is_primary', contact_11.is_primary,",
|
||||
" 'target',",
|
||||
" CASE",
|
||||
" WHEN entity_13.target_type = 'address' THEN (",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'archived', entity_15.archived,",
|
||||
" 'city', address_14.city,",
|
||||
" 'created_at', entity_15.created_at,",
|
||||
" 'id', entity_15.id,",
|
||||
" 'type', entity_15.type",
|
||||
" )",
|
||||
" FROM agreego.address address_14",
|
||||
" JOIN agreego.entity entity_15 ON entity_15.id = address_14.id",
|
||||
" WHERE",
|
||||
" NOT entity_15.archived",
|
||||
" AND relationship_12.target_id = entity_15.id)",
|
||||
" )",
|
||||
" WHEN entity_13.target_type = 'email_address' THEN (",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'address', email_address_16.address,",
|
||||
" 'archived', entity_17.archived,",
|
||||
" 'created_at', entity_17.created_at,",
|
||||
" 'id', entity_17.id,",
|
||||
" 'type', entity_17.type",
|
||||
" )",
|
||||
" FROM agreego.email_address email_address_16",
|
||||
" JOIN agreego.entity entity_17 ON entity_17.id = email_address_16.id",
|
||||
" WHERE",
|
||||
" NOT entity_17.archived",
|
||||
" AND relationship_12.target_id = entity_17.id)",
|
||||
" )",
|
||||
" WHEN entity_13.target_type = 'phone_number' THEN (",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'archived', entity_19.archived,",
|
||||
" 'created_at', entity_19.created_at,",
|
||||
" 'id', entity_19.id,",
|
||||
" 'number', phone_number_18.number,",
|
||||
" 'type', entity_19.type",
|
||||
" )",
|
||||
" FROM agreego.phone_number phone_number_18",
|
||||
" JOIN agreego.entity entity_19 ON entity_19.id = phone_number_18.id",
|
||||
" WHERE",
|
||||
" NOT entity_19.archived",
|
||||
" AND relationship_12.target_id = entity_19.id)",
|
||||
" )",
|
||||
" ELSE NULL",
|
||||
" END,",
|
||||
" 'type', entity_13.type",
|
||||
" )), '[]'::jsonb)",
|
||||
" FROM agreego.contact contact_11",
|
||||
" JOIN agreego.relationship relationship_12 ON relationship_12.id = contact_11.id",
|
||||
" JOIN agreego.entity entity_13 ON entity_13.id = relationship_12.id",
|
||||
" WHERE",
|
||||
" NOT entity_13.archived",
|
||||
" AND relationship_12.source_id = entity_5.id),",
|
||||
" 'created_at', entity_5.created_at,",
|
||||
" 'email_addresses',",
|
||||
" (SELECT COALESCE(jsonb_agg(jsonb_build_object(",
|
||||
" 'archived', entity_22.archived,",
|
||||
" 'created_at', entity_22.created_at,",
|
||||
" 'id', entity_22.id,",
|
||||
" 'is_primary', contact_20.is_primary,",
|
||||
" 'target',",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'address', email_address_23.address,",
|
||||
" 'archived', entity_24.archived,",
|
||||
" 'created_at', entity_24.created_at,",
|
||||
" 'id', entity_24.id,",
|
||||
" 'type', entity_24.type",
|
||||
" )",
|
||||
" FROM agreego.email_address email_address_23",
|
||||
" JOIN agreego.entity entity_24 ON entity_24.id = email_address_23.id",
|
||||
" WHERE",
|
||||
" NOT entity_24.archived",
|
||||
" AND relationship_21.target_id = entity_24.id),",
|
||||
" 'type', entity_22.type",
|
||||
" )), '[]'::jsonb)",
|
||||
" FROM agreego.contact contact_20",
|
||||
" JOIN agreego.relationship relationship_21 ON relationship_21.id = contact_20.id",
|
||||
" JOIN agreego.entity entity_22 ON entity_22.id = relationship_21.id",
|
||||
" WHERE",
|
||||
" NOT entity_22.archived",
|
||||
" AND relationship_21.target_type = 'email_address'",
|
||||
" AND relationship_21.source_id = entity_5.id),",
|
||||
" 'first_name', person_3.first_name,",
|
||||
" 'id', entity_5.id,",
|
||||
" 'is_primary', contact_3.is_primary,",
|
||||
" 'target', (SELECT jsonb_build_object(",
|
||||
" 'archived', entity_7.archived,",
|
||||
" 'city', address_6.city,",
|
||||
" 'created_at', entity_7.created_at,",
|
||||
" 'id', entity_7.id,",
|
||||
" 'type', entity_7.type",
|
||||
" )",
|
||||
" FROM agreego.address address_6",
|
||||
" JOIN agreego.entity entity_7 ON entity_7.id = address_6.id",
|
||||
" WHERE NOT entity_7.archived AND relationship_4.target_id = entity_7.id),",
|
||||
" 'last_name', person_3.last_name,",
|
||||
" 'name', organization_4.name,",
|
||||
" 'phone_numbers',",
|
||||
" (SELECT COALESCE(jsonb_agg(jsonb_build_object(",
|
||||
" 'archived', entity_27.archived,",
|
||||
" 'created_at', entity_27.created_at,",
|
||||
" 'id', entity_27.id,",
|
||||
" 'is_primary', contact_25.is_primary,",
|
||||
" 'target',",
|
||||
" (SELECT jsonb_build_object(",
|
||||
" 'archived', entity_29.archived,",
|
||||
" 'created_at', entity_29.created_at,",
|
||||
" 'id', entity_29.id,",
|
||||
" 'number', phone_number_28.number,",
|
||||
" 'type', entity_29.type",
|
||||
" )",
|
||||
" FROM agreego.phone_number phone_number_28",
|
||||
" JOIN agreego.entity entity_29 ON entity_29.id = phone_number_28.id",
|
||||
" WHERE",
|
||||
" NOT entity_29.archived",
|
||||
" AND relationship_26.target_id = entity_29.id),",
|
||||
" 'type', entity_27.type",
|
||||
" )), '[]'::jsonb)",
|
||||
" FROM agreego.contact contact_25",
|
||||
" JOIN agreego.relationship relationship_26 ON relationship_26.id = contact_25.id",
|
||||
" JOIN agreego.entity entity_27 ON entity_27.id = relationship_26.id",
|
||||
" WHERE",
|
||||
" NOT entity_27.archived",
|
||||
" AND relationship_26.target_type = 'phone_number'",
|
||||
" AND relationship_26.source_id = entity_5.id),",
|
||||
" 'type', entity_5.type",
|
||||
" )), '[]'::jsonb)",
|
||||
" FROM agreego.contact contact_3",
|
||||
" JOIN agreego.relationship relationship_4 ON relationship_4.id = contact_3.id",
|
||||
" JOIN agreego.entity entity_5 ON entity_5.id = relationship_4.id",
|
||||
" WHERE NOT entity_5.archived AND relationship_4.target_type = 'address' AND relationship_4.source_id = entity_2.id),",
|
||||
" 'archived', entity_2.archived,",
|
||||
" 'contacts', (SELECT COALESCE(jsonb_agg(jsonb_build_object(",
|
||||
" 'archived', entity_10.archived,",
|
||||
" 'created_at', entity_10.created_at,",
|
||||
" 'id', entity_10.id,",
|
||||
" 'is_primary', contact_8.is_primary,",
|
||||
" 'target', CASE WHEN entity_10.target_type = 'address' THEN ((SELECT jsonb_build_object(",
|
||||
" 'archived', entity_12.archived,",
|
||||
" 'city', address_11.city,",
|
||||
" 'created_at', entity_12.created_at,",
|
||||
" 'id', entity_12.id,",
|
||||
" 'type', entity_12.type",
|
||||
" )",
|
||||
" FROM agreego.address address_11",
|
||||
" JOIN agreego.entity entity_12 ON entity_12.id = address_11.id",
|
||||
" WHERE NOT entity_12.archived AND relationship_9.target_id = entity_12.id)) WHEN entity_10.target_type = 'email_address' THEN ((SELECT jsonb_build_object(",
|
||||
" 'address', email_address_13.address,",
|
||||
" 'archived', entity_14.archived,",
|
||||
" 'created_at', entity_14.created_at,",
|
||||
" 'id', entity_14.id,",
|
||||
" 'type', entity_14.type",
|
||||
" )",
|
||||
" FROM agreego.email_address email_address_13",
|
||||
" JOIN agreego.entity entity_14 ON entity_14.id = email_address_13.id",
|
||||
" WHERE NOT entity_14.archived AND relationship_9.target_id = entity_14.id)) WHEN entity_10.target_type = 'phone_number' THEN ((SELECT jsonb_build_object(",
|
||||
" 'archived', entity_16.archived,",
|
||||
" 'created_at', entity_16.created_at,",
|
||||
" 'id', entity_16.id,",
|
||||
" 'number', phone_number_15.number,",
|
||||
" 'type', entity_16.type",
|
||||
" )",
|
||||
" FROM agreego.phone_number phone_number_15",
|
||||
" JOIN agreego.entity entity_16 ON entity_16.id = phone_number_15.id",
|
||||
" WHERE NOT entity_16.archived AND relationship_9.target_id = entity_16.id)) ELSE NULL END,",
|
||||
" 'type', entity_10.type",
|
||||
" )), '[]'::jsonb)",
|
||||
" FROM agreego.contact contact_8",
|
||||
" JOIN agreego.relationship relationship_9 ON relationship_9.id = contact_8.id",
|
||||
" JOIN agreego.entity entity_10 ON entity_10.id = relationship_9.id",
|
||||
" WHERE NOT entity_10.archived AND relationship_9.source_id = entity_2.id),",
|
||||
" 'created_at', entity_2.created_at,",
|
||||
" 'email_addresses', (SELECT COALESCE(jsonb_agg(jsonb_build_object(",
|
||||
" 'archived', entity_19.archived,",
|
||||
" 'created_at', entity_19.created_at,",
|
||||
" 'id', entity_19.id,",
|
||||
" 'is_primary', contact_17.is_primary,",
|
||||
" 'target', (SELECT jsonb_build_object(",
|
||||
" 'address', email_address_20.address,",
|
||||
" 'archived', entity_21.archived,",
|
||||
" 'created_at', entity_21.created_at,",
|
||||
" 'id', entity_21.id,",
|
||||
" 'type', entity_21.type",
|
||||
" )",
|
||||
" FROM agreego.email_address email_address_20",
|
||||
" JOIN agreego.entity entity_21 ON entity_21.id = email_address_20.id",
|
||||
" WHERE NOT entity_21.archived AND relationship_18.target_id = entity_21.id),",
|
||||
" 'type', entity_19.type",
|
||||
" )), '[]'::jsonb)",
|
||||
" FROM agreego.contact contact_17",
|
||||
" JOIN agreego.relationship relationship_18 ON relationship_18.id = contact_17.id",
|
||||
" JOIN agreego.entity entity_19 ON entity_19.id = relationship_18.id",
|
||||
" WHERE NOT entity_19.archived AND relationship_18.target_type = 'email_address' AND relationship_18.source_id = entity_2.id),",
|
||||
" 'id', entity_2.id,",
|
||||
" 'name', organization_1.name,",
|
||||
" 'phone_numbers', (SELECT COALESCE(jsonb_agg(jsonb_build_object(",
|
||||
" 'archived', entity_24.archived,",
|
||||
" 'created_at', entity_24.created_at,",
|
||||
" 'id', entity_24.id,",
|
||||
" 'is_primary', contact_22.is_primary,",
|
||||
" 'target', (SELECT jsonb_build_object(",
|
||||
" 'archived', entity_26.archived,",
|
||||
" 'created_at', entity_26.created_at,",
|
||||
" 'id', entity_26.id,",
|
||||
" 'number', phone_number_25.number,",
|
||||
" 'type', entity_26.type",
|
||||
" )",
|
||||
" FROM agreego.phone_number phone_number_25",
|
||||
" JOIN agreego.entity entity_26 ON entity_26.id = phone_number_25.id",
|
||||
" WHERE NOT entity_26.archived AND relationship_23.target_id = entity_26.id),",
|
||||
" 'type', entity_24.type",
|
||||
" )), '[]'::jsonb)",
|
||||
" FROM agreego.contact contact_22",
|
||||
" JOIN agreego.relationship relationship_23 ON relationship_23.id = contact_22.id",
|
||||
" JOIN agreego.entity entity_24 ON entity_24.id = relationship_23.id",
|
||||
" WHERE NOT entity_24.archived AND relationship_23.target_type = 'phone_number' AND relationship_23.source_id = entity_2.id),",
|
||||
" 'type', entity_2.type",
|
||||
")))",
|
||||
" )",
|
||||
" FROM agreego.person person_3",
|
||||
" JOIN agreego.organization organization_4 ON organization_4.id = person_3.id",
|
||||
" JOIN agreego.entity entity_5 ON entity_5.id = organization_4.id",
|
||||
" WHERE NOT entity_5.archived AND entity_5.id = entity_2.id))",
|
||||
" ELSE NULL",
|
||||
"END",
|
||||
"FROM agreego.organization organization_1",
|
||||
"JOIN agreego.entity entity_2 ON entity_2.id = organization_1.id",
|
||||
"WHERE NOT entity_2.archived)"
|
||||
"WHERE NOT entity_2.archived)))"
|
||||
]
|
||||
]
|
||||
}
|
||||
@ -1833,7 +1955,32 @@
|
||||
"success": true,
|
||||
"sql": [
|
||||
[
|
||||
"FIX ME"
|
||||
"(SELECT jsonb_strip_nulls((SELECT COALESCE(jsonb_agg(",
|
||||
" CASE",
|
||||
" WHEN widget_1.kind = 'stock' THEN (",
|
||||
" jsonb_build_object(",
|
||||
" 'archived', entity_2.archived,",
|
||||
" 'created_at', entity_2.created_at,",
|
||||
" 'id', entity_2.id,",
|
||||
" 'kind', widget_1.kind,",
|
||||
" 'type', entity_2.type",
|
||||
" )",
|
||||
" )",
|
||||
" WHEN widget_1.kind = 'tasks' THEN (",
|
||||
" jsonb_build_object(",
|
||||
" 'archived', entity_2.archived,",
|
||||
" 'created_at', entity_2.created_at,",
|
||||
" 'id', entity_2.id,",
|
||||
" 'kind', widget_1.kind,",
|
||||
" 'type', entity_2.type",
|
||||
" )",
|
||||
" )",
|
||||
" ELSE NULL",
|
||||
" END",
|
||||
"), '[]'::jsonb)",
|
||||
"FROM agreego.widget widget_1",
|
||||
"JOIN agreego.entity entity_2 ON entity_2.id = widget_1.id",
|
||||
"WHERE NOT entity_2.archived)))"
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user