Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#14248 closed (invalid)

Date and DateTime fields, auto_now_add and PostgreSQL

Reported by: zloy.alu@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

PostgreSQL allows using function "now()", "current_date()", "current_time()" in columns. Why does you not use it?

Change History (3)

comment:1 Changed 6 years ago by Luke Plant

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: invalid
Status: newclosed

Some reasons:

  1. There is no advantage (at least none stated) in using this functionality.
  2. It would introduce differences between how it works with Postgres and other databases, which would only complicate things.
  3. It would require additional code paths just to detect which DB backend we are running.

Thanks!

comment:2 Changed 6 years ago by Malcolm Tredinnick

For future reference (in case we ever revisit this): although the functions provided by PostgreSQL are non-standard and not supported across all backends, PostgreSQL, along with all SQL-compliant dbs, provide constant-like functions CURRENT_TIMESTAMP, CURRENT_DATE, etc, that provide the same functionality. What I don't know at the moment (and aren't motivated to check right this minute) is if there are any backends we support which don't implement this part of the SQL standard.

Note, however, that this doesn't make this bug a laydown "accept". There are advantages to implementing auto_now and auto_now_add in Python -- it allows them to be overridden as part of the saving process (for timezone adjustments in some funky situation, for example).

comment:3 Changed 5 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

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