refs #5066 remake sql without ROW_ORDER

This commit is contained in:
Carlos Satorres 2023-05-30 12:21:44 +02:00
parent 3423ce612c
commit 0661bf8fa9
1 changed files with 6 additions and 9 deletions

View File

@ -17,14 +17,11 @@ module.exports = Self => {
});
Self.sorted = async warehouseFk => {
const vehicles = await Self.rawSql(`
SELECT ROW_NUMBER() OVER (ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate) AS 'order',
v.id,
v.warehouseFk,
CONCAT(v.numberPlate, ' - ', w.name) as description
FROM vehicle v
JOIN warehouse w ON w.id = v.warehouseFk
ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate ASC`, [warehouseFk, warehouseFk]);
return vehicles;
return Self.rawSql(`
SELECT v.id, v.warehouseFk, CONCAT(v.numberPlate, ' - ', w.name) as description
FROM vehicle v
JOIN warehouse w ON w.id = v.warehouseFk
ORDER BY v.warehouseFk = ? DESC, w.id, v.numberPlate ASC;
`, [warehouseFk]);
};
};