Re: [SQLObject] Incorrect join column name
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Ian B. <ia...@co...> - 2003-05-12 01:19:47
|
On Sun, 2003-05-11 at 17:55, Matt Goodall wrote:
[...example...]
> 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?
I'm not sure what the proper behavior is here -- I think it's correct
currently (though for naming things like this there's no One Right
Way). The default is that a foreign key column will be named
tablename_id, which is exactly what it does. But you want to use the
automatically generated table name ("order"), not the explicit name
("ordr"). I think in that case you just need to be explicit, i.e.:
MultipleJoin('OrderItem', joinColumn='order_id')
Ian
|