text += self.define_constraint_deferrability(constraint)
return text
+ def post_create_table(self, table):
+ table_opts = []
+ if table.dialect_options['postgresql']['tablespace']:
+ table_opts.append('TABLESPACE %s' % table.dialect_options['postgresql']['tablespace'])
+
+ return ' '.join(table_opts)
+
class PGTypeCompiler(compiler.GenericTypeCompiler):
"ops": {}
}),
(schema.Table, {
- "ignore_search_path": False
+ "ignore_search_path": False,
+ "tablespace": None
})
]
"VARCHAR(1), CHECK (somecolumn IN ('x', "
"'y', 'z')))")
+ def test_create_table_with_tablespace(self):
+ m = MetaData()
+ tbl = Table('atable', m, Column("id", Integer), postgresql_tablespace = 'sometablespace')
+ self.assert_compile(schema.CreateTable(tbl),
+ "CREATE TABLE atable (id INTEGER)TABLESPACE sometablespace")
+
def test_create_partial_index(self):
m = MetaData()
tbl = Table('testtbl', m, Column('data', Integer))