diff options
author | Rodrigo Menezes <rodrigo.menezes@moat.com> | 2014-08-26 12:57:00 -0400 |
---|---|---|
committer | Rodrigo Menezes <rodrigo.menezes@moat.com> | 2014-08-26 12:57:00 -0400 |
commit | b3f7cd8bf497febb80e6cd7dc39effc75ff1a7e7 (patch) | |
tree | e3a022b20405768bb4e1912c9a2f1347b751d64c /test/dialect/postgresql/test_compiler.py | |
parent | bcf7a55da01633c4890502463a08cb96af9fe5e9 (diff) | |
parent | 8e84942aa6fa2644b3fe6407c79449715a7e2c8c (diff) | |
download | sqlalchemy-b3f7cd8bf497febb80e6cd7dc39effc75ff1a7e7.tar.gz |
Merge branch 'master' of https://github.com/zzzeek/sqlalchemy into feature/postgres-relkind
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r-- | test/dialect/postgresql/test_compiler.py | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index b08fb0160..6c4f3c8cc 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -166,6 +166,90 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): "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_table_with_tablespace_quoted(self): + # testing quoting of tablespace name + m = MetaData() + 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_inherits(self): + m = MetaData() + tbl = Table( + 'atable', m, Column("id", Integer), + postgresql_inherits='i1') + self.assert_compile( + schema.CreateTable(tbl), + "CREATE TABLE atable (id INTEGER) INHERITS ( i1 )") + + def test_create_table_inherits_tuple(self): + m = MetaData() + tbl = Table( + 'atable', m, Column("id", Integer), + postgresql_inherits=('i1', 'i2')) + self.assert_compile( + schema.CreateTable(tbl), + "CREATE TABLE atable (id INTEGER) INHERITS ( i1, i2 )") + + def test_create_table_inherits_quoting(self): + m = MetaData() + tbl = Table( + 'atable', m, Column("id", Integer), + postgresql_inherits=('Quote Me', 'quote Me Too')) + self.assert_compile( + schema.CreateTable(tbl), + 'CREATE TABLE atable (id INTEGER) INHERITS ' + '( "Quote Me", "quote Me Too" )') + + def test_create_table_with_oids(self): + m = MetaData() + tbl = Table( + 'atable', m, Column("id", Integer), + postgresql_with_oids=True, ) + self.assert_compile( + schema.CreateTable(tbl), + "CREATE TABLE atable (id INTEGER) WITH OIDS") + + tbl2 = Table( + 'anothertable', m, Column("id", Integer), + postgresql_with_oids=False) + self.assert_compile( + schema.CreateTable(tbl2), + "CREATE TABLE anothertable (id INTEGER) WITHOUT OIDS") + + def test_create_table_with_oncommit_option(self): + m = MetaData() + tbl = Table( + 'atable', m, Column("id", Integer), + postgresql_on_commit="drop") + self.assert_compile( + schema.CreateTable(tbl), + "CREATE TABLE atable (id INTEGER) ON COMMIT DROP") + + def test_create_table_with_multiple_options(self): + m = MetaData() + tbl = Table( + 'atable', m, Column("id", Integer), + postgresql_tablespace='sometablespace', + postgresql_with_oids=False, + postgresql_on_commit="preserve_rows") + self.assert_compile( + schema.CreateTable(tbl), + "CREATE TABLE atable (id INTEGER) WITHOUT OIDS " + "ON COMMIT PRESERVE ROWS TABLESPACE sometablespace") + def test_create_partial_index(self): m = MetaData() tbl = Table('testtbl', m, Column('data', Integer)) |