diff --git a/pg4wp/rewriters/CreateTableSQLRewriter.php b/pg4wp/rewriters/CreateTableSQLRewriter.php index 0e26ba4..3a1dcb8 100644 --- a/pg4wp/rewriters/CreateTableSQLRewriter.php +++ b/pg4wp/rewriters/CreateTableSQLRewriter.php @@ -21,8 +21,8 @@ class CreateTableSQLRewriter extends AbstractSQLRewriter ' CHARACTER SET utf8' => '', ' DEFAULT CHARSET=utf8' => '', - // For flash-album-gallery plugin - ' tinyint' => ' smallint' + ' tinyint' => ' smallint', + ' mediumint' => ' integer' ]; public function rewrite(): string @@ -96,7 +96,7 @@ class CreateTableSQLRewriter extends AbstractSQLRewriter $numeric_types_imploded = implode('|', $numeric_types); // Prepare regex pattern to match 'type(x)' - $pattern = "/(" . $numeric_types_imploded . ")\(\d+\)/"; + $pattern = "/(" . $numeric_types_imploded . ")\(\d+\)/i"; // Execute type find & replace $sql = preg_replace_callback($pattern, function ($matches) { diff --git a/tests/rewriteTest.php b/tests/rewriteTest.php index 2bbeeaf..e755540 100644 --- a/tests/rewriteTest.php +++ b/tests/rewriteTest.php @@ -96,6 +96,29 @@ final class rewriteTest extends TestCase $this->assertSame(trim($expected), trim($postgresql)); } + public function test_it_handles_numerics_without_auto_incrment_case_insensitively() + { + $sql = <<assertSame(trim($expected), trim($postgresql)); + } public function test_it_handles_keys() { @@ -229,8 +252,8 @@ final class rewriteTest extends TestCase platform varchar(255), version varchar(255), location varchar(10), - user_id BIGINT(48) NOT NULL, - page_id BIGINT(48) NOT NULL, + user_id BIGINT NOT NULL, + page_id BIGINT NOT NULL, type VARCHAR(100) NOT NULL, PRIMARY KEY ( "ID" ) ); @@ -631,6 +654,63 @@ final class rewriteTest extends TestCase $this->assertSame(trim($expected), trim($postgresql)); } + public function test_it_rewrites_mediumints() + { + $sql = <<assertSame(trim($expected), trim($postgresql)); + } + +