#27227: Full text search by UUIDField returns DataError
----------------------------------------------+----------------------------
     Reporter:  danclaudiupop                 |      Owner:  nobody
         Type:  Uncategorized                 |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.10
     Severity:  Normal                        |   Keywords:  UUIDField fts
                                              |  postgres
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+----------------------------
 Consider the following model:

 {{{
 class Show(models.Model):
     cid = models.UUIDField(
         default=uuid.uuid4,
         editable=False,
         verbose_name="Content ID",
         help_text="Unique Identifier"
     )
     title_short = models.CharField(
         max_length=60,
         blank=True,
         verbose_name="Short Title",
         help_text="Short title (60 chars)"
     )
 }}}

 The following snippet returns DataError, see below traceback:

 {{{
 >>> from django.contrib.postgres.search import SearchVector
 >>> Show.objects.annotate(search=SearchVector('cid')).filter(search='foo')

 Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "/home/vagrant/ve/lib/python3.4/site-
 packages/django/db/models/query.py", line 232, in __repr__
     data = list(self[:REPR_OUTPUT_SIZE + 1])
   File "/home/vagrant/ve/lib/python3.4/site-
 packages/django/db/models/query.py", line 256, in __iter__
     self._fetch_all()
   File "/home/vagrant/ve/lib/python3.4/site-
 packages/django/db/models/query.py", line 1087, in _fetch_all
     self._result_cache = list(self.iterator())
   File "/home/vagrant/ve/lib/python3.4/site-
 packages/django/db/models/query.py", line 54, in __iter__
     results = compiler.execute_sql()
   File "/home/vagrant/ve/lib/python3.4/site-
 packages/django/db/models/sql/compiler.py", line 835, in execute_sql
     cursor.execute(sql, params)
   File "/home/vagrant/ve/lib/python3.4/site-
 packages/django/db/backends/utils.py", line 79, in execute
     return super(CursorDebugWrapper, self).execute(sql, params)
   File "/home/vagrant/ve/lib/python3.4/site-
 packages/django/db/backends/utils.py", line 64, in execute
     return self.cursor.execute(sql, params)
   File "/home/vagrant/ve/lib/python3.4/site-packages/django/db/utils.py",
 line 94, in __exit__
     six.reraise(dj_exc_type, dj_exc_value, traceback)
   File "/home/vagrant/ve/lib/python3.4/site-packages/django/utils/six.py",
 line 685, in reraise
     raise value.with_traceback(tb)
   File "/home/vagrant/ve/lib/python3.4/site-
 packages/django/db/backends/utils.py", line 64, in execute
     return self.cursor.execute(sql, params)
 django.db.utils.DataError: invalid input syntax for uuid: ""
 LINE 1: ...tag", to_tsvector(COALESCE("entities_show"."cid", '')) AS "s...
 }}}

 Tried with PostgreSQL 9.3.14 and PostgreSQL 9.5.3

--
Ticket URL: <https://code.djangoproject.com/ticket/27227>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/056.a5ef2fd0d64dc1b37077c00a7b427e7f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to