fix: refs #7662 get value for proc with select for updates
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-07-25 13:26:45 +02:00
parent 12c34db12c
commit 9e18a208b2
1 changed files with 5 additions and 4 deletions

View File

@ -20,13 +20,14 @@ module.exports = Self => {
if (typeof options == 'object') if (typeof options == 'object')
Object.assign(myOptions, options); Object.assign(myOptions, options);
const randStr = Math.random().toString(36).substring(3);
const result = await Self.rawSql(` const result = await Self.rawSql(`
CALL vn.collection_assign(?, @vCollectionFk); CALL vn.collection_assign(?, @vCollectionFk);
SELECT @vCollectionFk collectionFk SELECT @vCollectionFk ?
`, [userId], myOptions); `, [userId, randStr], myOptions);
// Por si entra en el SELECT FOR UPDATE y retorna un array más // Por si entra en SELECT FOR UPDATE una o varias veces
const collectionFk = result[2]?.[0]?.collectionFk || result[3]?.[0]?.collectionFk; const collectionFk = result.find(item => item[0]?.[randStr] !== undefined)?.[0]?.[randStr];
if (!collectionFk) throw new UserError('There are not picking tickets'); if (!collectionFk) throw new UserError('There are not picking tickets');
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions); await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);