query works in 0.7.10 and not 0.8.7
The query works in 0.7.10 but not 0.8.7.
Code
from sqlalchemy import create_engine, Column, Date, Integer
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from datetime import date
Base = declarative_base()
class Test(Base):
__tablename__ = 'test'
id = Column(Integer, primary_key=True)
start_date = Column(Date)
engine = create_engine('sqlite:///')
session = sessionmaker()
session.configure(bind=engine)
Base.metadata.create_all(engine)
s = session()
s.query(Test).filter(date(2010, 1, 1) <= Test.start_date <= date(2010, 12, 31))
output when running:
```
Traceback (most recent call last): File "test.py", line 24, in <module> s.query(Test).filter(date(2010, 1, 1) <= Test.start_date <= date(2010, 12, 31)) File "build/bdist.linux-x86_64/egg/sqlalchemy/sql/expression.py", line 4479, in nonzero TypeError: Boolean value of this clause is not defined Traceback (most recent call last): File "test.py", line 24, in <module> s.query(Test).filter(date(2010, 1, 1) <= Test.start_date <= date(2010, 12, 31)) File "build/bdist.linux-x86_64/egg/sqlalchemy/sql/expression.py", line 4479, in nonzero TypeError: Boolean value of this clause is not defined
Comments (3)
-
repo owner -
repo owner here's 0.7 - it's wrong:
Python 2.7.5 (default, Mar 7 2014, 19:17:16) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from sqlalchemy import Column, DateTime >>> col = Column('x', DateTime) >>> import datetime >>> print datetime.date(2010, 1, 1) <= col <= datetime.date(2010, 12, 31) x >= :x_1 >>>
so SQLA 0.9's behavior of raising is correct here (we can't override a Python expression of this form).
-
repo owner - changed status to closed
your app is failing on 0.7 as well, just silently. sorry !
- Log in to comment
saw this on the mailing list, and the answer given is correct. this can't work (and probably isn't working in your 0.7 app):
please do: