[SQLObject] Problem Creating the "Same" ForeignKey Twice
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Brad B. <br...@bb...> - 2003-10-14 17:58:38
|
Hi, I have a class like this: class Refund(SQLObject): """A transaction where somebody was given some or all of their money back for previous Purchase.""" ...[snip overriding of new and a couple class variables]... transactionID = ForeignKey('Transaction') refundedTransactionID = ForeignKey('Transaction') The first FK pointing to Transaction, represents the transaction that took place to do this refund. The second FK, also pointing to Transaction (refundedTransactionID), represents the transaction for which the refund was done. So, I need to have two FK's pointing to the same relation, each one, of course, pointing to a different row in the foreign relation (the transaction table.) When I create the refund table with only one of the ForeignKey()s present, it works fine, but if I try to create it (calling createTable) with both defined as above, I get: Traceback (most recent call last): File "lib/merchant.py", line 252, in ? class Refund(SQLObject): File "../SQLObject/SQLObject.py", line 233, in __new__ File "../SQLObject/SQLObject.py", line 503, in addColumn File "../SQLObject/SQLObject.py", line 102, in addNeedSet File "../SQLObject/SQLObject.py", line 404, in __new__ File "../SQLObject/SQLObject.py", line 662, in _init File "../SQLObject/DBConnection.py", line 254, in _SO_selectOne File "../SQLObject/SQLBuilder.py", line 126, in sqlRepr ValueError: Unknown SQL builtin type: <class 'SQLObject.SQLObject.MetaSQLObject'> for <class '__main__.Transaction'> Is there a known restriction/reason for why I can't have two FK's in A that both point to B, or is this a bug? -- Brad Bollenbach BBnet.ca |