Opened 14 years ago

Closed 14 years ago

Last modified 14 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: dev
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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 14 years ago.
document patch (Git-format)

Download all attachments as: .zip

Change History (7)

comment:1 by Russell Keith-Magee, 14 years ago

Triage Stage: UnreviewedAccepted

by idle sign, 14 years ago

Attachment: patch.diff added

document patch (Git-format)

comment:2 by Derek Willis, 14 years ago

Has patch: set

comment:3 by Tim Graham, 14 years ago

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.

in reply to:  3 comment:4 by idle sign, 14 years ago

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

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

(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