Changeset 7163
- Timestamp:
- 02/26/08 18:44:44 (9 months ago)
- Files:
-
- django/branches/queryset-refactor/django/core/exceptions.py (modified) (1 diff)
- django/branches/queryset-refactor/django/db/models/base.py (modified) (2 diffs)
- django/branches/queryset-refactor/django/db/models/sql/query.py (modified) (8 diffs)
- django/branches/queryset-refactor/tests/modeltests/custom_columns/models.py (modified) (1 diff)
- django/branches/queryset-refactor/tests/modeltests/field_subclassing/models.py (modified) (3 diffs)
- django/branches/queryset-refactor/tests/modeltests/lookup/models.py (modified) (1 diff)
- django/branches/queryset-refactor/tests/modeltests/many_to_one/models.py (modified) (2 diffs)
- django/branches/queryset-refactor/tests/modeltests/model_inheritance/models.py (modified) (1 diff)
- django/branches/queryset-refactor/tests/modeltests/reverse_lookup/models.py (modified) (1 diff)
- django/branches/queryset-refactor/tests/regressiontests/null_queries/models.py (modified) (1 diff)
- django/branches/queryset-refactor/tests/regressiontests/queries/models.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/queryset-refactor/django/core/exceptions.py
r6857 r7163 28 28 "Django is somehow improperly configured" 29 29 pass 30 31 class FieldError(Exception): 32 """Some kind of problem with a model field.""" 33 pass 34 django/branches/queryset-refactor/django/db/models/base.py
r7142 r7163 7 7 import django.db.models.manager 8 8 from django.core import validators 9 from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned 9 from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, FieldError 10 10 from django.db.models.fields import AutoField, ImageField, FieldDoesNotExist 11 11 from django.db.models.fields.related import OneToOneRel, ManyToOneRel, OneToOneField … … 102 102 for field in base._meta.local_fields: 103 103 if field.name in names: 104 raise TypeError('Local field %r in class %r clashes with field of similar name from abstract base class %r'104 raise FieldError('Local field %r in class %r clashes with field of similar name from abstract base class %r' 105 105 % (field.name, name, base.__name__)) 106 106 new_class.add_to_class(field.name, field) django/branches/queryset-refactor/django/db/models/sql/query.py
r7162 r7163 20 20 from django.db.models.fields import FieldDoesNotExist, Field, related 21 21 from django.contrib.contenttypes import generic 22 from django.core.exceptions import FieldError 22 23 from datastructures import EmptyResultSet 23 24 … … 549 550 join_tuple = tuple([tuple(j) for j in joins]) 550 551 if join_tuple in already_seen: 551 raise TypeError('Infinite loop caused by ordering.')552 raise FieldError('Infinite loop caused by ordering.') 552 553 already_seen[join_tuple] = True 553 554 … … 736 737 parts = arg.split(LOOKUP_SEP) 737 738 if not parts: 738 raise TypeError("Cannot parse keyword query %r" % arg)739 raise FieldError("Cannot parse keyword query %r" % arg) 739 740 740 741 # Work out the lookup type and remove it from 'parts', if necessary. … … 868 869 except FieldDoesNotExist: 869 870 names = opts.get_all_field_names() 870 raise TypeError("Cannot resolve keyword %r into field. "871 raise FieldError("Cannot resolve keyword %r into field. " 871 872 "Choices are: %s" % (name, ", ".join(names))) 872 873 if model: … … 973 974 974 975 if pos != len(names) - 1: 975 raise TypeError("Join on field %r not permitted." % name)976 raise FieldError("Join on field %r not permitted." % name) 976 977 977 978 return field, target, opts, joins … … 1034 1035 errors.append(item) 1035 1036 if errors: 1036 raise TypeError('Invalid order_by arguments: %s' % errors)1037 raise FieldError('Invalid order_by arguments: %s' % errors) 1037 1038 if ordering: 1038 1039 self.order_by.extend(ordering) … … 1229 1230 if self.alias_map[alias][ALIAS_REFCOUNT]: 1230 1231 if table: 1231 raise TypeError('Updates can only access a single database table at a time.')1232 raise FieldError('Updates can only access a single database table at a time.') 1232 1233 table = alias 1233 1234 else: … … 1272 1273 if not direct or m2m: 1273 1274 # Can only update non-relation fields and foreign keys. 1274 raise TypeError('Cannot update model field %r (only non-relations and foreign keys permitted).' % field)1275 raise fieldError('Cannot update model field %r (only non-relations and foreign keys permitted).' % field) 1275 1276 if field.rel and isinstance(val, Model): 1276 1277 val = val.pk django/branches/queryset-refactor/tests/modeltests/custom_columns/models.py
r6730 r7163 72 72 Traceback (most recent call last): 73 73 ... 74 TypeError: Cannot resolve keyword 'firstname' into field. Choices are: article, first_name, id, last_name74 FieldError: Cannot resolve keyword 'firstname' into field. Choices are: article, first_name, id, last_name 75 75 76 76 >>> a = Author.objects.get(last_name__exact='Smith') django/branches/queryset-refactor/tests/modeltests/field_subclassing/models.py
r6753 r7163 6 6 from django.utils.encoding import force_unicode 7 7 from django.core import serializers 8 from django.core.exceptions import FieldError 8 9 9 10 class Small(object): … … 51 52 if lookup_type == 'isnull': 52 53 return [] 53 raise TypeError('Invalid lookup type: %r' % lookup_type)54 raise FieldError('Invalid lookup type: %r' % lookup_type) 54 55 55 56 def flatten_data(self, follow, obj=None): … … 95 96 Traceback (most recent call last): 96 97 ... 97 TypeError: Invalid lookup type: 'lt'98 FieldError: Invalid lookup type: 'lt' 98 99 99 100 # Serialization works, too. django/branches/queryset-refactor/tests/modeltests/lookup/models.py
r7149 r7163 271 271 Traceback (most recent call last): 272 272 ... 273 TypeError: Cannot resolve keyword 'pub_date_year' into field. Choices are: headline, id, pub_date273 FieldError: Cannot resolve keyword 'pub_date_year' into field. Choices are: headline, id, pub_date 274 274 275 275 >>> Article.objects.filter(headline__starts='Article') 276 276 Traceback (most recent call last): 277 277 ... 278 TypeError: Join on field 'headline' not permitted.278 FieldError: Join on field 'headline' not permitted. 279 279 280 280 # Create some articles with a bit more interesting headlines for testing field lookups: django/branches/queryset-refactor/tests/modeltests/many_to_one/models.py
r6730 r7163 180 180 Traceback (most recent call last): 181 181 ... 182 TypeError: Cannot resolve keyword 'reporter_id' into field. Choices are: headline, id, pub_date, reporter182 FieldError: Cannot resolve keyword 'reporter_id' into field. Choices are: headline, id, pub_date, reporter 183 183 184 184 # You need to specify a comparison clause … … 186 186 Traceback (most recent call last): 187 187 ... 188 TypeError: Cannot resolve keyword 'reporter_id' into field. Choices are: headline, id, pub_date, reporter188 FieldError: Cannot resolve keyword 'reporter_id' into field. Choices are: headline, id, pub_date, reporter 189 189 190 190 # You can also instantiate an Article by passing django/branches/queryset-refactor/tests/modeltests/model_inheritance/models.py
r7143 r7163 149 149 Traceback (most recent call last): 150 150 ... 151 TypeError: Cannot resolve keyword 'supplier' into field. Choices are: address, id, italianrestaurant, lot, name, place_ptr, provider, rating, serves_hot_dogs, serves_pizza151 FieldError: Cannot resolve keyword 'supplier' into field. Choices are: address, id, italianrestaurant, lot, name, place_ptr, provider, rating, serves_hot_dogs, serves_pizza 152 152 153 153 # Parent fields can be used directly in filters on the child model. django/branches/queryset-refactor/tests/modeltests/reverse_lookup/models.py
r6730 r7163 56 56 Traceback (most recent call last): 57 57 ... 58 TypeError: Cannot resolve keyword 'choice' into field. Choices are: creator, id, poll_choice, question, related_choice58 FieldError: Cannot resolve keyword 'choice' into field. Choices are: creator, id, poll_choice, question, related_choice 59 59 """} django/branches/queryset-refactor/tests/regressiontests/null_queries/models.py
r6967 r7163 38 38 Traceback (most recent call last): 39 39 ... 40 TypeError: Cannot resolve keyword 'foo' into field. Choices are: choice, id, poll40 FieldError: Cannot resolve keyword 'foo' into field. Choices are: choice, id, poll 41 41 42 42 # Can't use None on anything other than __exact django/branches/queryset-refactor/tests/regressiontests/queries/models.py
r7154 r7163 395 395 Traceback (most recent call last): 396 396 ... 397 TypeError: Infinite loop caused by ordering.397 FieldError: Infinite loop caused by ordering. 398 398 399 399 # If the remote model does not have a default ordering, we order by its 'id'
