Opened 13 years ago

Closed 13 years ago

#17146 closed Cleanup/optimization (invalid)

Django docs possiable error

Reported by: from_a_far@… Owned by: nobody
Component: Documentation Version: 1.3
Severity: Normal Keywords: documentation
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

go to: https://docs.djangoproject.com/en/1.3/topics/db/queries/#complex-lookups-with-q-objects

and scroll down to:

Poll.objects.get(
    Q(question__startswith='Who'),
    Q(pub_date=date(2005, 5, 2)) | Q(pub_date=date(2005, 5, 6))
)

and it says it yealds the following SQL:

SELECT * from polls WHERE question LIKE 'Who%'
    AND (pub_date = '2005-05-02' OR pub_date = '2005-05-06')

Thats not true though is it? If it's Poll.objects.get(... it's only going to get one object isn't it?

Change History (1)

comment:1 by Luke Plant, 13 years ago

Resolution: invalid
Status: newclosed

It says 'roughly' translates, and it is correct. get() may or may not add a LIMIT clause (that's an implementation detail) - in fact it currently doesn't do any LIMIT clause, in order to be able to throw an exception when more than one object is matched.

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