Switch to using entity instead of donor_name in views.

This is less confusing because `entity` is used elsewhere.
This commit is contained in:
Bradley M. Kuhn 2022-11-21 17:21:55 -08:00
parent 3fa1f004d3
commit 4a6ad06ebb

View file

@ -143,7 +143,7 @@ CREATE UNIQUE INDEX donor_postal_address_mapping_single_prefferred_per_donor
-- -------------- VIEW: UserOperation_update_email_address ---------------------
DROP VIEW IF EXISTS UserOperation_email_add_when_none;
CREATE VIEW UserOperation_email_add_when_none AS
SELECT ledger_entity_id as donor_name, map.preferred as preferred_override, ea.date_encountered as entered_date,
SELECT ledger_entity_id as entity, map.preferred as preferred_override, ea.date_encountered as entered_date,
ea.email_address as email_address, ea.id as address_id, dd.id as donor_id
FROM donor dd
LEFT JOIN donor_email_address_mapping map ON dd.id = map.donor_id
@ -177,7 +177,7 @@ END;
-- -------------- VIEW: UserOperation_add_postal_for_donor_with_none ---------------------
DROP VIEW IF EXISTS UserOperation_add_postal_for_donor_with_none;
CREATE VIEW UserOperation_add_postal_for_donor_with_none AS
SELECT ledger_entity_id as donor_name, map.preferred as preferred_override, pa.date_encountered as entered_date,
SELECT ledger_entity_id as entity, map.preferred as preferred_override, pa.date_encountered as entered_date,
pa.formatted_address as formatted_postal_address, pa.id as address_id, dd.id as donor_id, pa.invalid as is_invalid
FROM donor dd
LEFT JOIN donor_postal_address_mapping map ON dd.id = map.donor_id
@ -216,7 +216,7 @@ END;
DROP VIEW IF EXISTS UserOperation_postal_address_change;
CREATE VIEW UserOperation_postal_address_change AS
SELECT ledger_entity_id as donor_name, map.preferred as preferred_override, pa.date_encountered as entered_date,
SELECT ledger_entity_id as entity, map.preferred as preferred_override, pa.date_encountered as entered_date,
pa.formatted_address as formatted_postal_address, pa.id as address_id, dd.id as donor_id, pa.invalid as is_invalid
FROM donor dd, donor_postal_address_mapping map, postal_address pa
WHERE dd.id = map.donor_id AND pa.id = map.postal_address_id
@ -224,7 +224,7 @@ CREATE VIEW UserOperation_postal_address_change AS
UNION
SELECT ledger_entity_id as donor_name, map.preferred as preferred_override, pa.date_encountered as entered_date,
SELECT ledger_entity_id as entity, map.preferred as preferred_override, pa.date_encountered as entered_date,
pa.formatted_address as formatted_postal_address, pa.id as address_id, dd.id as donor_id, pa.invalid as is_invalid
FROM donor dd, donor_postal_address_mapping map, postal_address pa
WHERE dd.id = map.donor_id AND pa.id = map.postal_address_id
@ -304,7 +304,7 @@ CREATE TABLE zz__temp_request_configuration_change(
DROP VIEW IF EXISTS UserOperation_fix_tshirt_size_request;
CREATE VIEW UserOperation_fix_tshirt_size_request AS
SELECT donor.ledger_entity_id as donor_name,
SELECT donor.ledger_entity_id as entity,
request_type.type as shirt_requested, request_configuration.description as size_requested,
request.date_requested as request_date, request.notes as note, donor.id as donor_id, request.id as request_id
FROM donor, request_configuration, request, request_type
@ -361,7 +361,7 @@ END;
DROP VIEW IF EXISTS UserOperation_donor_update;
CREATE VIEW UserOperation_donor_update AS
SELECT donor.ledger_entity_id as donor_name, donor.rt_ticket as ticket, donor.display_name as public_name,
SELECT donor.ledger_entity_id as entity, donor.rt_ticket as ticket, donor.display_name as public_name,
donor.public_ack as public_acknowledge, donor.is_supporter as is_sustainer, donor.id as donor_id
FROM donor
ORDER BY donor.ledger_entity_id, donor.id;
@ -371,7 +371,7 @@ CREATE TRIGGER donor_update_insert_new_donor
INSTEAD OF INSERT ON UserOperation_donor_update
BEGIN
INSERT INTO donor(ledger_entity_id, display_name, public_ack, rt_ticket, is_supporter)
VALUES(NEW.donor_name, NEW.public_name, NEW.public_acknowledge, NEW.ticket, 1);
VALUES(NEW.entity, NEW.public_name, NEW.public_acknowledge, NEW.ticket, 1);
END;
DROP TRIGGER IF EXISTS donor_update_display_name;
@ -450,7 +450,7 @@ CREATE VIEW UserQuery_contact_settings AS
DROP VIEW IF EXISTS UserOperation_contact_setting_change;
CREATE VIEW UserOperation_contact_setting_change AS
SELECT dd.ledger_entity_id as donor_name, rt.type as contact_setting, rc.description as setting_requested,
SELECT dd.ledger_entity_id as entity, rt.type as contact_setting, rc.description as setting_requested,
rr.date_requested as request_date, rr.notes as note, dd.id as donor_id, rr.id as request_id
FROM donor dd
LEFT JOIN request rr ON dd.id = rr.donor_id AND rr.request_type_id = 12