Hi all, I have a database table that defines polymorphism and another table that has a foreign key to the original. And in formallity:
## defines the ResourceDB, and it's polymorphism speicfic kind FileDB mapper (ResourceDB,_resources_table,polymorphic_on=_resources_table.c.type,properties= { }) mapper(FileDB,_files_table,properties={ }, inherits=ResourceDB, polymorphic_identity="file") ## defines ObjectMarkingDB, that has an external foreign key pointing to ResourceDB mapper(ObjectMarkingDB,_object_markings_table, properties={ "imageResourceId":_object_markings_table.c.image_resource_id, "imageResource":relation (ResourceDB,None,foreign_keys=_object_markings_table.c.image_resource_id,primaryjoin=_object_markings_table.c.image_resource_id==_resources_table.c.id,viewonly=True,uselist=False),#single_parent=True), ) All is rather simple so far, the problem arises when i perform a query with eager loading, for example: session.query(ObjectMarkingDB).<filtering and so on>.options(eagerload ("imageResource")) The sql query to perform the eager loading is horrible, more horrible than anything i can imagine. I managed to write my own sql statement that takes a fraction of the time, the question is: Lets say i have a collection of ResourceDB objects, how do i internally connect them to the ObjectMarkingDB instances? Or in other words: how do i implement my own eager loading for this specific purpse? And in formallity, lets say i have a collection of ResourceDBs and i collection of ObjectMarkingDBs. how do i: for every ResourceDb in ResourceDBs: connect ResourceDB to relevant ObjectMarkingDB Thanks in advance, Mati --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---