- [bug] ensure pickleability of all ORM exceptions
for multiprocessing compatibility. [ticket:2371]
+- sql
+ - [feature] Added "false()" and "true()" expression
+ constructs to sqlalchemy.sql namespace, though
+ not part of __all__ as of yet.
+
- engine
- [bug] Added __reduce__ to StatementError,
DBAPIError, column errors so that exceptions
SQLite does not appear to support constraint
naming in any case.
+ - [bug] sql.false() and sql.true() compile to
+ 0 and 1, respectively in sqlite [ticket:2368]
+
- mysql
- [bug] fixed regexp that filters out warnings
for non-reflected "PARTITION" directives,
def visit_now_func(self, fn, **kw):
return "CURRENT_TIMESTAMP"
+ def visit_true(self, expr, **kw):
+ return '1'
+
+ def visit_false(self, expr, **kw):
+ return '0'
+
def visit_char_length_func(self, fn, **kw):
return "length%s" % self.function_argspec(fn)
except_all,
exists,
extract,
+ false,
func,
insert,
intersect,
subquery,
table,
text,
+ true,
tuple_,
type_coerce,
union,
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):
"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,