Problem with uuid primary keys

95 weergaven
Naar het eerste ongelezen bericht

je...@joblicate.com

ongelezen,
2 mrt 2016, 05:32:4102-03-2016
aan django-watson discussion group
I'm trying to search a model with uuid primary keys

id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)


When I search, I get the following error 

Traceback (most recent call last):
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/rest_framework/viewsets.py", line 87, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/rest_framework/views.py", line 466, in dispatch
    response = self.handle_exception(exc)
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/rest_framework/views.py", line 463, in dispatch
    response = handler(request, *args, **kwargs)
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/rest_framework/mixins.py", line 48, in list
    return Response(serializer.data)
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/rest_framework/serializers.py", line 658, in data
    ret = super(ListSerializer, self).data
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/rest_framework/serializers.py", line 223, in data
    self._data = self.to_representation(self.instance)
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/rest_framework/serializers.py", line 598, in to_representation
    self.child.to_representation(item) for item in iterable
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/django/db/models/query.py", line 162, in __iter__
    self._fetch_all()
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/django/db/models/query.py", line 965, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/django/db/models/query.py", line 238, in iterator
    results = compiler.execute_sql()
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 840, in execute_sql
    cursor.execute(sql, params)
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/Users/jeppe/Repos/Joblicate-backend/.virtualenv/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
ProgrammingError: operator does not exist: text = uuid
LINE 1: ...h', '$$a$$:*')) AND (watson_searchentry.object_id = "joblica...


I seems text is being compared with uuid, which does not work. Anyone else experienced this?

Jeppe

Dave Hall

ongelezen,
2 mrt 2016, 05:44:4302-03-2016
aan django-watson discussion group
It needs to be able to perform a database join on between the searchentry table and the primary key of the model. Due to limitations in the Django ORM, only joins with integer and string primary keys are supported at the moment.

The workaround (and the best performance), is to use an integer primary key, and have the UUID as a unique key if it's required.

--
You received this message because you are subscribed to the Google Groups "django-watson discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-watso...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-watson.
For more options, visit https://groups.google.com/d/optout.

je...@joblicate.com

ongelezen,
2 mrt 2016, 08:23:3102-03-2016
aan django-watson discussion group
I've opened https://github.com/etianen/django-watson/pull/154 with a proposal for uuid pk support
Allen beantwoorden
Auteur beantwoorden
Doorsturen
0 nieuwe berichten