diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-02-19 15:24:36 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-02-19 15:24:36 -0500 |
commit | 7e66d7e392138caf2a57be53f2498e6098c30187 (patch) | |
tree | faee6dc8192331180a5132d0262fe3c4cd0cf3b1 | |
parent | 77ed03652580c5db925729c573b76ca32393dc67 (diff) | |
parent | c597843f137b2b3ff90e648e7507dd1f325d4f48 (diff) | |
download | sqlalchemy-7e66d7e392138caf2a57be53f2498e6098c30187.tar.gz |
Merge branch 'master' of https://bitbucket.org/50onred/sqlalchemy/overview into t
-rw-r--r-- | lib/sqlalchemy/dialects/mysql/base.py | 4 | ||||
-rw-r--r-- | test/dialect/mysql/test_compiler.py | 30 |
2 files changed, 32 insertions, 2 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index aafb8bec4..c557d3b6f 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -1640,12 +1640,12 @@ class MySQLDDLCompiler(compiler.DDLCompiler): 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))) diff --git a/test/dialect/mysql/test_compiler.py b/test/dialect/mysql/test_compiler.py index 45f8405c8..24e203317 100644 --- a/test/dialect/mysql/test_compiler.py +++ b/test/dialect/mysql/test_compiler.py @@ -476,3 +476,33 @@ class SQLTest(fixtures.TestBase, AssertsCompiledSQL): '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' + ) + |