summaryrefslogtreecommitdiff
path: root/test/dialect/test_sqlite.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-01-18 12:42:54 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2012-01-18 12:42:54 -0500
commit8c05a3bf6599f92bbf8d2246123597e8966f3a52 (patch)
treeec4be43a19f0ff4154d5588ebaeb143fa257e75e /test/dialect/test_sqlite.py
parentcd6e5d6dea83d5d5317765f14b15641fdf54ecc0 (diff)
downloadsqlalchemy-8c05a3bf6599f92bbf8d2246123597e8966f3a52.tar.gz
- [feature] Added "false()" and "true()" expression
constructs to sqlalchemy.sql namespace, though not part of __all__ as of yet. - [bug] sql.false() and sql.true() compile to 0 and 1, respectively in sqlite [ticket:2368]
Diffstat (limited to 'test/dialect/test_sqlite.py')
-rw-r--r--test/dialect/test_sqlite.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py
index 7a5953654..4fe67fd2e 100644
--- a/test/dialect/test_sqlite.py
+++ b/test/dialect/test_sqlite.py
@@ -259,6 +259,18 @@ class DefaultsTest(fixtures.TestBase, AssertsCompiledSQL):
finally:
db.execute("DROP TABLE r_defaults")
+ @testing.provide_metadata
+ def test_boolean_default(self):
+ t= Table("t", self.metadata,
+ Column("x", Boolean, server_default=sql.false()))
+ t.create(testing.db)
+ testing.db.execute(t.insert())
+ testing.db.execute(t.insert().values(x=True))
+ eq_(
+ testing.db.execute(t.select().order_by(t.c.x)).fetchall(),
+ [(False,), (True,)]
+ )
+
class DialectTest(fixtures.TestBase, AssertsExecutionResults):
@@ -440,6 +452,15 @@ class SQLTest(fixtures.TestBase, AssertsCompiledSQL):
"SELECT CAST(STRFTIME('%s', t.col1) AS "
"INTEGER) AS anon_1 FROM t" % subst)
+ def test_true_false(self):
+ self.assert_compile(
+ sql.false(), "0"
+ )
+ self.assert_compile(
+ sql.true(),
+ "1"
+ )
+
def test_constraints_with_schemas(self):
metadata = MetaData()
t1 = Table('t1', metadata,