Last active
August 29, 2015 14:06
-
-
Save peterdemin/7afff3d66b657de3fb40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# regression test for https://bitbucket.org/zzzeek/sqlalchemy/issue/2682/is_-and-isnot-in-conjunction-with-boolean | |
from sqlalchemy import create_engine, Column, Integer, Boolean | |
from sqlalchemy.orm import sessionmaker | |
from sqlalchemy.ext.declarative import declarative_base | |
Base = declarative_base() | |
engine = create_engine('mysql://user:password@localhost/mre') | |
Session = sessionmaker(bind=engine) | |
class MyTable(Base): | |
__tablename__ = 'my_table' | |
id = Column(Integer, primary_key=True) | |
is_cool = Column(Boolean, default=False) | |
session = Session() | |
Base.metadata.create_all(engine) | |
session.add_all([ | |
MyTable(is_cool=False), | |
MyTable(is_cool=True), | |
MyTable(is_cool=False), | |
]) | |
cools = session.query(MyTable).filter(MyTable.is_cool.is_(True)).all() | |
assert len(cools) == 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment