for database load on the next object-wide unexpire, when the object
were merged into the session with ``session.merge(obj, load=False)``.
+ .. change::
+ :tags: feature, sql
+ :pullreq: github:275
+
+ Added a hook in :meth:`.DDLCompiler.visit_create_table` called
+ :meth:`.DDLCompiler.create_table_suffix`, allowing custom dialects
+ to add keywords after the "CREATE TABLE" clause. Pull request
+ courtesy Mark Sandan.
+
.. change::
:tags: feature, sql
:pullreq: github:231
text = "\nCREATE "
if table._prefixes:
text += " ".join(table._prefixes) + " "
- text += "TABLE " + preparer.format_table(table) + " ("
+ text += "TABLE " + preparer.format_table(table) + " "
+
+ create_table_suffix = self.create_table_suffix(table)
+ if create_table_suffix:
+ text += create_table_suffix + " "
+
+ text += "("
separator = "\n"
colspec += " NOT NULL"
return colspec
+ def create_table_suffix(self, table):
+ return ''
+
def post_create_table(self, table):
return ''
"PRIMARY KEY (b, a))"
)
+ def test_create_table_suffix(self):
+ class MyDialect(default.DefaultDialect):
+ class MyCompiler(compiler.DDLCompiler):
+ def create_table_suffix(self, table):
+ return 'SOME SUFFIX'
+
+ ddl_compiler = MyCompiler
+
+ m = MetaData()
+ t1 = Table('t1', m, Column('q', Integer))
+ self.assert_compile(
+ schema.CreateTable(t1),
+ "CREATE TABLE t1 SOME SUFFIX (q INTEGER)",
+ dialect=MyDialect()
+ )
+
def test_table_no_cols(self):
m = MetaData()
t1 = Table('t1', m)