Skip to content

Commit 8d9a4d2

Browse files
author
jokob-sk
committed
stop devParentMAC overwrite if specified #1021
1 parent 2b61665 commit 8d9a4d2

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

server/scan/device_handling.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,16 @@ def update_devices_data_from_scan (db):
316316
FROM CurrentScan
317317
WHERE Devices.devMac = CurrentScan.cur_MAC
318318
)
319-
WHERE EXISTS (
319+
WHERE
320+
(devParentPort IS NULL OR devParentPort = "" OR devParentPort = "null")
321+
AND
322+
EXISTS (
320323
SELECT 1
321324
FROM CurrentScan
322325
WHERE Devices.devMac = CurrentScan.cur_MAC
323326
AND CurrentScan.cur_Port IS NOT NULL
324327
AND CurrentScan.cur_Port NOT IN ("", "null")
325328
)
326-
AND (devParentPort IS NULL OR devParentPort = "" OR devParentPort = "null")
327329
""")
328330

329331
# Update only devices with empty or NULL devParentMAC
@@ -334,13 +336,15 @@ def update_devices_data_from_scan (db):
334336
FROM CurrentScan
335337
WHERE Devices.devMac = CurrentScan.cur_MAC
336338
)
337-
WHERE EXISTS (
338-
SELECT 1
339-
FROM CurrentScan
340-
WHERE Devices.devMac = CurrentScan.cur_MAC
341-
AND CurrentScan.cur_NetworkNodeMAC IS NOT NULL AND CurrentScan.cur_NetworkNodeMAC NOT IN ("", "null")
342-
)
343-
AND (devParentMAC IS NULL OR devParentMAC = "" OR devParentMAC = "null")
339+
WHERE
340+
(devParentMAC IS NULL OR devParentMAC IN ("", "null", "(unknown)", "(Unknown)"))
341+
AND
342+
EXISTS (
343+
SELECT 1
344+
FROM CurrentScan
345+
WHERE Devices.devMac = CurrentScan.cur_MAC
346+
AND CurrentScan.cur_NetworkNodeMAC IS NOT NULL AND CurrentScan.cur_NetworkNodeMAC NOT IN ("", "null")
347+
)
344348
""")
345349

346350
# Update only devices with empty or NULL devSite

0 commit comments

Comments
 (0)