stop devParentMAC overwrite if specified #1021

This commit is contained in:
jokob-sk
2025-03-23 13:23:39 +11:00
parent 2b61665ee8
commit 8d9a4d23d1

View File

@@ -316,14 +316,16 @@ def update_devices_data_from_scan (db):
FROM CurrentScan FROM CurrentScan
WHERE Devices.devMac = CurrentScan.cur_MAC WHERE Devices.devMac = CurrentScan.cur_MAC
) )
WHERE EXISTS ( WHERE
(devParentPort IS NULL OR devParentPort = "" OR devParentPort = "null")
AND
EXISTS (
SELECT 1 SELECT 1
FROM CurrentScan FROM CurrentScan
WHERE Devices.devMac = CurrentScan.cur_MAC WHERE Devices.devMac = CurrentScan.cur_MAC
AND CurrentScan.cur_Port IS NOT NULL AND CurrentScan.cur_Port IS NOT NULL
AND CurrentScan.cur_Port NOT IN ("", "null") AND CurrentScan.cur_Port NOT IN ("", "null")
) )
AND (devParentPort IS NULL OR devParentPort = "" OR devParentPort = "null")
""") """)
# Update only devices with empty or NULL devParentMAC # Update only devices with empty or NULL devParentMAC
@@ -334,13 +336,15 @@ def update_devices_data_from_scan (db):
FROM CurrentScan FROM CurrentScan
WHERE Devices.devMac = CurrentScan.cur_MAC WHERE Devices.devMac = CurrentScan.cur_MAC
) )
WHERE EXISTS ( WHERE
SELECT 1 (devParentMAC IS NULL OR devParentMAC IN ("", "null", "(unknown)", "(Unknown)"))
FROM CurrentScan AND
WHERE Devices.devMac = CurrentScan.cur_MAC EXISTS (
AND CurrentScan.cur_NetworkNodeMAC IS NOT NULL AND CurrentScan.cur_NetworkNodeMAC NOT IN ("", "null") SELECT 1
) FROM CurrentScan
AND (devParentMAC IS NULL OR devParentMAC = "" OR devParentMAC = "null") WHERE Devices.devMac = CurrentScan.cur_MAC
AND CurrentScan.cur_NetworkNodeMAC IS NOT NULL AND CurrentScan.cur_NetworkNodeMAC NOT IN ("", "null")
)
""") """)
# Update only devices with empty or NULL devSite # Update only devices with empty or NULL devSite