From 0174d698a8ed155b51cc44c503b10bc67b16dfc9 Mon Sep 17 00:00:00 2001 From: Vsevolod Solovyov Date: Thu, 15 Mar 2018 09:00:47 -0400 Subject: Add support for declarative partitioning in PostgreSQL 10 Added support for "PARTITION BY" in Postgresql table definitions, using "postgresql_partition_by". Pull request courtesy Vsevolod Solovyov. Change-Id: Id74d6882d7193fae1e5fd44b6e12d6852866fcc4 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/430 --- test/dialect/postgresql/test_compiler.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/dialect/postgresql/test_compiler.py') diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index db142a657..66764fcc2 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -233,6 +233,26 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): '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( -- cgit v1.2.1