#24859: UUIDField does not Properly Raise TyperError
-------------------------------+--------------------
     Reporter:  cancan101      |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  Uncategorized  |    Version:  1.8
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 I have two models one with an int pk and one with a UUIDField pk:


 {{{
 class Bar(models.Model):
     id = models.UUIDField(primary_key=True, default=uuid4)

 class Bar2(models.Model):
     pass
 }}}

 If I try to get these using a value of {} they fail differently. The model
 with the int pk:

 {{{
 >>> Bar2.objects.all().get(pk={})
 TypeError: int() argument must be a string or a number, not 'dict'
 }}}


 whereas:

 {{{
 >>> Bar.objects.all().get(pk={})
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
   File "/Users/alex/.virtualenvs/TestPG/lib/python2.7/site-
 packages/django/db/models/query.py", line 328, in get
     num = len(clone)
   File "/Users/alex/.virtualenvs/TestPG/lib/python2.7/site-
 packages/django/db/models/query.py", line 144, in __len__
     self._fetch_all()
   File "/Users/alex/.virtualenvs/TestPG/lib/python2.7/site-
 packages/django/db/models/query.py", line 965, in _fetch_all
     self._result_cache = list(self.iterator())
   File "/Users/alex/.virtualenvs/TestPG/lib/python2.7/site-
 packages/django/db/models/query.py", line 238, in iterator
     results = compiler.execute_sql()
   File "/Users/alex/.virtualenvs/TestPG/lib/python2.7/site-
 packages/django/db/models/sql/compiler.py", line 840, in execute_sql
     cursor.execute(sql, params)
   File "/Users/alex/.virtualenvs/TestPG/lib/python2.7/site-
 packages/django/db/backends/utils.py", line 79, in execute
     return super(CursorDebugWrapper, self).execute(sql, params)
   File "/Users/alex/.virtualenvs/TestPG/lib/python2.7/site-
 packages/django/db/backends/utils.py", line 64, in execute
     return self.cursor.execute(sql, params)
   File "/Users/alex/.virtualenvs/TestPG/lib/python2.7/site-
 packages/django/db/utils.py", line 97, in __exit__
     six.reraise(dj_exc_type, dj_exc_value, traceback)
   File "/Users/alex/.virtualenvs/TestPG/lib/python2.7/site-
 packages/django/db/backends/utils.py", line 64, in execute
     return self.cursor.execute(sql, params)
   File "/Users/alex/.virtualenvs/TestPG/lib/python2.7/site-
 packages/django/db/backends/sqlite3/base.py", line 318, in execute
     return Database.Cursor.execute(self, query, params)
 InterfaceError: Error binding parameter 0 - probably unsupported type.
 }}}

 This inconsistency leads to issues like: https://github.com/tomchristie
 /django-rest-framework/issues/2970

--
Ticket URL: <https://code.djangoproject.com/ticket/24859>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.f5ff70ab1d8fa7ad1903fc671a31623a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to