Hi Michael, Thanks for the quick response!
I had no luck with has()/any() mostly because I didn't have the attribute per se, just its (string) name - but I've rather belatedly realised I can just use modelClass.__dict__[attr].any(), which works like a charm. I'll consider the functional approach you suggested, it does look much cleaner - thanks for the tip. A related question; I'm sure there must be a straightforward way, given an attribute 'attr' (which is a relation) of a mapped class 'Foo', to extract a reference to the mapped class to which the relation points. I currently have the following: tC = orm.class_mapper(Foo).get_property(attr)._get_target().class_ Or, broken down M = orm.class_mapper(Foo) # Mapper for the class p = M.get_property(attr) # The property Mt = p._get_target() # Mapper for the target tC = Mt.class_ # Target class. But I'm fairly sure any sequence of calls that involve methods from someone else's code which begin with an underscore counts as bad form ;) is there a more direct way of getting this? Cheers, -- Ben --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---