From a64f9b74ec9d6d69231d62caa7dfbfa642890764 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 18 Nov 2024 10:52:41 +0100 Subject: [PATCH] feat: refs #8057 Requested changes --- db/versions/11346-yellowPhormium/00-address.sql | 4 ++-- db/versions/11346-yellowPhormium/01-client.sql | 4 ++-- db/versions/11346-yellowPhormium/02-supplier.sql | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql index 8e1315072..a8ee88b94 100644 --- a/db/versions/11346-yellowPhormium/00-address.sql +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -10,9 +10,9 @@ CREATE OR REPLACE TEMPORARY TABLE tAddressGeo FROM address a JOIN town t ON t.provinceFk = a.provinceFk JOIN postCode p ON p.townFk = t.id - AND p.`code` = a.postalCode GROUP BY a.id - ORDER BY (a.city SOUNDS LIKE t.`name`) DESC; + ORDER BY (a.city SOUNDS LIKE t.`name`) DESC, + (p.code = a.postalCode) DESC; UPDATE address a JOIN tAddressGeo tag ON tag.id = a.id diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql index 932b28ef5..e1294c30e 100644 --- a/db/versions/11346-yellowPhormium/01-client.sql +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -13,9 +13,9 @@ CREATE OR REPLACE TEMPORARY TABLE tClientGeo FROM client c JOIN town t ON t.provinceFk = c.provinceFk JOIN postCode p ON p.townFk = t.id - AND p.`code` = c.postcode GROUP BY c.id - ORDER BY (c.city SOUNDS LIKE t.`name`) DESC; + ORDER BY (c.city SOUNDS LIKE t.`name`) DESC, + (p.code = c.postcode) DESC; UPDATE client c JOIN tClientGeo tcg ON tcg.id = c.id diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index b3e25bd7e..57cdefaea 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -12,9 +12,11 @@ CREATE OR REPLACE TEMPORARY TABLE tSupplierGeo FROM supplier s JOIN town t ON t.provinceFk = s.provinceFk JOIN postCode p ON p.townFk = t.id - AND p.`code` = s.postCode + LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id GROUP BY s.id - ORDER BY (s.city SOUNDS LIKE t.`name`) DESC; + ORDER BY (s.city SOUNDS LIKE t.`name`) DESC, + (p.code = s.postCode) DESC, + (p.code = sad.postalCode) DESC; UPDATE supplier s JOIN tSupplierGeo tsg ON tsg.id = s.id