Re: [Sqlalchemy-tickets] [sqlalchemy] #2813: Buglette with annotated join condition
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-08-27 18:34:27
|
#2813: Buglette with annotated join condition
----------------------------------+------------------------------------
Reporter: dairiki | Owner: zzzeek
Type: defect | Status: new
Priority: lowest | Milestone: 0.8.xx
Component: orm | Severity: no triage selected yet
Resolution: | Keywords:
Progress State: awaiting triage |
----------------------------------+------------------------------------
Comment (by zzzeek):
yeah not sure how to handle this, annotation() makes a copy of the Column,
and in this case it's copying it before it gets a table assigned.
If you use this patch:
{{{
#!diff
diff --git a/lib/sqlalchemy/orm/relationships.py
b/lib/sqlalchemy/orm/relationships.py
index f37bb8a..7d8a97d 100644
--- a/lib/sqlalchemy/orm/relationships.py
+++ b/lib/sqlalchemy/orm/relationships.py
@@ -1866,6 +1866,8 @@ class JoinCondition(object):
def _has_annotation(self, clause, annotation):
for col in visitors.iterate(clause, {}):
if annotation in col._annotations:
+ if col.table is None:
+ raise sa_exc.ArgumentError("column %s doesn't have a
Table" % col)
return True
else:
}}}
it raises an error, but this isn't great.
the workaround is to use a string, `primaryjoin="(remote(TableOne.x) ==
foreign(TableTwo.x))"`.
i might have realized this issue a while back but i dont have a good idea
how to deal with it.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2813#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|