You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a model with some relationships configured with collection_class=set.
But when I try to insert a new record it tries to call the constructor with the collection as a list, and that fails with following error.
A workaround is to override the class constructor. But maybe it is better if pyramid_sacrud could cast the iterable to the collection_class type.
Traceback (most recent call last):
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/pyramid_sacrud/views/CRUD.py", line 140, in sa_add
obj = self.crud.create(data)
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sacrud/action.py", line 66, in create
return self._add(obj, data, **kwargs)
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sacrud/action.py", line 183, in _add
.add(self.session, data, self.table)
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sacrud/preprocessing.py", line 206, in add
return self.obj(**params)
File "", line 4, in init
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sqlalchemy/orm/state.py", line 269, in _initialize_instance
return manager.original_init(_mixed[1:], *_kwargs)
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sqlalchemy/ext/declarative/base.py", line 526, in _declarative_constructor
setattr(self, k, kwargs[k])
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 226, in set
instance_dict(instance), value, None)
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 1009, in set
lambda adapter, i: adapter.adapt_like_to_iterable(i))
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 1025, in _set_iterable
new_values = list(adapter(new_collection, iterable))
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 1009, in
lambda adapter, i: adapter.adapt_like_to_iterable(i))
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sqlalchemy/orm/collections.py", line 646, in adapt_like_to_iterable
given, wanted))
TypeError: Incompatible collection type: list is not set-like
Hi!
I have a model with some relationships configured with collection_class=set.
But when I try to insert a new record it tries to call the constructor with the collection as a list, and that fails with following error.
A workaround is to override the class constructor. But maybe it is better if pyramid_sacrud could cast the iterable to the collection_class type.
Traceback (most recent call last):
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/pyramid_sacrud/views/CRUD.py", line 140, in sa_add
obj = self.crud.create(data)
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sacrud/action.py", line 66, in create
return self._add(obj, data, **kwargs)
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sacrud/action.py", line 183, in _add
.add(self.session, data, self.table)
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sacrud/preprocessing.py", line 206, in add
return self.obj(**params)
File "", line 4, in init
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sqlalchemy/orm/state.py", line 269, in _initialize_instance
return manager.original_init(_mixed[1:], *_kwargs)
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sqlalchemy/ext/declarative/base.py", line 526, in _declarative_constructor
setattr(self, k, kwargs[k])
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 226, in set
instance_dict(instance), value, None)
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 1009, in set
lambda adapter, i: adapter.adapt_like_to_iterable(i))
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 1025, in _set_iterable
new_values = list(adapter(new_collection, iterable))
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 1009, in
lambda adapter, i: adapter.adapt_like_to_iterable(i))
File "/home/tallada/Projectes/env/cosmohub_v5/local/lib/python2.7/site-packages/sqlalchemy/orm/collections.py", line 646, in adapt_like_to_iterable
given, wanted))
TypeError: Incompatible collection type: list is not set-like
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: