refs #2687 db: use myt to implement
gitea/salix/pipeline/pr-dev This commit looks good Details
gitea/salix/pipeline/pr-test This commit looks good Details

This commit is contained in:
Javier Segarra 2024-02-11 20:41:00 +01:00
parent edcd9baca7
commit a97b3afe98
2 changed files with 14 additions and 7 deletions

View File

@ -27,7 +27,7 @@ BEGIN
DECLARE vEvaNotes VARCHAR(255);
DECLARE vDone BOOL;
DECLARE vAuxEntryFk INT;
DECLARE vTx BOOLEAN DEFAULT !@@in_transaction;
DECLARE vTx BOOLEAN DEFAULT @@in_transaction;
DECLARE vRsEntry CURSOR FOR
SELECT e.id
FROM entry e
@ -41,9 +41,10 @@ BEGIN
CALL util.tx_rollback(vTx);
RESIGNAL;
END;
CALL util.tx_start(vTx);
IF !vTx THEN
SET vTx = TRUE;
CALL util.tx_start(vTx);
END IF;
INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`, isDelivered, isReceived, m3, cargoSupplierFk, kg,clonedFrom)
SELECT vDateStart, vDateEnd, vWarehouseInFk, vWarehouseOutFk, vAgencyModeFk, vRef, isDelivered, isReceived, m3,cargoSupplierFk, kg,vTravelFk
FROM travel

View File

@ -19,7 +19,7 @@ describe('Travel cloneWithEntries()', () => {
travelFk: newTravelId
}
}, options);
const newTravel = await models.Travel.findById(travelId);
const newTravel = await models.Travel.findById(travelId, options);
expect(newTravelId).not.toEqual(travelId);
expect(newTravel.ref).toEqual('fifth travel');
@ -27,9 +27,15 @@ describe('Travel cloneWithEntries()', () => {
expect(newTravel.warehouseOutFk).toEqual(warehouseThree);
expect(newTravel.agencyModeFk).toEqual(agencyModeOne);
expect(travelEntries.length).toBeGreaterThan(0);
await models.Entry.destroyAll({
travelFk: newTravelId
}, options);
await models.Travel.destroyById(newTravelId, options);
await tx.rollback();
const travelRemoved = await models.Travel.findById(newTravelId, options);
const travelRemoved = await models.Travel.findById(newTravelId);
const entries = await models.Entry.find();
expect(entries.length).toBeGreaterThan(0);
expect(travelRemoved).toBeNull();
} catch (e) {