- attached testcase.py
case() with a not_(...) condition throws exception
Issue #1661
resolved
The code:
case([ (not_(foo.c.x), 42) ])
Expected: statement like CASE WHEN NOT foo.x THEN 42 END
Observed this exception instead:
Traceback (most recent call last):
File "/tmp/testcase.py", line 10, in <module>
(not_(foo.c.x), 42),
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/sqlalchemy/sql/expression.py", line 466, in case
return _Case(whens, value=value, else_=else_)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/sqlalchemy/sql/expression.py", line 2205, in __init__
whenlist = [_literal_as_binds(r)) for (c, r) in whens]((_no_literals(c).self_group(),)
TypeError: self_group() takes exactly 2 arguments (1 given)
Minimal test case is attached.
Versions: OS X 10.5, Python 2.6.4 from MacPorts, SQLAlchemy 0.5.8.
For what it's worth, my uninformed guess would be that _UnaryExpression.self_group
needs to default against=None
(like I see a few other places doing).
(SQLAlchemy rocks. Thanks!)
Comments (6)
-
Account Deleted -
repo owner - changed milestone to 0.5.8
-
repo owner - changed milestone to 0.5.9
-
repo owner fixed in 0.6 in bf163f02378e5e3523c28f16c09d39a8a0dd90d2
-
repo owner - changed status to resolved
-
repo owner - removed milestone
Removing milestone: 0.5.9 (automated comment)
- Log in to comment
Minimal test case to reproduce this bug