fix: UUID cast in datasheet routes — use slug-first lookup
This commit is contained in:
parent
24a9eba9ce
commit
1f8176bf8e
@ -26,7 +26,7 @@ datasheetRouter.get("/transceiver/:id", async (req, res) => {
|
|||||||
FROM transceivers t
|
FROM transceivers t
|
||||||
LEFT JOIN vendors v ON t.vendor_id = v.id
|
LEFT JOIN vendors v ON t.vendor_id = v.id
|
||||||
LEFT JOIN standards s ON t.standard_id = s.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]
|
[id]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ datasheetRouter.get("/switch/:id", async (req, res) => {
|
|||||||
const sw = await pool.query(
|
const sw = await pool.query(
|
||||||
`SELECT sw.*, v.name AS vendor_name, v.website AS vendor_website
|
`SELECT sw.*, v.name AS vendor_name, v.website AS vendor_website
|
||||||
FROM switches sw JOIN vendors v ON sw.vendor_id = v.id
|
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]
|
[id]
|
||||||
);
|
);
|
||||||
if (!sw.rows[0]) return res.status(404).json({ error: "Switch not found" });
|
if (!sw.rows[0]) return res.status(404).json({ error: "Switch not found" });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user