Adam Tauno Williams wrote: > x3 = join(x1, x2) join() here is:
http://www.sqlalchemy.org/docs/reference/sqlalchemy/expressions.html#sqlalchemy.sql.expression.join it knows nothing about classes "x1" and "x2" and interprets them as text. You want here to be using: http://www.sqlalchemy.org/docs/reference/orm/query.html#sqlalchemy.orm.join if you upgrade to a recent 0.5 (highly recommended as 0.5.4 is ancient) the "orm.join" function will come into your imports via "from sqlalchemy.orm import *". > > class Action(Base): > """ An OpenGroupare Task History Info entry """ > __table__ = x3 > > Session = sessionmaker() > Session.configure(bind=engine) > db = Session() > > z = Action() > z.job_id = 1 > z.comment = 'TEST TEST TEST' > z.actor_id = 0 > z.action = 'test' > db.add(z) > > db.commit() > ------------------------------------------------------ > > Why does this work in straight mapper code but not work in declarative? > This seems like a 1:1 correspondence. > > STACK TRACE > ---------------------------------------------------- > Traceback (most recent call last): > File "./dec.py", line 26, in <module> > x3 = join(x1, x2) > File > "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/sqlalchemy/sql/expression.py", > line 123, in join > return Join(left, right, onclause, isouter) > File > "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/sqlalchemy/sql/expression.py", > line 2506, in __init__ > self.onclause = self._match_primaries(self.left, self.right) > File > "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/sqlalchemy/sql/expression.py", > line 2552, in _match_primaries > return sql_util.join_condition(primary, secondary) > File > "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/sqlalchemy/sql/util.py", > line 100, in join_condition > for fk in b.foreign_keys: > AttributeError: '_TextClause' object has no attribute 'foreign_keys' > awill...@linux-m3mt:~> > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
