Ticket #2348: patch_with_test.diff

File patch_with_test.diff, 1.4 KB (added by Karen Tracey <kmtracey@…>, 8 years ago)
  • django/db/models/query.py

     
    836836                new_column = new_opts.pk.column
    837837                join_column = field.column
    838838
    839             raise FieldFound
     839            # If there are still items on path but this is not a related field, we're stuck.
     840            # Add first element of path to current field name so the TypeError raised
     841            # below properly identifies the cause of the problem.
     842            if path and not field.rel:
     843                name += LOOKUP_SEPARATOR + path[0]
     844            else:
     845                raise FieldFound
    840846
    841847    except FieldFound: # Match found, loop has been shortcut.
    842848        pass
  • tests/modeltests/lookup/models.py

     
    191191>>> Article.objects.filter(headline__contains='\\')
    192192[<Article: Article with \ backslash>]
    193193
    194 """}
     194# Test added for Ticket #2348
     195# Bad lookup parm should produce "Cannot resolve keyword", not "Unbound local error"
     196>>> Article.objects.filter(pub_date_year='2005').count()
     197Traceback (most recent call last):
     198    ...
     199TypeError: Cannot resolve keyword 'pub_date_year' into field
     200
     201"""}
Back to Top