On Tue, Aug 12, 2008 at 06:18:39PM +0200, Luis Javier Peris wrote:
> I'd like to know if there is a restriction using inheritance about
> multiplejoin function because I'm getting an error and I don't know why.
> I've the following code:
>
> class Question(InheritableSQLObject):
> filename = StringCol(default=None, length=255, unique=True)
> title = StringCol(default=None)
> default_mark = FloatCol(default=0.0)
> wording = RelatedJoin('Content')
> term_questions = RelatedJoin('Term', joinColumn='term',
> otherColumn='question',
> intermediateTable='Term_questions')
> answers = MultipleJoin('Answer')
> questionref = MultipleJoin('QuestionRef')
>
>
> class Answer(SQLObject):
> value = StringCol(default=None)
> calification = FloatCol(default=None)
> ide = StringCol(default=None)
> question = ForeignKey('Question')
>
>
> class Ord(Question):
> _inheritable = False
> shuffle = BoolCol()
> orderanswers = MultipleJoin('OrderChoice')
>
>
> class OrderChoice(SQLObject):
> value = StringCol(default=None)
> ord = IntCol(default=None)
> ide = StringCol(default=None)
> question = ForeignKey('Ord')
>
> and when I've a Ord instance (called 'q') and I do 'q.orderanswers' I get
> the following error:
>
> sqlobject.dberrors.OperationalError: Unknown column 'ord_id' in 'where
> clause'
It has nothing with inheritance. I simplified the program (you have to
do this yourself) to:
class Ord(SQLObject):
orderanswers = MultipleJoin('OrderChoice')
class OrderChoice(SQLObject):
question = ForeignKey('Ord')
Ord.createTable()
OrderChoice.createTable()
ord = Ord()
print ord.orderanswers
and got the same error. Well, with this simple program and SQL it
generates it easy to see where is the problem:
1/QueryR : CREATE TABLE ord (
id INTEGER PRIMARY KEY
)
2/QueryR : CREATE TABLE order_choice (
id INTEGER PRIMARY KEY,
question_id INT CONSTRAINT question_id_exists REFERENCES ord(id)
)
3/QueryR : INSERT INTO ord VALUES (NULL)
4/QueryR : SELECT NULL FROM ord WHERE ((ord.id) = (1))
5/QueryR : SELECT id FROM order_choice WHERE ord_id = (1)
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss