Re: [SQLObject] Having trouble with one to many joins
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Luke O. <lu...@me...> - 2003-06-16 23:04:15
|
Since your class definitions look broadly correct, I'm guessing it is a case-sensitivity issue (MySQL has case sensitive tablenames on some platforms, Postgres is always insensitive, not sure about others), or a problem with the SQLObject version you're using not properly reading _table... I haven't followed changes to that portion of the code in a while, although I know Ian's been fixing up various bugs regarding Styles etc. What database, OS, and version of SQLObject are you using? Have you tried explicitly setting the joinMethodName and joinColumn arguments of the Join? If you turn on debug=True for the connection you are using, the SQL that is printed to stdout should provide a pretty clear picture of where the problem is, so this will probably the most helpful info in addition to version info. - Luke Quoting Andy Todd <an...@ha...>: > Hi, > > This is probably a stupid question, but I couldn't find anything in the > mailing list archives. > > I've got two tables in a parent-child relationship and I thought I had > specified the joins correctly but I am getting no joy. > > Table 1 (the parent) is called PORTFOLIOS, here is my class definition; > > class Portfolio(SQLObject): > _table='portfolios' > _columns=[Col('portfolioCode'), > Col('portfolioDesc'), > ] > _joins=[MultipleJoin('Holding'), > ] > > The child table is called HOLDINGS, here is its class definition; > > class Holding(SQLObject): > _table='holdings' > _columns=[Col('portfolioID', foreignKey='Portfolio'), > Col('stockID', foreignKey='Stock'), > Col('buyDate'), > Col('buyQuantity'), > Col('buyPrice'), > Col('currentQuantity'), > ] > > The tables are already populated and I can fetch rows from either table > successfully, either with index values, select or selectBy methods. But > the join is a bit shonky, my Holding objects contain a reference to the > correct portfolio object and a portfolioID attribute, but the Portfolio > objects do not contain any references to holdings. > > I suspect the problem lies in my choice of names. Because the table is > called portfolios, the class Portfolio and the foreign key column > portfolio_id I believe the foreign key is being traversed correctly. Can > anyone suggest what I have done wrong and, more importantly, what I can > do to get this working properly. > > Thanks in advance, > Andy > -- > -------------------------------------------------------------------------------- > From the desk of Andrew J Todd esq - http://www.halfcooked.com/ > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: INetU > Attention Web Developers & Consultants: Become An INetU Hosting Partner. > Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! > INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > -- i find your contempt for naked feet curious. |