summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-08-23 15:21:16 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-08-23 15:21:16 -0400
commitb490534657229cbc44f1f5735a39539ceaf776a3 (patch)
treebae34903b54189215938b55455443b822a70ff33 /test/dialect/postgresql/test_compiler.py
parentfaa5a9067661039dcc8663e00bdcea2d098c9989 (diff)
downloadsqlalchemy-b490534657229cbc44f1f5735a39539ceaf776a3.tar.gz
- pep8 formatting for pg table opts feature, tests
- add support for PG INHERITS - fix mis-named tests - changelog fixes #2051
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r--test/dialect/postgresql/test_compiler.py95
1 files changed, 73 insertions, 22 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py
index 5d1fddb49..6c4f3c8cc 100644
--- a/test/dialect/postgresql/test_compiler.py
+++ b/test/dialect/postgresql/test_compiler.py
@@ -168,37 +168,88 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
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")
+ 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
- tbl = Table('anothertable', m, Column("id", Integer), postgresql_tablespace = 'table')
- self.assert_compile(schema.CreateTable(tbl),
- 'CREATE TABLE anothertable (id INTEGER)TABLESPACE "table"')
+ 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")
+ 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")
+ 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 create_table_with_oncommit_option(self):
+ 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 create_table_with_multiple_options(self):
+ 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")
-
+ 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))