#16898: Throwing an exception out of a custom field (or any QuerySet._results_iter callable) results in a bad _results_cache -------------------------------------+------------------------------------- Reporter: jdunck | Owner: nobody Type: Bug | Status: new Milestone: | Component: Database Version: 1.3 | layer (models, ORM) Keywords: | Severity: Normal Has patch: 0 | Triage Stage: Needs tests: 0 | Unreviewed Easy pickings: 0 | Needs documentation: 0 | Patch needs improvement: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Using a custom field which breaks: {{{ class BrokenField(DateTimeField): __metaclass__ = SubfieldBase
def to_python(self, value): raise TypeError("Nope.") }}} Assume some rows exist. If you then create AModel using that field: {{{ class AModel(Model): f = BrokenField(null=True) }}} And you then try to query on it: {{{ >>> qs = AModel.objects.all() >>> qs [] >>> qs._result_cache is None True }}} You get an empty (or truncated) results list. I think the underlying exception should instead be raised. If it only breaks sometimes, the results will be shorter, a very hard-to-find bug. -- Ticket URL: <https://code.djangoproject.com/ticket/16898> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.