On Tue, 2008-12-09 at 13:05 +0200, [EMAIL PROTECTED] wrote: > not sure if that is the problem, but are Folder.items and > FolterContent.folder the reciprocal ends of same relation? > then u need only one of those, with backref. >
Hi, "Folder" is a "Content". A "Folder" can contains one or more "Content" through the "folder_content" table which is represented by the "FolderContent" association object, so FolderContent has a reference to a "Content" and a "Folder" (which is a "Content"). It's this "FolderContent" list which is accessible through the "Folder.items" property. In "FolderContent" I'd like to have a property to the corresponding "Content" and the corresponding "Folder" (which is a "Content", I suspect that the problem is here). So in my "FolderContent" mapper I added 'content' : relation(Content), which works. However 'folder' : relation(Folder) doesn't (although foreign keys are there, and I presume that SQLAlchemy use them to detect join points ..), so I wonder why it works for one and not for the other .. :) It sounds a bit complicated on paper, but in fact it's very simple. Thanks, Julien > On Tuesday 09 December 2008 12:08:02 Julien Cigar wrote: > > Dear SQLAlchemy users, > > > > I'm playing with inheritance for a CMS-like application. It's very > > usefull as it greatly simplifies the code. > > > > Here is my SQL script http://pastebin.com/f7c5297c8 and here is my > > python code (mappers, etc) http://pastebin.com/f1e2738ba > > (Not everything is shown...) > > > > As you can see, everything inherits from a "Content". "Folder" are > > special "Content" which act as containers for one or more "Content" > > through the "FolderContent" object (folder_content table). > > > > The problem is at line 128 of the second paste, SQLAlchemy is > > unable to determine the join condition to the "Folder" ("folder" > > table) which seems strange because folder_content table has > > explicitely a foreign key to the "folder" table (line 70 of the > > first paste). > > > > When I try to get a specific FolderContent through : > > >>> model.FolderContent.query.get((12,6)) > > > > I get a: > > > > "ArgumentError: Could not determine join condition between > > parent/child tables on relation FolderContent.folder. Specify a > > 'primaryjoin' expression. If this is a many-to-many relation, > > 'secondaryjoin' is needed as well." > > > > My question is: do I need to explicitely specify the join condition > > when inheritance is involved ? Why is SQLAlchemy able to detect the > > join condition for my "Content" (line 127) but not for my "Folder" > > (line 128) ? > > > > In advance thanks for your answers > > > > Best regards, > > Julien > > > > > -- Julien Cigar Belgian Biodiversity Platform http://www.biodiversity.be Université Libre de Bruxelles (ULB) Campus de la Plaine CP 257 Bâtiment NO, Bureau 4 N4 115C (Niveau 4) Boulevard du Triomphe, entrée ULB 2 B-1050 Bruxelles Mail: [EMAIL PROTECTED] @biobel: http://biobel.biodiversity.be/person/show/471 Tel : 02 650 57 52 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" 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/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
