On Thu, 21 Oct 2004 17:23:24 +0300, Max Ischenko <ma...@uc...> wrote:
>
> Hi,
>
> I need to setup simple one-to-many relation but has problems due (I
> guess) SQLobject's magic autonaming scheme.
>
> Here is my code:
>
> class OrderGateway(SQLObject):
> name = StringCol()
> prints = MultipleJoin('PrintGateway')
>
> class PrintGateway(SQLObject):
> size = StringCol()
> order = ForeignKey('OrderGateway')
>
> dborder = OrderGateway(name='me')
> print dborder.prints
>
> The last statement gives this error:
> psycopg.ProgrammingError: ERROR: column "order_gateway_id" does not exist
It seems that you've had hit the same problem I had last week. I have
posted a few messages here; in the last one there is a suggestion for
a ammendment to the documentation, in the tutorial part. I don't know
if Ian has read it though.
> I can fix it by renaming column order to order_gateway, but I don't want
> to. I also can't rename OrderGateway class to Order class because than I
> would get a clash with SQL reserved keyword and anyway, I don't want to
> neither. ;-)
The solution is simple -- use the joinColumn argument in your
MultipleJoin entry, as follows:
class OrderGateway(SQLObject):
name = StringCol()
prints = MultipleJoin('PrintGateway', joinColumn='order')
class PrintGateway(SQLObject):
size = StringCol()
order = ForeignKey('OrderGateway')
--
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: car...@gm...
mail: car...@ya...
|