Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#12524 closed (fixed)

Bad formatting on dates in JSON serializer causes ValidationError in loaddata

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

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 Gabriel Farrell 14 years ago.
Fill zeros on string-formatted years
safe_year.2.diff (1.8 KB ) - added by Gabriel Farrell 14 years ago.
now with test

Download all attachments as: .zip

Change History (7)

by Gabriel Farrell, 14 years ago

Attachment: safe_year.diff added

Fill zeros on string-formatted years

comment:1 by Eric Holscher, 14 years ago

milestone: 1.2
Needs tests: set
Triage Stage: UnreviewedAccepted

Could use a test case.

comment:2 by Gabriel Farrell, 14 years ago

Needs tests: unset

by Gabriel Farrell, 14 years ago

Attachment: safe_year.2.diff added

now with test

comment:3 by Russell Keith-Magee, 14 years ago

Resolution: fixed
Status: newclosed

(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 by Russell Keith-Magee, 14 years ago

(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 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

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