Skip to content

Commit f78aa80

Browse files
committed
fix: treat nulls as empty arrays for list_of_* comparion
1 parent fd8137b commit f78aa80

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

ayon_server/sqlfilter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ def build_condition(c: QueryCondition, **kwargs) -> str:
232232
else:
233233
safe_value = json.dumps(value).replace("'", "''")
234234
safe_value = f"'{safe_value}'::jsonb"
235-
logger.trace(f"Safe value of {type(value)} {value}: {safe_value}")
236235

237236
else:
238237
raise ValueError(f"Invalid path: {path}")
@@ -274,7 +273,8 @@ def build_condition(c: QueryCondition, **kwargs) -> str:
274273
if len(value) == 0:
275274
if operator == "eq":
276275
if len(path) > 1:
277-
return f"NOT EXISTS (SELECT 1 FROM jsonb_array_elements({column}))"
276+
# Treat nulls in attribues as empty arrays
277+
return f"((NOT EXISTS (SELECT 1 FROM jsonb_array_elements({column}))) OR {column} IS NULL)" # noqa 501
278278
return f"array_length({column}, 1) IS NULL"
279279

280280
if operator == "ne":

0 commit comments

Comments
 (0)