fix: UUID cast in datasheet routes — use slug-first lookup

This commit is contained in:
Rene Fichtmueller 2026-03-31 08:58:26 +02:00
parent 24a9eba9ce
commit 1f8176bf8e

View File

@ -26,7 +26,7 @@ datasheetRouter.get("/transceiver/:id", async (req, res) => {
FROM transceivers t
LEFT JOIN vendors v ON t.vendor_id = v.id
LEFT JOIN standards s ON t.standard_id = s.id
WHERE t.id = $1::text::uuid OR t.slug = $1`,
WHERE t.slug = $1 OR t.id::text = $1`,
[id]
);
@ -158,7 +158,7 @@ datasheetRouter.get("/switch/:id", async (req, res) => {
const sw = await pool.query(
`SELECT sw.*, v.name AS vendor_name, v.website AS vendor_website
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
WHERE sw.id = $1::text::uuid OR sw.model = $1`,
WHERE sw.model = $1 OR sw.id::text = $1`,
[id]
);
if (!sw.rows[0]) return res.status(404).json({ error: "Switch not found" });