Django

Code

Ticket #5409 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

Logic error in the db-api documentation

Reported by: David Paccoud <dpaccoud@gmail.com> Assigned to: nobody
Milestone: Component: Documentation
Version: SVN Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

logic-error.diff (483 bytes) - added by David Paccoud <dpaccoud@gmail.com> on 09/12/07 12:18:19.
logic-error.2.diff (479 bytes) - added by David Paccoud <dpaccoud@gmail.com> on 09/12/07 16:27:25.
Updated version

Change History

09/12/07 12:18:19 changed by David Paccoud <dpaccoud@gmail.com>

  • attachment logic-error.diff added.

09/12/07 15:14:34 changed by ramiro

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

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

09/12/07 16:27:25 changed by David Paccoud <dpaccoud@gmail.com>

  • attachment logic-error.2.diff added.

Updated version

09/12/07 16:30:14 changed by David Paccoud <dpaccoud@gmail.com>

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

09/13/07 09:41:39 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #5409 (Logic error in the db-api documentation)




Change Properties
Action