I have a relationship with a validator to automatically convert dicts
appended to the collection, so I can do something like this:
my_obj.my_collection.append({"rel_type_id": x})
Instead of this:
my_obj.my_collection.append(RelType(rel_type_id=x))
That works exactly as expected, but when I try to replace the whole
collection at once:
my_obj.my_collection = [{"rel_type_id": x}]
That results in a TypeError: unhashable type: 'dict', and the validator
method is never called. Apparently that happens when the
orm.collection.bulk_replace function uses sets to find the difference
between the old and the new collection. I don't see an straightforward fix
for that, it feels more like a limitation of the current implementation
than a bug.
It looks like I could do what I want with a custom collection and the
collection.converter decorator. Any other ideas?
Thanks.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.