Updated patch applied in r12504. Refs #12806.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12508 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
1d5165e3be
commit
7ca3e8fecf
|
@ -100,7 +100,7 @@ write::
|
||||||
>>> first_person = Person.objects.raw('SELECT * from myapp_person')[0]
|
>>> first_person = Person.objects.raw('SELECT * from myapp_person')[0]
|
||||||
|
|
||||||
However, the indexing and slicing are not performed at the database level. If
|
However, the indexing and slicing are not performed at the database level. If
|
||||||
you have a big amount of ``Person`` objects in your database, it would be more
|
you have a big amount of ``Person`` objects in your database, it is more
|
||||||
efficient to limit the query at the SQL level::
|
efficient to limit the query at the SQL level::
|
||||||
|
|
||||||
>>> first_person = Person.objects.raw('SELECT * from myapp_person LIMIT 1')[0]
|
>>> first_person = Person.objects.raw('SELECT * from myapp_person LIMIT 1')[0]
|
||||||
|
|
|
@ -196,8 +196,4 @@ class RawQueryTests(TestCase):
|
||||||
first_two = Author.objects.raw(query)[0:2]
|
first_two = Author.objects.raw(query)[0:2]
|
||||||
self.assertEquals(len(first_two), 2)
|
self.assertEquals(len(first_two), 2)
|
||||||
|
|
||||||
try:
|
self.assertRaises(TypeError, lambda: Author.objects.raw(query)['test'])
|
||||||
Author.objects.raw(query)['test']
|
|
||||||
self.fail('Index lookups should only accept int, long or slice')
|
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
|
|
Loading…
Reference in New Issue