--- /dev/null
+.. change::
+ :tags: feature, postgresql
+ :versions: 1.3.0b1
+
+ Added support for "PARTITION BY" in Postgresql table definitions,
+ using "postgresql_partition_by". Pull request courtesy
+ Vsevolod Solovyov.
Table("some_table", metadata, ..., postgresql_inherits=("t1", "t2", ...))
-.. versionadded:: 1.0.0
+ .. versionadded:: 1.0.0
+
+* ``PARTITION BY``::
+
+ Table("some_table", metadata, ...,
+ postgresql_partition_by='LIST (part_column)')
+
+ .. versionadded:: 1.2.6
.. seealso::
', '.join(self.preparer.quote(name) for name in inherits) +
' )')
+ if pg_opts['partition_by']:
+ table_opts.append('\n PARTITION BY %s' % pg_opts['partition_by'])
+
if pg_opts['with_oids'] is True:
table_opts.append('\n WITH OIDS')
elif pg_opts['with_oids'] is False:
(schema.Table, {
"ignore_search_path": False,
"tablespace": None,
+ "partition_by": None,
"with_oids": None,
"on_commit": None,
"inherits": None
'CREATE TABLE atable (id INTEGER) INHERITS '
'( "Quote Me", "quote Me Too" )')
+ def test_create_table_partition_by_list(self):
+ m = MetaData()
+ tbl = Table(
+ 'atable', m, Column("id", Integer), Column("part_column", Integer),
+ postgresql_partition_by='LIST (part_column)')
+ self.assert_compile(
+ schema.CreateTable(tbl),
+ 'CREATE TABLE atable (id INTEGER, part_column INTEGER) '
+ 'PARTITION BY LIST (part_column)')
+
+ def test_create_table_partition_by_range(self):
+ m = MetaData()
+ tbl = Table(
+ 'atable', m, Column("id", Integer), Column("part_column", Integer),
+ postgresql_partition_by='RANGE (part_column)')
+ self.assert_compile(
+ schema.CreateTable(tbl),
+ 'CREATE TABLE atable (id INTEGER, part_column INTEGER) '
+ 'PARTITION BY RANGE (part_column)')
+
def test_create_table_with_oids(self):
m = MetaData()
tbl = Table(