added alias names to lookup queries for merger

This commit is contained in:
2026-08-22 21:48:40 -04:00
parent a232bd4727
commit d08181e1d7
3 changed files with 38 additions and 34 deletions

View File

@ -1357,10 +1357,10 @@
"LEFT JOIN agreego.\"user\" t3 ON t3.id = t1.id",
"LEFT JOIN agreego.\"person\" t4 ON t4.id = t1.id",
"WHERE",
" (\"first_name\" = 'LookupFirst'",
" AND \"last_name\" = 'LookupLast'",
" AND \"date_of_birth\" = '{{timestamp}}'",
" AND \"pronouns\" = 'they/them'))"
" (t4.\"first_name\" = 'LookupFirst'",
" AND t4.\"last_name\" = 'LookupLast'",
" AND t4.\"date_of_birth\" = '{{timestamp}}'",
" AND t4.\"pronouns\" = 'they/them'))"
],
[
"INSERT INTO agreego.\"entity\" (",
@ -1521,10 +1521,10 @@
"LEFT JOIN agreego.\"user\" t3 ON t3.id = t1.id",
"LEFT JOIN agreego.\"person\" t4 ON t4.id = t1.id",
"WHERE",
" (\"first_name\" = 'LookupFirst'",
" AND \"last_name\" = 'LookupLast'",
" AND \"date_of_birth\" = '{{timestamp}}'",
" AND \"pronouns\" = 'they/them'))"
" (t4.\"first_name\" = 'LookupFirst'",
" AND t4.\"last_name\" = 'LookupLast'",
" AND t4.\"date_of_birth\" = '{{timestamp}}'",
" AND t4.\"pronouns\" = 'they/them'))"
],
[
"INSERT INTO agreego.\"entity\" (",
@ -1687,17 +1687,17 @@
"LEFT JOIN agreego.\"user\" t3 ON t3.id = t1.id",
"LEFT JOIN agreego.\"person\" t4 ON t4.id = t1.id",
"WHERE",
" (\"first_name\" = 'LookupFirst'",
" AND \"last_name\" = 'LookupLast'",
" AND \"date_of_birth\" = '{{timestamp}}'",
" AND \"pronouns\" = 'they/them')",
" (t4.\"first_name\" = 'LookupFirst'",
" AND t4.\"last_name\" = 'LookupLast'",
" AND t4.\"date_of_birth\" = '{{timestamp}}'",
" AND t4.\"pronouns\" = 'they/them')",
"UNION SELECT COALESCE(to_jsonb(t1.*), '{}') || COALESCE(to_jsonb(t2.*), '{}') || COALESCE(to_jsonb(t3.*), '{}') || COALESCE(to_jsonb(t4.*), '{}')",
"FROM agreego.\"entity\" t1",
"LEFT JOIN agreego.\"organization\" t2 ON t2.id = t1.id",
"LEFT JOIN agreego.\"user\" t3 ON t3.id = t1.id",
"LEFT JOIN agreego.\"person\" t4 ON t4.id = t1.id",
"WHERE",
" (\"name\" = 'LookupName'))"
" (t3.\"name\" = 'LookupName'))"
],
[
"INSERT INTO agreego.\"entity\" (",
@ -1862,10 +1862,10 @@
"LEFT JOIN agreego.\"user\" t3 ON t3.id = t1.id",
"LEFT JOIN agreego.\"person\" t4 ON t4.id = t1.id",
"WHERE",
" (\"first_name\" = 'LookupFirst'",
" AND \"last_name\" = 'LookupLast'",
" AND \"date_of_birth\" = '{{timestamp}}'",
" AND \"pronouns\" = 'they/them'))"
" (t4.\"first_name\" = 'LookupFirst'",
" AND t4.\"last_name\" = 'LookupLast'",
" AND t4.\"date_of_birth\" = '{{timestamp}}'",
" AND t4.\"pronouns\" = 'they/them'))"
],
[
"INSERT INTO agreego.\"entity\" (",
@ -2796,10 +2796,10 @@
"LEFT JOIN agreego.\"relationship\" t2 ON t2.id = t1.id",
"LEFT JOIN agreego.\"contact\" t3 ON t3.id = t1.id",
"WHERE",
" (t1.\"type\" = 'contact'",
" AND \"source_id\" = '{{uuid:generated_0}}'",
" AND \"target_id\" = '{{uuid:generated_1}}'",
" AND \"start_date\" = '{{timestamp}}'))"
" (t2.\"type\" = 'contact'",
" AND t2.\"source_id\" = '{{uuid:generated_0}}'",
" AND t2.\"target_id\" = '{{uuid:generated_1}}'",
" AND t2.\"start_date\" = '{{timestamp}}'))"
],
[
"INSERT INTO agreego.\"entity\" (",
@ -2928,10 +2928,10 @@
"LEFT JOIN agreego.\"relationship\" t2 ON t2.id = t1.id",
"LEFT JOIN agreego.\"contact\" t3 ON t3.id = t1.id",
"WHERE",
" (t1.\"type\" = 'contact'",
" AND \"source_id\" = '{{uuid:generated_0}}'",
" AND \"target_id\" = '{{uuid:generated_5}}'",
" AND \"start_date\" = '{{timestamp}}'))"
" (t2.\"type\" = 'contact'",
" AND t2.\"source_id\" = '{{uuid:generated_0}}'",
" AND t2.\"target_id\" = '{{uuid:generated_5}}'",
" AND t2.\"start_date\" = '{{timestamp}}'))"
],
[
"INSERT INTO agreego.\"entity\" (",
@ -3060,10 +3060,10 @@
"LEFT JOIN agreego.\"relationship\" t2 ON t2.id = t1.id",
"LEFT JOIN agreego.\"contact\" t3 ON t3.id = t1.id",
"WHERE",
" (t1.\"type\" = 'contact'",
" AND \"source_id\" = '{{uuid:generated_0}}'",
" AND \"target_id\" = '{{uuid:generated_9}}'",
" AND \"start_date\" = '{{timestamp}}'))"
" (t2.\"type\" = 'contact'",
" AND t2.\"source_id\" = '{{uuid:generated_0}}'",
" AND t2.\"target_id\" = '{{uuid:generated_9}}'",
" AND t2.\"start_date\" = '{{timestamp}}'))"
],
[
"INSERT INTO agreego.\"entity\" (",