Hello all
I need to perform multiple left joins in a single query and am getting
errors. This is my code:
#******************************
from sqlobject import *
from sqlobject.sqlbuilder import *
sqlhub.processConnection =
connectionForURI("mysql://platodbuser:[EMAIL
PROTECTED]/Delme?charset=latin1&sqlobject_encoding=latin-1")
class Object(SQLObject):
attributes = SQLMultipleJoin('Attribute')
class Attribute(SQLObject):
object = ForeignKey('Object')
name = StringCol()
value = FloatCol()
Object.createTable(ifNotExists = True)
Attribute.createTable(ifNotExists = True)
attr1 = Alias(Attribute, 'attr1')
attr2 = Alias(Attribute, 'attr2')
sel = Object.select(
clause = AND(attr1.q.value > 2.0, attr2.q.value < 5.0)
, join = [ LEFTJOINOn(Object, attr1, Object.q.id == attr1.q.objectID)
, LEFTJOINOn(Object, attr2, Object.q.id == attr2.q.objectID)
]
)
print list(sel)
#******************************
The resulting SQL is
SELECT object.id FROM object
LEFT JOIN attribute attr1 ON ((object.id) = (attr1.object_id)), object
LEFT JOIN attribute attr2 ON ((object.id) = (attr2.object_id))
WHERE (((attr1.value) > (2.0)) AND ((attr2.value) < (5.0)))
As you can see, there is a second ", object" before the second join. Why is
that? If I can tell correctly, this one is superfluous, right? Am I doing
something wrong (e.g. is it even allowed to pass a list of joins to join?)
or how can I do this correctly?
I'm on sqlobject version 0.9.0.1.
Thanks for your comments
Bernhard
And, I apologize for the mess that's following, but, really, I can't turn
it off... :-).
___________________________________________________________________
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.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss