wasn't implementing the sort properly, replaced
with the existing sort algorithm
+ - [bug] the "name" of a column-level CHECK constraint,
+ if present, is now rendered in the CREATE TABLE
+ statement using "CONSTRAINT <name> CHECK <expression>".
+ [ticket:2305]
+
- pyodbc
- [bug] pyodbc-based dialects now parse the
pyodbc accurately as far as observed
return text
def visit_column_check_constraint(self, constraint):
- text = "CHECK (%s)" % constraint.sqltext
+ text = ""
+ if constraint.name is not None:
+ text += "CONSTRAINT %s " % \
+ self.preparer.format_constraint(constraint)
+ text += "CHECK (%s)" % constraint.sqltext
text += self.define_constraint_deferrability(constraint)
return text
assert 'NOT DEFERRABLE' not in sql
assert 'INITIALLY DEFERRED' in sql
+ def test_column_level_ck_name(self):
+ t = Table('tbl', MetaData(),
+ Column('a', Integer, CheckConstraint("a > 5", name="ck_a_greater_five"))
+ )
+ self.assert_compile(
+ schema.CreateTable(t),
+ "CREATE TABLE tbl (a INTEGER CONSTRAINT "
+ "ck_a_greater_five CHECK (a > 5))"
+ )
def test_deferrable_pk(self):
factory = lambda **kw: PrimaryKeyConstraint('a', **kw)
self._test_deferrable(factory)
self.assert_compile(
schema.CreateTable(t),
- "CREATE TABLE tbl (a INTEGER, b INTEGER, FOREIGN KEY(b) REFERENCES tbl (a) DEFERRABLE INITIALLY DEFERRED)",
+ "CREATE TABLE tbl (a INTEGER, b INTEGER, "
+ "FOREIGN KEY(b) REFERENCES tbl "
+ "(a) DEFERRABLE INITIALLY DEFERRED)",
)
def test_deferrable_unique(self):