Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#13414 closed (fixed)

QuerySet API ref wrong sql equivalent in __year lookup example

Reported by: idle Owned by: nobody
Component: Documentation Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

In http://docs.djangoproject.com/en/dev/ref/models/querysets/#year it is said that sql equivalent for

Entry.objects.filter(pub_date__year=2005)

is

SELECT ... WHERE EXTRACT('year' FROM pub_date) = '2005';

but according to current code it should rather be

SELECT ... WHERE pub_date BETWEEN '2005-01-01' AND '2005-12-31 23:59:59.999999';

Attachments (1)

patch.diff (768 bytes) - added by idle 5 years ago.
document patch (Git-format)

Download all attachments as: .zip

Change History (7)

comment:1 Changed 5 years ago by russellm

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

Changed 5 years ago by idle

document patch (Git-format)

comment:2 Changed 5 years ago by dwillis

  • Has patch set

comment:3 follow-up: Changed 5 years ago by timo

  • Triage Stage changed from Accepted to Ready for checkin
  • Version changed from 1.2-beta to SVN

When I tried this out (on postgres), the query was actually:

SELECT ... WHERE pub_date BETWEEN '2005-01-01 00:00:00' AND '2005-12-31 23:59:59.999999';

(00:00:00 doesn't appear in the patch), but otherwise this looks good to go.

comment:4 in reply to: ↑ 3 Changed 5 years ago by idle

Replying to timo:

When I tried this out (on postgres), the query was actually:

SQL in the patch was from MySQL. The reason is a backend, I want to believe :)

comment:5 Changed 5 years ago by lukeplant

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

(In [13692]) Fixed #13414 - QuerySet API ref wrong sql equivalent in year lookup example

Thanks to idle for report and patch

comment:6 Changed 5 years ago by lukeplant

(In [13693]) [1.2.X] Fixed #13414 - QuerySet API ref wrong sql equivalent in year lookup example

Thanks to idle for report and patch

Backport of [13690] from trunk.

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