Opened 9 years ago

Closed 9 years ago

#5409 closed (fixed)

Logic error in the db-api documentation

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

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@…> 9 years ago.
logic-error.2.diff (479 bytes) - added by David Paccoud <dpaccoud@…> 9 years ago.
Updated version

Download all attachments as: .zip

Change History (5)

Changed 9 years ago by David Paccoud <dpaccoud@…>

Attachment: logic-error.diff added

comment:1 Changed 9 years ago by Ramiro Morales

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

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”"

Changed 9 years ago by David Paccoud <dpaccoud@…>

Attachment: logic-error.2.diff added

Updated version

comment:2 Changed 9 years ago by David Paccoud <dpaccoud@…>

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

comment:3 Changed 9 years ago by Adrian Holovaty

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