if opt in ('DATA_DIRECTORY', 'INDEX_DIRECTORY',
'DEFAULT_CHARACTER_SET', 'CHARACTER_SET',
'DEFAULT_CHARSET',
- 'DEFAULT_COLLATE'):
+ 'DEFAULT_COLLATE', 'PARTITION_BY'):
opt = opt.replace('_', ' ')
joiner = '='
if opt in ('TABLESPACE', 'DEFAULT CHARACTER SET',
- 'CHARACTER SET', 'COLLATE'):
+ 'CHARACTER SET', 'COLLATE', 'PARTITION BY', 'PARTITIONS'):
joiner = ' '
table_opts.append(joiner.join((opt, arg)))
'KEY idx_autoinc_order (`order`)'
')ENGINE=InnoDB')
+ def test_create_table_with_partition(self):
+ t1 = Table(
+ 'testtable', MetaData(),
+ Column('id', Integer(), primary_key=True, autoincrement=True),
+ Column('other_id', Integer(), primary_key=True, autoincrement=False),
+ mysql_partitions='2', mysql_partition_by='KEY(other_id)')
+ self.assert_compile(
+ schema.CreateTable(t1),
+ 'CREATE TABLE testtable ('
+ 'id INTEGER NOT NULL AUTO_INCREMENT, '
+ 'other_id INTEGER NOT NULL, '
+ 'PRIMARY KEY (id, other_id)'
+ ')PARTITION BY KEY(other_id) PARTITIONS 2'
+ )
+
+ def test_create_table_with_partition_hash(self):
+ t1 = Table(
+ 'testtable', MetaData(),
+ Column('id', Integer(), primary_key=True, autoincrement=True),
+ Column('other_id', Integer(), primary_key=True, autoincrement=False),
+ mysql_partitions='2', mysql_partition_by='HASH(other_id)')
+ self.assert_compile(
+ schema.CreateTable(t1),
+ 'CREATE TABLE testtable ('
+ 'id INTEGER NOT NULL AUTO_INCREMENT, '
+ 'other_id INTEGER NOT NULL, '
+ 'PRIMARY KEY (id, other_id)'
+ ')PARTITION BY HASH(other_id) PARTITIONS 2'
+ )
+