Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#13414 closed (fixed)

QuerySet API ref wrong sql equivalent in __year lookup example

Reported by: idle sign 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 sign 6 years ago.
document patch (Git-format)

Download all attachments as: .zip

Change History (7)

comment:1 Changed 6 years ago by Russell Keith-Magee

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

Changed 6 years ago by idle sign

Attachment: patch.diff added

document patch (Git-format)

comment:2 Changed 6 years ago by Derek Willis

Has patch: set

comment:3 Changed 6 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin
Version: 1.2-betaSVN

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 6 years ago by idle sign

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 6 years ago by Luke Plant

Resolution: fixed
Status: newclosed

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

Thanks to idle for report and patch

comment:6 Changed 6 years ago by Luke Plant

(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