has_table() property works again. Regression from
0.6.3 (we don't have a Jython buildbot, sorry)
[ticket:1960]
+
+- sqlite
+ - The REFERENCES clause in a CREATE TABLE that includes
+ a remote schema name now renders the remote name without
+ the schema clause, as required by SQLite. [ticket:1851]
+
0.6.5
=====
return super(SQLiteDDLCompiler, self).\
visit_primary_key_constraint(constraint)
+ def define_constraint_remote_table(self, constraint, table, preparer):
+ """Format the remote table clause of a CREATE CONSTRAINT clause."""
+
+ return preparer.format_table(table, use_schema=False)
def visit_create_index(self, create):
index = create.element
text += "FOREIGN KEY(%s) REFERENCES %s (%s)" % (
', '.join(preparer.quote(f.parent.name, f.parent.quote)
for f in constraint._elements.values()),
- preparer.format_table(remote_table),
+ self.define_constraint_remote_table(constraint, remote_table, preparer),
', '.join(preparer.quote(f.column.name, f.column.quote)
for f in constraint._elements.values())
)
text += self.define_constraint_deferrability(constraint)
return text
+ def define_constraint_remote_table(self, constraint, table, preparer):
+ """Format the remote table clause of a CREATE CONSTRAINT clause."""
+
+ return preparer.format_table(table)
+
def visit_unique_constraint(self, constraint):
text = ""
if constraint.name is not None:
"SELECT CAST(STRFTIME('%s', t.col1) AS "
"INTEGER) AS anon_1 FROM t" % subst)
+ def test_constraints_with_schemas(self):
+ metadata = MetaData()
+ t1 = Table('t1', metadata,
+ Column('id', Integer, primary_key=True),
+ schema='master')
+ t2 = Table('t2', metadata,
+ Column('id', Integer, primary_key=True),
+ Column('t2_id', Integer, ForeignKey('master.t1.id')),
+ schema='master'
+ )
+
+ self.assert_compile(
+ schema.CreateTable(t2),
+ "CREATE TABLE master.t2 ("
+ "id INTEGER NOT NULL, "
+ "t2_id INTEGER, "
+ "PRIMARY KEY (id), "
+ "FOREIGN KEY(t2_id) REFERENCES t1 (id)"
+ ")"
+ )
+
class InsertTest(TestBase, AssertsExecutionResults):