Code

Opened 7 years ago

Closed 7 years ago

#3044 closed enhancement (invalid)

Add datetime check to django.db.backends.util date/time functions

Reported by: cephelo@… Owned by: adrian
Component: Database layer (models, ORM) Version: master
Severity: minor Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Currently if you pass datetime types to the typecast_time and typecast_timestamp functions, they throw TypeErrors. A simple change enhances the functionality of these functions (attached a patch) in that if you pass a date/time/datetime, it simply returns it. Passing a different type to a function of the wrong type still returns raises exceptions as it does now.

Patch is against changeset:4086.

Attachments (1)

util.py.diff (993 bytes) - added by cephelo@… 7 years ago.
django\db\backends\util.py patch

Download all attachments as: .zip

Change History (3)

Changed 7 years ago by cephelo@…

django\db\backends\util.py patch

comment:1 Changed 7 years ago by mtredinnick

Why is this needed? Those conversion functions are only intended for use by database backends and if a backend can do the conversion to Python datetime types natively, it doesn't need to call the conversion functions. Is there are backend that does not behave this way?

comment:2 Changed 7 years ago by cephelo@…

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

This isn't needed anymore, no. At the time, MySQLdb for Win32 was doing some wonky things, but I think it has evened out. I haven't used the patch since shortly after I posted it.

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.