1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

magic-removal: Fixed #1186 -- Fixed problem resolving primary key in some 'pk' database queries. Also lightly refactored query-parsing code. Thanks, Russ

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1856 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty
2006-01-08 06:16:05 +00:00
parent 2bc39d88e6
commit f998c7bcc6
7 changed files with 333 additions and 172 deletions

View File

@@ -47,6 +47,10 @@ Traceback (most recent call last):
...
DoesNotExist: Employee does not exist for {'pk': 'foo'}
# Use the name of the primary key, rather than pk.
>>> Employee.objects.get_object(employee_code__exact='ABC123')
Dan Jones
# Fran got married and changed her last name.
>>> fran = Employee.objects.get_object(pk='XYZ456')
>>> fran.last_name = 'Jones'
@@ -66,4 +70,23 @@ True
[Sears]
>>> Business.objects.get_in_bulk(['Sears'])
{'Sears': Sears}
>>> Business.objects.get_list(name__exact='Sears')
[Sears]
>>> Business.objects.get_list(pk='Sears')
[Sears]
# Queries across tables, involving primary key
>>> Employee.objects.get_list(businesses__name__exact='Sears')
[Dan Jones, Fran Jones]
>>> Employee.objects.get_list(businesses__pk='Sears')
[Dan Jones, Fran Jones]
>>> Business.objects.get_list(employees__employee_code__exact='ABC123')
[Sears]
>>> Business.objects.get_list(employees__pk='ABC123')
[Sears]
>>> Business.objects.get_list(employees__first_name__startswith='Fran')
[Sears]
"""