Re: [SQLObject] Incorrect join column name
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Matt G. <ma...@po...> - 2003-05-11 23:17:29
|
I should have mentioned ... this was using latest CVS HEAD and PostgreSQL 7.3. - Matt On Sun, 2003-05-11 at 23:55, Matt Goodall wrote: > Hi, > > I've only recently started experimenting with SQLObject so please > forgive me if this turns out to be complete nonsense ;-). > > There seems to be a problem with the name that is generated for a join > column when a class explicitly sets the name of the table (using > _table). Here's an example: > > class Order(SQLObject.SQLObject): > _table = 'ordr' > _columns = [ > SQLObject.IntCol('number', dbName='nmbr'), > SQLObject.IntCol('customerID', foreignKey='Customer'), > ] > _joins = [SQLObject.MultipleJoin('OrderItem'),] > > class OrderItem(SQLObject.SQLObject): > _columns = [ > SQLObject.IntCol('orderID', foreignKey='Order'), > SQLObject.IntCol('productID', foreignKey='Product'), > SQLObject.IntCol('quantity'), > ] > > (Ignore the Customer and Product classes - they're not relevant.) > > >From the above, SQLObject creates the following tables: > > CREATE TABLE ordr ( > id serial NOT NULL, > nmbr integer, > customer_id integer > ); > > CREATE TABLE order_item ( > id serial NOT NULL, > order_id integer, > product_id integer, > quantity integer > ); > > So far, so good. However when I have an existing Order (with id=1) and I > "call" order.orderItems the following SQL is executed: > > SELECT id FROM order_item WHERE ordr_id = 1 > > As you can see, ordr_id is wrong - it should be order_id. > > I started trying to fix the error but realised that I don't actually > know what to fix - the table creation code or the join code. i.e. should > the created table's column be called ordr_id or should the join SQL use > order_id? > > If someone who understands what SQLObject's *should* be doing can tell > me what to fix I will try to send a patch. > > - Matt > > > > ------------------------------------------------------- > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara > The only event dedicated to issues related to Linux enterprise solutions > www.enterpriselinuxforum.com > > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss |