Code

Opened 7 years ago

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

Download all attachments as: .zip

Change History (5)

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

comment:1 Changed 7 years ago by ramiro

  • 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 7 years ago by David Paccoud <dpaccoud@…>

Updated version

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

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

comment:3 Changed 7 years ago by adrian

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

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.