Code

Opened 8 years ago

Closed 4 years ago

#2871 closed defect (worksforme)

DateTime fields are not checked when updating object

Reported by: mikhail@… Owned by: nobody
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I created an object, but after that I updated it in Django admin and edited DateTimeField to 2006-02-31 00:00:00. In database there is 0000-00-00 00:00:00, and I get an exception when refering to object:

ValueError at /games/game/1/
year is out of range
Request Method: 	POST
Request URL: 	http://localhost:8000/games/game/1/
Exception Type: 	ValueError
Exception Value: 	year is out of range
Exception Location: 	/usr/lib/python2.4/site-packages/MySQLdb/connections.py in defaulterrorhandler, line 33

Please verify that the date is correct before inserting/updating. See function time.strptime in Python.

Also IntegerField (and PositiveIntegerField) is not checked but simply substituted by database to 231-1 if larger during inserting/updating.

Attachments (0)

Change History (3)

comment:1 Changed 7 years ago by SmileyChris

  • Component changed from Validators to Admin interface
  • Triage Stage changed from Unreviewed to Accepted

This should be caught by validation. Probably this will fix itself with the newforms-branch

comment:2 Changed 7 years ago by ubernostrum

Yeah, this is something we need to catch at the form validation stage. Might be worth working up a torture test of cases where MySQL will corrupt incoming data without raising an error, and running newforms through it.

comment:3 Changed 4 years ago by stephanhoyer

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

I just tested it, form was validated correctly.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.