fix(striker-ui-api): simply query table alias in GET host connection

main^2
Tsu-ba-me 7 months ago
parent 850a55151f
commit aaa0a9cfea
  1. 36
      striker-ui-api/src/lib/request_handlers/host/getHostConnection.ts

@ -55,7 +55,7 @@ export const getHostConnection = buildGetRequestHandler(
let rawDatabaseData: AnvilDataDatabaseHash; let rawDatabaseData: AnvilDataDatabaseHash;
const hostUUIDField = 'ip_add.ip_address_host_uuid'; const hostUUIDField = 'a.ip_address_host_uuid';
const localHostUUID: string = getLocalHostUUID(); const localHostUUID: string = getLocalHostUUID();
const { after: condHostUUIDs, before: beforeBuildIDCond } = const { after: condHostUUIDs, before: beforeBuildIDCond } =
buildUnknownIDCondition(rawHostUUIDs, hostUUIDField, { buildUnknownIDCondition(rawHostUUIDs, hostUUIDField, {
@ -117,29 +117,29 @@ export const getHostConnection = buildGetRequestHandler(
} }
return `SELECT return `SELECT
ip_add.ip_address_uuid, a.ip_address_uuid,
ip_add.ip_address_host_uuid, a.ip_address_host_uuid,
ip_add.ip_address_address, a.ip_address_address,
CASE CASE
WHEN ip_add.ip_address_on_type = 'interface' WHEN a.ip_address_on_type = 'interface'
THEN ( THEN (
CASE CASE
WHEN net_int.network_interface_name ~* '.*n\\d+_link\\d+' WHEN b.network_interface_name ~* '.*n\\d+_link\\d+'
THEN net_int.network_interface_name THEN b.network_interface_name
ELSE net_int.network_interface_device ELSE b.network_interface_device
END END
) )
ELSE bon.bond_active_interface ELSE d.bond_active_interface
END AS network_name END AS network_name
FROM ip_addresses AS ip_add FROM ip_addresses AS a
LEFT JOIN network_interfaces AS net_int LEFT JOIN network_interfaces AS b
ON ip_add.ip_address_on_uuid = net_int.network_interface_uuid ON a.ip_address_on_uuid = b.network_interface_uuid
LEFT JOIN bridges AS bri LEFT JOIN bridges AS c
ON ip_add.ip_address_on_uuid = bri.bridge_uuid ON a.ip_address_on_uuid = c.bridge_uuid
LEFT JOIN bonds AS bon LEFT JOIN bonds AS d
ON bri.bridge_uuid = bon.bond_bridge_uuid ON c.bridge_uuid = d.bond_bridge_uuid
OR ip_add.ip_address_on_uuid = bon.bond_uuid OR a.ip_address_on_uuid = d.bond_uuid
WHERE ${condHostUUIDs} WHERE ${condHostUUIDs}
AND ip_add.ip_address_note != 'DELETED';`; AND a.ip_address_note != 'DELETED';`;
}, },
); );

Loading…
Cancel
Save