fix: UUID cast in datasheet routes — use slug-first lookup
This commit is contained in:
parent
3a6cbc475d
commit
a53c00b8c4
@ -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" });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user