fix: Corregir funciones json_agg y json_build_object en PostgreSQL para pre-órdenes y escaneo QR

This commit is contained in:
unknown
2026-10-05 05:18:13 -06:00
parent 96c789edac
commit 7cd5c3b6ab
3 changed files with 19 additions and 4 deletions
+6 -2
View File
@@ -1397,7 +1397,9 @@ app.get('/api/estudiantes/qr/:token', (req, res) => {
const preordenesFormateadas = preordenesPendientes.map(o => ({
...o,
items: JSON.parse(o.items_json || '[]')
items: Array.isArray(o.items_json)
? o.items_json
: (typeof o.items_json === 'string' ? JSON.parse(o.items_json || '[]') : [])
}));
res.json({
@@ -1687,7 +1689,9 @@ app.get('/api/ordenes', (req, res) => {
const ordenes = db.prepare(query).all(...params);
const resultado = ordenes.map(o => ({
...o,
items: JSON.parse(o.items_json || '[]')
items: Array.isArray(o.items_json)
? o.items_json
: (typeof o.items_json === 'string' ? JSON.parse(o.items_json || '[]') : [])
}));
res.json(resultado);