refs #2687 db: use myt to implement
This commit is contained in:
parent
edcd9baca7
commit
a97b3afe98
|
@ -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;
|
||||
|
||||
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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue