mirror of https://github.com/zulip/zulip.git
migrations: Enforce evaluation order in 0306 WHERE clause.
Depending on PostgreSQL’s query plan, it was possible for the value condition to be evaluated before the field_type condition was checked, leading to errors like psycopg2.errors.InvalidDatetimeFormat: invalid value "stri" for "YYYY" DETAIL: Value must be an integer. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
a42f7a67e1
commit
69890f36b1
|
@ -20,7 +20,10 @@ class Migration(migrations.Migration):
|
|||
FROM zerver_customprofilefield AS f
|
||||
WHERE f.id = field_id
|
||||
AND f.field_type = 4
|
||||
AND value <> to_char(to_date(value, 'YYYY-MM-DD'), 'YYYY-MM-DD');
|
||||
AND CASE
|
||||
WHEN f.field_type = 4
|
||||
THEN value <> to_char(to_date(value, 'YYYY-MM-DD'), 'YYYY-MM-DD')
|
||||
END;
|
||||
""",
|
||||
reverse_sql="",
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue