Hello,
(Sorry I couldn't figure out how to register for trac issue creation.)
Trying to use Entity.to_dict() I've noticed that anything in "deep"
will be recursively be to_dict'()ed which breaks if it happens to be
None. I think it's more useful to allow the entries in "deep" to
either be an Entity or None. I want to to_dict() a relationship only
_if_ it is set.
Therefore I vote for entity.py:81 to be changed from:
data[rname] = dbdata.to_dict(rdeep, exclude)
to:
if dbdata is None:
data[rname] = None
else:
data[rname] = dbdata.to_dict(rdeep, exclude)
I found
http://groups.google.com/group/sqlelixir/browse_thread/thread/a7ee892c725e3437?pli=1
where Gaetan de Menten commented:
- The following test: "data[rname] is not None" shouldn't be there IMO
(so that you can set a relationship to "NULL").
Sounds very related!
Also:
- Is there a simple way to build that "deep" tree automatically from
my model, if I happen to want to resolve _all_ ManyToOne and OneToOne
relationships in the entity? I don't have circular problems and just
want "all".
- It would be nice if entities resolved through "deep" had their
corresponding (fk) ids removed.
- Couldn't "exclude" be a nested dict like "deep", rather than a list?
(and just extended with the remote_side stuff) I would like to filter
out some other fields further down the hierarchy (yes, the ids :-)).
Cheers,
Danny
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---