Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UUID binary field make error while loading referenced table [PYFB75] #90

Open
firebird-automations opened this issue Nov 13, 2018 · 2 comments

Comments

@firebird-automations
Copy link

Submitted by: Emmanuel Belair (ebelair)

Hi, I have a related entity that uses UUID binary as primary key, when I try to get this entity, I get the following error:

Schema:
import uuid

from django.db import models

class AgdeEtab(models.Model):
etab_id = models.UUIDField(primary_key=True, default=uuid.uuid4, blank=False, null=False)
activite_commerce = models.ForeignKey('AgdeActiviteCommerce', models.DO_NOTHING, blank=True, null=True)

class Meta:
    managed = False
    db\_table = 'agde\_etab'

class AgdeActiviteCommerce(models.Model):
activite_commerce_id = models.UUIDField(primary_key=True, default=uuid.uuid4)
activite_commerce_lib = models.CharField(unique=True, max_length=60)

class Meta:
    managed = False
    db\_table = 'agde\_activite\_commerce'

In console :

>>> from agde.models import AgdeEtab
>>> etab = AgdeEtab.objects.get(enseigne__startswith='MIDAS')
>>> etab.activite_commerce

Traceback (most recent call last):
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 158, in __get__
rel_obj = self.field.get_cached_value(instance)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/mixins.py", line 13, in get_cached_value
return instance._state.fields_cache[cache_name]
KeyError: 'activite_commerce'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 164, in __get__
rel_obj = self.get_object(instance)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 139, in get_object
return qs.get(self.field.get_reverse_related_filter(instance))
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 397, in get
num = len(clone)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 254, in __len__
self._fetch_all()
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 1182, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1068, in execute_sql
cursor.execute(sql, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/firebird/base.py", line 262, in execute
return self.cursor.execute(q, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/fdb/fbcore.py", line 3627, in execute
self._ps._execute(parameters)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/fdb/fbcore.py", line 3308, in _execute
self.__tuple2xsqlda(self._in_sqlda, parameters)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/fdb/fbcore.py", line 3091, in __tuple2xsqlda
len(value)))
ValueError: Value of parameter (0) is too long, expected 16, found 32

When I debug http://fbcore.py line 3091, the value type is bytes with 32 alnum chars
Feel free to ask if you need more details

@firebird-automations
Copy link
Author

Modified by: Emmanuel Belair (ebelair)

description: Hi, I have a related entity that uses UUID binary as primary key, when I try to get this entity, I get the following error:

Schema:
import uuid

from django.db import models

class AgdeEtab(models.Model):
etab_id = models.UUIDField(primary_key=True, default=uuid.uuid4, blank=False, null=False)
activite_commerce = models.ForeignKey('AgdeActiviteCommerce', models.DO_NOTHING, blank=True, null=True)

class Meta:
    managed = False
    db\_table = 'agde\_etab'

class AgdeActiviteCommerce(models.Model):
activite_commerce_id = models.UUIDField(primary_key=True, default=uuid.uuid4)
activite_commerce_lib = models.CharField(unique=True, max_length=60)

class Meta:
    managed = False
    db\_table = 'agde\_activite\_commerce'

>>> from agde.models import AgdeEtab
>>> etab = AgdeEtab.objects.get(enseigne__startswith='MIDAS')
>>> etab.activite_commerce
Traceback (most recent call last):
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 158, in __get__
rel_obj = self.field.get_cached_value(instance)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/mixins.py", line 13, in get_cached_value
return instance._state.fields_cache[cache_name]
KeyError: 'activite_commerce'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 164, in __get__
rel_obj = self.get_object(instance)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 139, in get_object
return qs.get(self.field.get_reverse_related_filter(instance))
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 397, in get
num = len(clone)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 254, in __len__
self._fetch_all()
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 1182, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1068, in execute_sql
cursor.execute(sql, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/firebird/base.py", line 262, in execute
return self.cursor.execute(q, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/fdb/fbcore.py", line 3627, in execute
self._ps._execute(parameters)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/fdb/fbcore.py", line 3308, in _execute
self.__tuple2xsqlda(self._in_sqlda, parameters)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/fdb/fbcore.py", line 3091, in __tuple2xsqlda
len(value)))
ValueError: Value of parameter (0) is too long, expected 16, found 32

=>

Hi, I have a related entity that uses UUID binary as primary key, when I try to get this entity, I get the following error:

Schema:
import uuid

from django.db import models

class AgdeEtab(models.Model):
etab_id = models.UUIDField(primary_key=True, default=uuid.uuid4, blank=False, null=False)
activite_commerce = models.ForeignKey('AgdeActiviteCommerce', models.DO_NOTHING, blank=True, null=True)

class Meta:
    managed = False
    db\_table = 'agde\_etab'

class AgdeActiviteCommerce(models.Model):
activite_commerce_id = models.UUIDField(primary_key=True, default=uuid.uuid4)
activite_commerce_lib = models.CharField(unique=True, max_length=60)

class Meta:
    managed = False
    db\_table = 'agde\_activite\_commerce'

>>> from agde.models import AgdeEtab
>>> etab = AgdeEtab.objects.get(enseigne__startswith='MIDAS')
>>> etab.activite_commerce
Traceback (most recent call last):
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 158, in __get__
rel_obj = self.field.get_cached_value(instance)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/mixins.py", line 13, in get_cached_value
return instance._state.fields_cache[cache_name]
KeyError: 'activite_commerce'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 164, in __get__
rel_obj = self.get_object(instance)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 139, in get_object
return qs.get(self.field.get_reverse_related_filter(instance))
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 397, in get
num = len(clone)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 254, in __len__
self._fetch_all()
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 1182, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1068, in execute_sql
cursor.execute(sql, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/firebird/base.py", line 262, in execute
return self.cursor.execute(q, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/fdb/fbcore.py", line 3627, in execute
self._ps._execute(parameters)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/fdb/fbcore.py", line 3308, in _execute
self.__tuple2xsqlda(self._in_sqlda, parameters)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/fdb/fbcore.py", line 3091, in __tuple2xsqlda
len(value)))
ValueError: Value of parameter (0) is too long, expected 16, found 32

When I debug http://fbcore.py line 3091, the value type is bytes with 32 alnum chars
Feel free to ask if you need more details

@firebird-automations
Copy link
Author

Modified by: Emmanuel Belair (ebelair)

description: Hi, I have a related entity that uses UUID binary as primary key, when I try to get this entity, I get the following error:

Schema:
import uuid

from django.db import models

class AgdeEtab(models.Model):
etab_id = models.UUIDField(primary_key=True, default=uuid.uuid4, blank=False, null=False)
activite_commerce = models.ForeignKey('AgdeActiviteCommerce', models.DO_NOTHING, blank=True, null=True)

class Meta:
    managed = False
    db\_table = 'agde\_etab'

class AgdeActiviteCommerce(models.Model):
activite_commerce_id = models.UUIDField(primary_key=True, default=uuid.uuid4)
activite_commerce_lib = models.CharField(unique=True, max_length=60)

class Meta:
    managed = False
    db\_table = 'agde\_activite\_commerce'

>>> from agde.models import AgdeEtab
>>> etab = AgdeEtab.objects.get(enseigne__startswith='MIDAS')
>>> etab.activite_commerce
Traceback (most recent call last):
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 158, in __get__
rel_obj = self.field.get_cached_value(instance)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/mixins.py", line 13, in get_cached_value
return instance._state.fields_cache[cache_name]
KeyError: 'activite_commerce'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 164, in __get__
rel_obj = self.get_object(instance)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 139, in get_object
return qs.get(self.field.get_reverse_related_filter(instance))
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 397, in get
num = len(clone)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 254, in __len__
self._fetch_all()
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 1182, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1068, in execute_sql
cursor.execute(sql, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/firebird/base.py", line 262, in execute
return self.cursor.execute(q, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/fdb/fbcore.py", line 3627, in execute
self._ps._execute(parameters)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/fdb/fbcore.py", line 3308, in _execute
self.__tuple2xsqlda(self._in_sqlda, parameters)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/fdb/fbcore.py", line 3091, in __tuple2xsqlda
len(value)))
ValueError: Value of parameter (0) is too long, expected 16, found 32

When I debug http://fbcore.py line 3091, the value type is bytes with 32 alnum chars
Feel free to ask if you need more details

=>

Hi, I have a related entity that uses UUID binary as primary key, when I try to get this entity, I get the following error:

Schema:
import uuid

from django.db import models

class AgdeEtab(models.Model):
etab_id = models.UUIDField(primary_key=True, default=uuid.uuid4, blank=False, null=False)
activite_commerce = models.ForeignKey('AgdeActiviteCommerce', models.DO_NOTHING, blank=True, null=True)

class Meta:
    managed = False
    db\_table = 'agde\_etab'

class AgdeActiviteCommerce(models.Model):
activite_commerce_id = models.UUIDField(primary_key=True, default=uuid.uuid4)
activite_commerce_lib = models.CharField(unique=True, max_length=60)

class Meta:
    managed = False
    db\_table = 'agde\_activite\_commerce'

In console :

>>> from agde.models import AgdeEtab
>>> etab = AgdeEtab.objects.get(enseigne__startswith='MIDAS')
>>> etab.activite_commerce

Traceback (most recent call last):
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 158, in __get__
rel_obj = self.field.get_cached_value(instance)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/mixins.py", line 13, in get_cached_value
return instance._state.fields_cache[cache_name]
KeyError: 'activite_commerce'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 164, in __get__
rel_obj = self.get_object(instance)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py", line 139, in get_object
return qs.get(self.field.get_reverse_related_filter(instance))
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 397, in get
num = len(clone)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 254, in __len__
self._fetch_all()
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 1182, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1068, in execute_sql
cursor.execute(sql, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/django/db/backends/firebird/base.py", line 262, in execute
return self.cursor.execute(q, params)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/fdb/fbcore.py", line 3627, in execute
self._ps._execute(parameters)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/fdb/fbcore.py", line 3308, in _execute
self.__tuple2xsqlda(self._in_sqlda, parameters)
File "/home/manu/env01/fbtest/venv/lib/python3.6/site-packages/fdb/fbcore.py", line 3091, in __tuple2xsqlda
len(value)))
ValueError: Value of parameter (0) is too long, expected 16, found 32

When I debug http://fbcore.py line 3091, the value type is bytes with 32 alnum chars
Feel free to ask if you need more details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants