mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
validator: Reject ISO 8601 dates missing leading zeros.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
90354c4e5f
commit
2ab0b3d4fc
27
zerver/migrations/0306_custom_profile_field_date_format.py
Normal file
27
zerver/migrations/0306_custom_profile_field_date_format.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
"""
|
||||
We previously accepted invalid ISO 8601 dates like 1909-3-5 for
|
||||
date values of custom profile fields. Correct them by adding the
|
||||
missing leading zeros: 1909-03-05.
|
||||
"""
|
||||
|
||||
dependencies = [
|
||||
("zerver", "0305_realm_deactivated_redirect"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunSQL(
|
||||
sql="""\
|
||||
UPDATE zerver_customprofilefieldvalue
|
||||
SET value = to_char(to_date(value, 'YYYY-MM-DD'), 'YYYY-MM-DD')
|
||||
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');
|
||||
""",
|
||||
reverse_sql="",
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user