fix: replace all :: type casts with CAST() in SQLAlchemy text() calls

SQLAlchemy's text() interprets :name::type as two named parameters.
Fixes syntax errors in link discovery, signal history, and SNMP profile
CRUD that caused 500 errors at runtime.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jason Staack
2026-03-21 23:59:20 -05:00
parent 2fff669cc3
commit e152c741e5
3 changed files with 6 additions and 6 deletions

View File

@@ -106,8 +106,8 @@ async def on_wireless_registration_for_links(msg) -> None:
(gen_random_uuid(), :ap_device_id, :cpe_device_id, :tenant_id,
:interface, :client_mac, :signal_strength, :tx_ccq, :tx_rate,
:rx_rate,
CASE WHEN :signal_strength::int IS NULL THEN 'active'
WHEN :signal_strength::int < :degraded_threshold THEN 'degraded'
CASE WHEN CAST(:signal_strength AS int) IS NULL THEN 'active'
WHEN CAST(:signal_strength AS int) < :degraded_threshold THEN 'degraded'
ELSE 'active' END,
0, NOW(), NOW(), NOW())
ON CONFLICT (ap_device_id, cpe_device_id) DO UPDATE SET
@@ -152,7 +152,7 @@ async def on_wireless_registration_for_links(msg) -> None:
WHERE ap_device_id = :ap_device_id
AND tenant_id = :tenant_id
AND cpe_device_id NOT IN (
SELECT unnest(:seen_cpe_ids::uuid[])
SELECT unnest(CAST(:seen_cpe_ids AS uuid[]))
)
AND state NOT IN ('down', 'stale')
"""),

View File

@@ -51,7 +51,7 @@ async def get_signal_history(
WHERE wr.mac_address = :mac_address
AND wr.device_id = :device_id
AND wr.tenant_id = :tenant_id
AND wr.time > now() - :lookback::interval
AND wr.time > now() - CAST(:lookback AS interval)
AND wr.signal_strength IS NOT NULL
GROUP BY bucket
ORDER BY bucket