Re: [SQLObject] More about Inheritance
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <jpa...@ya...> - 2005-02-25 18:19:28
|
Hi! --- Oleg Broytmann <ph...@ma...> escreveu: > On Thu, Feb 24, 2005 at 05:54:29PM -0300, Jo?o Paulo F Farias wrote: > > I've made 3 classes: A, B, C, as follows: > > > > class A(SQLObject): > > b = ForeignKey('B') > > > > class B(InheritableSQLObject): > > x = IntCol() > > It is not enough to inherit InheritableSQLObject. You also need to > mark the table as inheritable: > > class B(InheritableSQLObject): > _inheritable = True > > > class C(B): > > y = IntCol() > > If this is the last class in the hierarchy - unmark it: > > class C(InheritableSQLObject): > _inheritable = False > > > Then I've inserted a C object, like this: > > c = C(x=10, y=20) > > > > And tried to create an A object: > > a = A(b=c) > > > > Here I got an error... > > Which one? The error is about foreign key constraints, as the B table has no rows, when I do: A(b=c), it looks on B table for a row with id == c.id, but there are none (this is what I think it does). Also, I've put the _inheritable and _connection on my classes, I've ommited them on the email for the sake of simplicity. ;) -- JP > > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > ===== ----------------------------------- João Paulo F Farias jpa...@ya... ----------------------------------- _______________________________________________________ Yahoo! Acesso Grátis - Instale o discador do Yahoo! agora. http://br.acesso.yahoo.com/ - Internet rápida e grátis |