From 46ad45bdb9ec5e39304b888639f1deeb834a9457 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Tue, 11 Oct 2022 17:36:14 +1100 Subject: [PATCH] thrimshim: Don't 500 if MODIFIED video doesn't contain some fields Missing fields _should_ be interpreted as "don't update these" but we weren't doing that. --- thrimshim/thrimshim/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/thrimshim/thrimshim/main.py b/thrimshim/thrimshim/main.py index 6d72ee3..67b2679 100644 --- a/thrimshim/thrimshim/main.py +++ b/thrimshim/thrimshim/main.py @@ -346,7 +346,7 @@ def update_row(ident, editor=None): if new_row['state'] == 'MODIFIED': # Modifying published rows is more limited, we ignore all other fields. for column in set(modifiable_columns) & set(non_null_columns): - if new_row[column] is None: + if new_row.get(column) is None: missing.append(column) if missing: return 'Fields {} must be non-null for modified video'.format(', '.join(missing)), 400 @@ -357,7 +357,7 @@ def update_row(ident, editor=None): """).format(sql.SQL(", ").join( sql.SQL("{} = {}").format( sql.Identifier(column), database.get_column_placeholder(column), - ) for column in modifiable_columns + ) for column in set(modifiable_columns) & set(new_row) )) result = database.query(conn, build_query, id=ident, **new_row) if result.rowcount != 1: