- assigned issue to
pk bindparam expressions busted when constructing joins
Issue #768
resolved
Hi,
I have the following two tables (in MySql):
CREATE TABLE `A` (
`xkey` varchar(200) NOT NULL,
`yval` int(11) default NULL,
PRIMARY KEY (`xkey`)
) ENGINE=InnoDB;
and
CREATE TABLE `B` (
`xkey` varchar(200) NOT NULL default '',
`s` enum('yes','no') NOT NULL default 'yes',
PRIMARY KEY (`xkey`,`s`)
) ENGINE=InnoDB;
The following statement worked fine till 0.3.8 , and from 0.3.9 throws
the exception:
oj=outerjoin(A, B, and_(A.c.xkey==B.c.xkey, B.c.s=='yes'))
Traceback (most recent call last):
File "join.py", line 13, in ?
oj=outerjoin(A, B, and_(A.c.xkey==B.c.xkey, B.c.s=='yes'))
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.3.9-
py2.4.egg/sqlalchemy/sql.py", line 117, in outerjoin
return Join(left, right, onclause, isouter = True, **kwargs)
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.3.9-
py2.4.egg/sqlalchemy/sql.py", line 2256, in __init__
self._init_primary_key()
File "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.3.9-
py2.4.egg/sqlalchemy/sql.py", line 2287, in _init_primary_key
if p.references(c) or (c.primary_key and not p.primary_key):
AttributeError: '_BindParamClause' object has no attribute
'primary_key'
Note, if B.s were not an enum but a varchar, it would have worked.
Comments (6)
-
reporter -
- assigned issue to
- changed component to sql
- changed title to pk bindparam expressions busted when constructing joins
t = Table('t', MetaData(), Column('a', Integer, primary_key=True)) print join(t, t, t.c.a==12)
-
reporter i see the issue here (just do a getattr instead of x.primary_key), but how come changing from "enum" to "varchar" works ? is that not the case ?
-
It's not the case. It doesn't matter what the type of the column is, so long as it's a member of the primary key.
-
reporter - changed status to resolved
-
reporter - removed milestone
Removing milestone: 0.4.0 (automated comment)
- Log in to comment