It works! :) Now I can do this: >>> model.Resource.query.filter(model.Resource.parent == ... model.Resource.query.filter_by(url='example.com').one()).one() <Resource at 'example.com/mypage'>
Just so people know how to fix this if they have the same problem, here is my mapper code, using SQLAlchemy 0.4.2: resources_mapper = mapper(Resource, resources, polymorphic_on=resources.c.type, polymorphic_identity="empty", column_prefix='_', properties={ 'id': resources.c.id, 'url': synonym('_url', map_column=True), 'children': relation(Resource, backref=backref("_parent", remote_side=[resources.c.id])), #'parent': synonym('_parent'), #This doesn't work, so I put it after initialization. 'name': synonym('_name', map_column=True), 'type': resources.c.type, # NOTE: Remember to add here other columns that don't need # a custom property accessor, like the id. Otherwise, they # be available as _column_name, not column_name. }, save_on_init=False, ) resource_mapper.add_property('parent', synonym('_parent')) Thanks for the help Michael Bayer! --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---