#19135: Example in "Spanning Multi-valued relationships" is mixed
-------------------------------+--------------------------------------
     Reporter:  anonymous      |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  closed
    Component:  Documentation  |                  Version:  1.4
     Severity:  Normal         |               Resolution:  invalid
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------
Changes (by claudep):

 * status:  new => closed
 * resolution:   => invalid


Old description:

> '''The example writes:'''
>
> That may sound a bit confusing, so hopefully an example will clarify. To
> select all blogs that contain entries with both "Lennon" in the headline
> and that were published in 2008 (the same entry satisfying both
> conditions), we would write:
>
> Blog.objects.filter(entry__headline__contains='Lennon',
>         entry__pub_date__year=2008)
>
> To select all blogs that contain an entry with "Lennon" in the headline
> as well as an entry that was published in 2008, we would write:
>
> Blog.objects.filter(entry__headline__contains='Lennon').filter(
>         entry__pub_date__year=2008)
>
> From my understanding, the two examples are mixed up: the first example
> should be for the second explanation and vice versa. First example is a
> union of two sets: filter(setA, setB), the second example is an
> intersection of two sets: filter(setA).filter(setB).

New description:

 '''The example writes:'''

 That may sound a bit confusing, so hopefully an example will clarify. To
 select all blogs that contain entries with both "Lennon" in the headline
 and that were published in 2008 (the same entry satisfying both
 conditions), we would write:
 {{{
 Blog.objects.filter(entry__headline__contains='Lennon',
         entry__pub_date__year=2008)
 }}}
 To select all blogs that contain an entry with "Lennon" in the headline as
 well as an entry that was published in 2008, we would write:
 {{{
 Blog.objects.filter(entry__headline__contains='Lennon').filter(
         entry__pub_date__year=2008)
 }}}
 From my understanding, the two examples are mixed up: the first example
 should be for the second explanation and vice versa. First example is a
 union of two sets: filter(setA, setB), the second example is an
 intersection of two sets: filter(setA).filter(setB).

--

Comment:

 No, the example is right. The first filter will apply both conditions on
 the same join, while the second one will create a separate join for each
 condition, hence the results might be larger.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/19135#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to