Opened 6 years ago

Closed 5 years ago

Last modified 4 years ago

#12524 closed (fixed)

Bad formatting on dates in JSON serializer causes ValidationError in loaddata

Reported by: gsf Owned by: nobody
Component: Core (Serialization) Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Using SQLite I saw the following error when doing a loaddata on a fixture I had just dumped out:

ValidationError: [u'Enter a valid date/time in YYYY-MM-DD HH:MM[:ss[.uuuuuu]] format.']

Some poking around revealed some dates in my database were set to "0001-01-01", but in the fixture they had been serialized as " 1-01-01". The attached patch to the datetime_safe util fixed the issue, allowing me to load the data back in, weird dates and all.

Attachments (2)

safe_year.diff (415 bytes) - added by gsf 6 years ago.
Fill zeros on string-formatted years
safe_year.2.diff (1.8 KB) - added by gsf 5 years ago.
now with test

Download all attachments as: .zip

Change History (7)

Changed 6 years ago by gsf

Fill zeros on string-formatted years

comment:1 Changed 5 years ago by ericholscher

  • milestone set to 1.2
  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Could use a test case.

comment:2 Changed 5 years ago by gsf

  • Needs tests unset

Changed 5 years ago by gsf

now with test

comment:3 Changed 5 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [12423]) Fixed #12524 -- Clarified handling of pre-1000AD dates in datetime_safe (and thus, the serializers). Patch includes moving the datetime_safe tests into the utils regressiontests module. Thanks to gsf for the report and initial patch.

comment:4 Changed 5 years ago by russellm

(In [12424]) [1.1.X] Fixed #12524 -- Clarified handling of pre-1000AD dates in datetime_safe (and thus, the serializers). Patch includes moving the datetime_safe tests into the utils regressiontests module. Thanks to gsf for the report and initial patch.

Backport of r12423 from trunk.

comment:5 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top