From 4dcc8b02a597eb818d79029aa8a3ee6e6cbdc643 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 9 Jul 2024 10:01:32 +0200 Subject: [PATCH 1/6] feat: refs #7685 delivery coordinates --- .../procedures/address_updateCorordinates.sql | 30 +++++++++++++++++++ .../vn/triggers/delivery_beforeInsert.sql | 12 ++------ .../vn/triggers/delivery_beforeUpdate.sql | 12 ++------ 3 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 db/routines/vn/procedures/address_updateCorordinates.sql diff --git a/db/routines/vn/procedures/address_updateCorordinates.sql b/db/routines/vn/procedures/address_updateCorordinates.sql new file mode 100644 index 000000000..2004cd180 --- /dev/null +++ b/db/routines/vn/procedures/address_updateCorordinates.sql @@ -0,0 +1,30 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`address_updateCorordinates`( + vTicketFk INT, + vLongitude INT, + vLatitude INT) +BEGIN +/** + * Actualiza las coordenadas de una direccion + * + * @param vTicketFk id del ticket + * @param vLongitude longitud de la direccion + * @param vLatitude latitud de la dirrecion + */ + DECLARE vAddressFK INT; + + START TRANSACTION; + + SELECT addressFK INTO vAddressFK + FROM ticket + WHERE id = vTicketFk + FOR UPDATE; + + UPDATE address + SET longitude = vLongitude, + latitude = vLatitude + WHERE id = vAddressFK; + + COMMIT; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/delivery_beforeInsert.sql b/db/routines/vn/triggers/delivery_beforeInsert.sql index 89431c30f..c9679ed13 100644 --- a/db/routines/vn/triggers/delivery_beforeInsert.sql +++ b/db/routines/vn/triggers/delivery_beforeInsert.sql @@ -4,16 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeInsert FOR EACH ROW BEGIN - IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) - THEN - UPDATE address - SET longitude = NEW.longitude, - latitude = NEW.latitude - WHERE id IN ( - SELECT addressFK - FROM ticket - WHERE id = NEW.ticketFk - ); + IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) THEN + CALL address_updateCorordinates(NEW.ticketFk,NEW.longitude,NEW.latitude); END IF; END$$ diff --git a/db/routines/vn/triggers/delivery_beforeUpdate.sql b/db/routines/vn/triggers/delivery_beforeUpdate.sql index 7e6aa7d4c..dda0e9dd2 100644 --- a/db/routines/vn/triggers/delivery_beforeUpdate.sql +++ b/db/routines/vn/triggers/delivery_beforeUpdate.sql @@ -4,16 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeUpdate FOR EACH ROW BEGIN -IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) - THEN - UPDATE address - SET longitude = NEW.longitude, - latitude = NEW.latitude - WHERE id IN ( - SELECT addressFK - FROM ticket - WHERE id = NEW.ticketFk - ); + IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) THEN + CALL address_updateCorordinates(NEW.ticketFk,NEW.longitude,NEW.latitude); END IF; END$$ From b3a98226c082548f1715c861b3f3c44400562404 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 11 Jul 2024 10:23:31 +0200 Subject: [PATCH 2/6] feat: refs #7685 chages required --- ...dateCorordinates.sql => address_updateCoordinates.sql} | 8 ++------ db/routines/vn/triggers/delivery_beforeInsert.sql | 2 +- db/routines/vn/triggers/delivery_beforeUpdate.sql | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) rename db/routines/vn/procedures/{address_updateCorordinates.sql => address_updateCoordinates.sql} (84%) diff --git a/db/routines/vn/procedures/address_updateCorordinates.sql b/db/routines/vn/procedures/address_updateCoordinates.sql similarity index 84% rename from db/routines/vn/procedures/address_updateCorordinates.sql rename to db/routines/vn/procedures/address_updateCoordinates.sql index 2004cd180..0b734e9d7 100644 --- a/db/routines/vn/procedures/address_updateCorordinates.sql +++ b/db/routines/vn/procedures/address_updateCoordinates.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`address_updateCorordinates`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`address_updateCoordinates`( vTicketFk INT, vLongitude INT, vLatitude INT) @@ -12,19 +12,15 @@ BEGIN * @param vLatitude latitud de la dirrecion */ DECLARE vAddressFK INT; - - START TRANSACTION; SELECT addressFK INTO vAddressFK FROM ticket - WHERE id = vTicketFk - FOR UPDATE; + WHERE id = vTicketFk; UPDATE address SET longitude = vLongitude, latitude = vLatitude WHERE id = vAddressFK; - COMMIT; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/delivery_beforeInsert.sql b/db/routines/vn/triggers/delivery_beforeInsert.sql index c9679ed13..241015261 100644 --- a/db/routines/vn/triggers/delivery_beforeInsert.sql +++ b/db/routines/vn/triggers/delivery_beforeInsert.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeInsert BEGIN IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) THEN - CALL address_updateCorordinates(NEW.ticketFk,NEW.longitude,NEW.latitude); + CALL address_updateCoordinates(NEW.ticketFk,NEW.longitude,NEW.latitude); END IF; END$$ diff --git a/db/routines/vn/triggers/delivery_beforeUpdate.sql b/db/routines/vn/triggers/delivery_beforeUpdate.sql index dda0e9dd2..264591951 100644 --- a/db/routines/vn/triggers/delivery_beforeUpdate.sql +++ b/db/routines/vn/triggers/delivery_beforeUpdate.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeUpdate BEGIN IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) THEN - CALL address_updateCorordinates(NEW.ticketFk,NEW.longitude,NEW.latitude); + CALL address_updateCoordinates(NEW.ticketFk,NEW.longitude,NEW.latitude); END IF; END$$ From cb0461b241d60fa1bd872a70c66c1215a5556bf6 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 11 Jul 2024 11:43:19 +0200 Subject: [PATCH 3/6] feat: refs #7685 changes required --- db/routines/vn/procedures/address_updateCoordinates.sql | 9 ++++----- db/routines/vn/triggers/delivery_beforeInsert.sql | 9 +++++---- db/routines/vn/triggers/delivery_beforeUpdate.sql | 9 +++++---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/db/routines/vn/procedures/address_updateCoordinates.sql b/db/routines/vn/procedures/address_updateCoordinates.sql index 0b734e9d7..f36e35894 100644 --- a/db/routines/vn/procedures/address_updateCoordinates.sql +++ b/db/routines/vn/procedures/address_updateCoordinates.sql @@ -5,11 +5,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`address_updateCoord vLatitude INT) BEGIN /** - * Actualiza las coordenadas de una direccion + * Actualiza las coordenadas de una dirección * - * @param vTicketFk id del ticket - * @param vLongitude longitud de la direccion - * @param vLatitude latitud de la dirrecion + * @param vTicketFk Id del ticket + * @param vLongitude Longitud de la dirección + * @param vLatitude Latitud de la dirección */ DECLARE vAddressFK INT; @@ -21,6 +21,5 @@ BEGIN SET longitude = vLongitude, latitude = vLatitude WHERE id = vAddressFK; - END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/delivery_beforeInsert.sql b/db/routines/vn/triggers/delivery_beforeInsert.sql index 241015261..eb4a6f21a 100644 --- a/db/routines/vn/triggers/delivery_beforeInsert.sql +++ b/db/routines/vn/triggers/delivery_beforeInsert.sql @@ -3,10 +3,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeInsert BEFORE INSERT ON `delivery` FOR EACH ROW BEGIN - - IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) THEN - CALL address_updateCoordinates(NEW.ticketFk,NEW.longitude,NEW.latitude); + IF (NEW.longitude IS NOT NULL + AND NEW.latitude IS NOT NULL + AND NEW.ticketFK IS NOT NULL) + THEN + CALL address_updateCoordinates(NEW.ticketFk, NEW.longitude, NEW.latitude); END IF; - END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/delivery_beforeUpdate.sql b/db/routines/vn/triggers/delivery_beforeUpdate.sql index 264591951..6206d4722 100644 --- a/db/routines/vn/triggers/delivery_beforeUpdate.sql +++ b/db/routines/vn/triggers/delivery_beforeUpdate.sql @@ -3,10 +3,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeUpdate BEFORE UPDATE ON `delivery` FOR EACH ROW BEGIN - - IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) THEN - CALL address_updateCoordinates(NEW.ticketFk,NEW.longitude,NEW.latitude); + IF (NEW.longitude IS NOT NULL + AND NEW.latitude IS NOT NULL + AND NEW.ticketFK IS NOT NULL) + THEN + CALL address_updateCoordinates(NEW.ticketFk, NEW.longitude, NEW.latitude); END IF; - END$$ DELIMITER ; From 9b2ebe7bd9825dfcd4c683eabe30be2ca2493782 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 11 Jul 2024 11:52:27 +0200 Subject: [PATCH 4/6] feat: refs #7685 --- db/routines/vn/procedures/address_updateCoordinates.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/address_updateCoordinates.sql b/db/routines/vn/procedures/address_updateCoordinates.sql index f36e35894..bdeb886df 100644 --- a/db/routines/vn/procedures/address_updateCoordinates.sql +++ b/db/routines/vn/procedures/address_updateCoordinates.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`address_updateCoord vLatitude INT) BEGIN /** - * Actualiza las coordenadas de una dirección + * Actualiza las coordenadas de una dirección. * * @param vTicketFk Id del ticket * @param vLongitude Longitud de la dirección From fb1c66633c3a335a767958a953e5243f8af75369 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 11 Jul 2024 11:55:10 +0200 Subject: [PATCH 5/6] feat: refs #7685 --- db/routines/vn/procedures/address_updateCoordinates.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/address_updateCoordinates.sql b/db/routines/vn/procedures/address_updateCoordinates.sql index bdeb886df..950a8ad40 100644 --- a/db/routines/vn/procedures/address_updateCoordinates.sql +++ b/db/routines/vn/procedures/address_updateCoordinates.sql @@ -8,8 +8,8 @@ BEGIN * Actualiza las coordenadas de una dirección. * * @param vTicketFk Id del ticket - * @param vLongitude Longitud de la dirección - * @param vLatitude Latitud de la dirección + * @param vLongitude Longitud de la dirección. + * @param vLatitude Latitud de la dirección. */ DECLARE vAddressFK INT; From c770d17c256c89355ce3bcdc5359fc1be71661df Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 11 Jul 2024 11:57:48 +0200 Subject: [PATCH 6/6] feat: refs #7685 --- db/routines/vn/procedures/address_updateCoordinates.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/address_updateCoordinates.sql b/db/routines/vn/procedures/address_updateCoordinates.sql index 950a8ad40..bdeb886df 100644 --- a/db/routines/vn/procedures/address_updateCoordinates.sql +++ b/db/routines/vn/procedures/address_updateCoordinates.sql @@ -8,8 +8,8 @@ BEGIN * Actualiza las coordenadas de una dirección. * * @param vTicketFk Id del ticket - * @param vLongitude Longitud de la dirección. - * @param vLatitude Latitud de la dirección. + * @param vLongitude Longitud de la dirección + * @param vLatitude Latitud de la dirección */ DECLARE vAddressFK INT;