TEST: field locking test fixes 6

Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
jokob-sk
2026-01-29 10:02:09 +11:00
parent 46d866b5ee
commit 7faaa630a1
2 changed files with 24 additions and 100 deletions

View File

@@ -360,11 +360,14 @@ def update_ipv4_ipv6(db):
if records_to_update:
# We use COALESCE(?, Column) so that if the first arg is NULL,
# it keeps the current value of the column.
mylog("none", f"[Update Devices] Updated records_to_update: {records_to_update}")
sql.executemany(
"""
UPDATE Devices
SET devPrimaryIPv4 = COALESCE(?, devPrimaryIPv4),
devPrimaryIPv6 = COALESCE(?, devPrimaryIPv6)
SET devPrimaryIPv4 = COALESCE(?, NULLIF(devPrimaryIPv4, '')),
devPrimaryIPv6 = COALESCE(?, NULLIF(devPrimaryIPv6, ''))
WHERE devMac = ?
""",
records_to_update,