on_commit_options = table.dialect_options['postgresql']['on_commit'].replace("_", " ").upper()
table_opts.append('ON COMMIT %s' % on_commit_options)
if table.dialect_options['postgresql']['tablespace']:
- table_opts.append('TABLESPACE %s' % table.dialect_options['postgresql']['tablespace'])
+ tablespace_name = table.dialect_options['postgresql']['tablespace']
+ table_opts.append('TABLESPACE %s' % self.preparer.quote(tablespace_name))
return ' '.join(table_opts)
self.assert_compile(schema.CreateTable(tbl),
"CREATE TABLE atable (id INTEGER)TABLESPACE sometablespace")
+ # testing quoting of tablespace name
+ tbl = Table('anothertable', m, Column("id", Integer), postgresql_tablespace = 'table')
+ self.assert_compile(schema.CreateTable(tbl),
+ 'CREATE TABLE anothertable (id INTEGER)TABLESPACE "table"')
+
def test_create_table_with_oids(self):
m = MetaData()
tbl = Table('atable', m, Column("id", Integer), postgresql_withoids = True, )