Opened 17 years ago

Closed 17 years ago

#5409 closed (fixed)

Logic error in the db-api documentation

Reported by: David Paccoud <dpaccoud@…> Owned by: nobody
Component: Documentation Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

in http://www.djangoproject.com/documentation/db-api/#exclude-kwargs

This example excludes all entries whose pub_date is later than 2005-1-3 AND whose headline is NOT “Hello”
should read:
This example excludes all entries whose pub_date is later than 2005-1-3 OR whose headline is NOT “Hello”

That is because "select not x and not y" is equivalent to "select not (x or y)" and, therefore, "exclude x or y"

Attachments (2)

logic-error.diff (483 bytes ) - added by David Paccoud <dpaccoud@…> 17 years ago.
logic-error.2.diff (479 bytes ) - added by David Paccoud <dpaccoud@…> 17 years ago.
Updated version

Download all attachments as: .zip

Change History (5)

by David Paccoud <dpaccoud@…>, 17 years ago

Attachment: logic-error.diff added

comment:1 by Ramiro Morales, 17 years ago

David is talking about the

Entry.objects.exclude(pub_date__gt=datetime.date(2005, 1, 3)).exclude(headline='Hello')

example. But the sentence he suggests is also wrong, after applying the De Morgan's law as he rightly suggests it should read:

"This example excludes all entries whose pub_date is later than 2005-1-3 OR whose headline is “Hello”"

by David Paccoud <dpaccoud@…>, 17 years ago

Attachment: logic-error.2.diff added

Updated version

comment:2 by David Paccoud <dpaccoud@…>, 17 years ago

Thanks ramiro, you are absolutely right.
I have updated the patch.

comment:3 by Adrian Holovaty, 17 years ago

Resolution: fixed
Status: newclosed

(In [6126]) Fixed #5409 -- Fixed logic error in docs/db-api.txt. Thanks, David Paccoud

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