I did a forward to SQLObject-Discuss just after sending my message... ;-)
I'm forwarding your message on to the SQLObject list for further review.
Does your patch include unit tests?
---------- Forwarded message ----------
From: Joćo Paulo Fernandes Farias < firstname.lastname@example.org>
Date: Oct 2, 2005 9:09 AM
Subject: [TurboGears] Re: How to create tables with cyclic references?
I've patched SQLObject to do late reference on creation of tables.
It is no 100%, but it is a starting point.
I've attached the patch.
On 10/1/05, Ian Bicking <email@example.com> wrote:
> Joćo Paulo Fernandes Farias wrote:
> > Hi!
> > How do I create tables with cyclic references?
> > As an example, suppose we have two classes:
> > class A(SQLObject):
> > b = ForeignKey('B')
> > class B(SQLObject):
> > a = ForeignKey('A')
> > /me using turbogears...
> > I issue a: turbogears-admin.py sql create
> > It gives me some erros because it tries to create table A but B does not
> > exists, so it cannot be referenced.
> > My suggestion is: Create all tables and then issue all the "alter table
> > add constraint" as necessary.
> This is kind of hard. Technically you can do it like:
> class A(SQLObject):
> b = ForeignKey('B')
> class B(SQLObject):
> def create():
> B.sqlmeta.addColumn (ForeignKey(name='a', foreignKey='A'),
> However, this won't work with sqlobject-admin (and thus
Author of the Zesty News RSS newsreader