Hi, in a working setup I added a ForeignKey to table 'cliente_cliente' as follows (client_id):
class Project(Base): __tablename__ = "ticket_project" __table_args__ = {'useexisting' : True} id = Column(Integer, primary_key=True) date_create = Column(Date(), server_default=text("CURRENT_TIMESTAMP"), nullable=False) date_last_modify = Column(Date(), onupdate=func.now(), default=func.now()) status = Column(ForeignKey('ticket_status.id'), nullable=False) name = Column(String(30), nullable=False) description = Column(Text, nullable=False) date_start = Column(Date, default=func.now()) date_end = Column(Date) client_id = Column(ForeignKey(Cliente.id), nullable=True) this brakes session.query(Project).... with the message I report below. Of course I *did* create new field on table in the Postgres database. Note that if I use autoload on all Tables everything works correctly, so I tend to think I made a mistake in the definition, but I already spent some hours w/o any better understanding. I'll try to reproduce the error on a simpler situation but is not that easy and I'd like to understand if the error message tells something that could address me to the solution thanks in advance sandro *:-) Traceback (most recent call last): File "/home/misc/src/hg/py/fossati/fossati/job.py", line 86, in jobs_mask m.reload() File "../../sqlkit/widgets/mask/mask.py", line 67, in reload File "/misc/src/hg/py/sqlkit/sqlkit/widgets/common/sqlwidget.py", line 703, in reload self.records = query.all() File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/orm/query.py", line 1007, in all return list(self) File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/orm/query.py", line 1097, in __iter__ context = self._compile_context() File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/orm/query.py", line 1569, in _compile_context from_clause = sql_util.splice_joins(from_clause, eager_join, eager_join.stop_on) File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/sql/util.py", line 252, in splice_joins right.onclause = adapter.traverse(right.onclause) File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/sql/visitors.py", line 158, in traverse return replacement_traverse(obj, self.__traverse_options__, replace) File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/sql/visitors.py", line 250, in replacement_traverse obj = clone(obj) File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/sql/visitors.py", line 241, in clone newelem = replace(element) File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/sql/visitors.py", line 155, in replace e = v.replace(elem) File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/sql/util.py", line 473, in replace return self._corresponding_column(col, True) File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/sql/util.py", line 451, in _corresponding_column newcol = self.selectable.corresponding_column(col, require_embedded=require_embedded) File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/sql/expression.py", line 1834, in corresponding_column if self.c.contains_column(column): File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/util.py", line 1358, in __get__ obj.__dict__[self.__name__] = result = self.fget(obj) File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/sql/expression.py", line 1867, in _columns self._export_columns() File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/sql/expression.py", line 1897, in _export_columns self._populate_column_collection() File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/sql/expression.py", line 2594, in _populate_column_collection for col in self.element.columns: File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/util.py", line 1358, in __get__ obj.__dict__[self.__name__] = result = self.fget(obj) File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/sql/expression.py", line 1867, in _columns self._export_columns() File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/sql/expression.py", line 1897, in _export_columns self._populate_column_collection() File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/sql/expression.py", line 3428, in _populate_column_collection c._make_proxy(self, name=self.use_labels and c._label or None) File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/schema.py", line 743, in _make_proxy [c._init_items(f) for f in fk] File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/schema.py", line 54, in _init_items item._set_parent(self) File "/home/misc/src/sqlalchemy/sqlalchemy-svn/lib/sqlalchemy/schema.py", line 929, in _set_parent self.parent.table.foreign_keys.remove(fk) KeyError: ForeignKey(u'cliente_cliente.id') -- Sandro Dentella *:-) http://sqlkit.argolinux.org SQLkit home page - PyGTK/python/sqlalchemy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---