datalite icon indicating copy to clipboard operation
datalite copied to clipboard

BUG: fetch_equals crashes if there are no rows to return

Open CHerSun opened this issue 3 years ago • 0 comments

Lines in fetch_equals:

        cur.execute(f"SELECT * FROM {table_name} WHERE {field} = ?;", (value, ))
        obj_id, *field_values = list(cur.fetchone())

crash execution due to None being returned from cur.fetchone() if there are no rows.

A fix could be:

        row = cur.fetchone()
        if not row:
            return None
        obj_id, *field_values = list(row)

CHerSun avatar Aug 11 '22 14:08 CHerSun