feat: #6382 chekCodeFormat #2351

Merged
jgallego merged 6 commits from 6382-regularizar-Shelving-Parking into dev 2024-05-06 07:46:10 +00:00
3 changed files with 24 additions and 32 deletions
Showing only changes of commit 7d3870e4a1 - Show all commits

View File

@ -23,16 +23,6 @@ BEGIN
SET vPacking = COALESCE(vPacking, GREATEST(vn.itemPacking(vBarcode,vWarehouseFk), 1));
SET vQuantity = vQuantity * vPacking;
IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
INSERT IGNORE INTO parking(code) VALUES(vShelvingFk);
INSERT INTO shelving(code, parkingFk)
SELECT vShelvingFk, id
FROM parking
WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci;
END IF;
IF (SELECT COUNT(*) FROM itemShelving
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
AND itemFk = vItemFk

View File

@ -1,4 +1,7 @@
ALTER TABLE vn.parking
ADD CONSTRAINT chkParkingCodeFormat CHECK (CHAR_LENGTH(code) > 4 AND code LIKE '%-%');
guillermo marked this conversation as resolved
Review

Gasta millor LENGTH()

Gasta millor LENGTH()
Review

perque?
Si se espera que code contenga caracteres que podrían ser multibyte y solo importa el conteo de caracteres visibles, se debería preferir CHAR_LENGTH. Por otro lado, si se quiere asegurar una restricción basada en el tamaño en bytes de la cadena, entonces se debería usar LENGTH

perque? Si se espera que code contenga caracteres que podrían ser multibyte y solo importa el conteo de caracteres visibles, se debería preferir CHAR_LENGTH. Por otro lado, si se quiere asegurar una restricción basada en el tamaño en bytes de la cadena, entonces se debería usar LENGTH
ALTER TABLE vn.parking MODIFY COLUMN sectorFk int(11) NOT NULL;
ALTER TABLE vn.shelving
ADD CONSTRAINT chkShelvingCodeFormat CHECK (CHAR_LENGTH(code) <= 4 AND code NOT LIKE '%-%');

View File

@ -1,7 +1,6 @@
const {models} = require('vn-loopback/server/server');
const LoopBackContext = require('loopback-context');
// #6276
describe('ItemShelving upsertItem()', () => {
const warehouseFk = 1;
let ctx;
@ -31,7 +30,7 @@ describe('ItemShelving upsertItem()', () => {
});
it('should add two new records', async() => {
const shelvingFk = 'ZPP';
const shelvingFk = 'GVC';
const items = [1, 1, 1, 2];
await models.ItemShelving.upsertItem(ctx, shelvingFk, items, warehouseFk, options);