Hi all!
I'd like to use a related join with a custom join table and non-standard
property names on the join table. Something like this:
# ----------------------------------
class VoidFoo(sqlobject.SQLObject):
fooDooh = sqlobject.ForeignKey('Foo')
voidDooh = sqlobject.ForeignKey('Void')
class Void(sqlobject.SQLObject):
foos = sqlobject.SQLRelatedJoin('Foo', intermediateTable = 'void_foo',
otherColumn = 'foo_dooh_id', createRelatedTable = False)
class Foo(sqlobject.SQLObject):
voids = sqlobject.SQLRelatedJoin('Void', intermediateTable =
'void_foo', otherColumn = 'void_dooh_id', createRelatedTable = False)
Void.createTable()
Foo.createTable()
VoidFoo.createTable()
foo = Foo()
foo.addVoid(Void())
# ----------------------------------
This is the SQL output:
1/Query : ALTER TABLE void_foo ADD CONSTRAINT
void_foo_foo_dooh_id_exists FOREIGN KEY (foo_dooh_id) REFERENCES foo (id)
1/Query : ALTER TABLE void_foo ADD CONSTRAINT
void_foo_void_dooh_id_exists FOREIGN KEY (void_dooh_id) REFERENCES void
(id)
1/QueryIns: INSERT INTO foo () VALUES ()
1/QueryOne: SELECT NULL FROM foo WHERE id = (1)
1/QueryIns: INSERT INTO void () VALUES ()
1/QueryOne: SELECT NULL FROM void WHERE id = (1)
1/Query : INSERT INTO void_foo (foo_id, void_dooh_id) VALUES (1, 1)
And that's the error I'm getting:
sqlobject.dberrors.OperationalError: Unknown column 'foo_id' in 'field
list'
Apparently, the fooDoo isn't properly resolved to foo_doo_id but instead to
its default name foo_id. Is this a bug or am I just doing something wrong?
Thanks a lot!
Bernhard
___________________________________________________________________
Disclaimer:
Diese Mitteilung ist nur fuer die Empfaengerin / den Empfaenger bestimmt.
Fuer den Fall, dass sie von nichtberechtigten Personen empfangen wird,
bitten wir diese hoeflich, die Mitteilung an die ZKB zurueckzusenden und
anschliessend die Mitteilung mit allen Anhaengen sowie allfaellige Kopien
zu vernichten bzw. zu loeschen. Der Gebrauch der Information ist verboten.
This message is intended only for the named recipient and may contain
confidential or privileged information.
If you have received it in error, please advise the sender by return e-mail
and delete this message and any attachments. Any unauthorised use or
dissemination of this information is strictly prohibited.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss