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:paiJohr2@db-server/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

Thanks for your comments


And, I apologize for the mess that's following, but, really, I can't turn it off... :-).


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.