peewee-async
peewee-async copied to clipboard
Use of models without primary key?
I have a basic model:
class UserGroup(Model):
uid = BinaryUUIDField(index=True)
gid = BinaryUUIDField(index=True)
class Meta:
primary_key = False
indexes = (
(('uid', 'gid'), True),
)
When I'm inserting new records:
ug = await create_object(
UserGroup,
uid=uid,
gid=gid
)
File "/var/app/app/auth/routes.py", line 101, in group_add_user
gid=gid
File "/usr/local/lib/python3.7/site-packages/peewee_async.py", line 458, in create_object
obj._pk = pk
File "/usr/local/lib/python3.7/site-packages/peewee.py", line 6426, in _pk
setattr(self, self._meta.primary_key.name, value)
AttributeError: 'bool' object has no attribute 'name'
Is there a workaround?
Hello @akuzia, does peewee.CompositeKey work for you?