From d46dba61489504e5b4226cde891c8c7822dde5f1 Mon Sep 17 00:00:00 2001 From: Matthew Bucci Date: Thu, 17 Oct 2024 01:18:11 -0700 Subject: [PATCH] numeric rewriting should be case insensitive --- pg4wp/rewriters/CreateTableSQLRewriter.php | 2 +- tests/rewriteTest.php | 27 ++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pg4wp/rewriters/CreateTableSQLRewriter.php b/pg4wp/rewriters/CreateTableSQLRewriter.php index 0e26ba4..66deb10 100644 --- a/pg4wp/rewriters/CreateTableSQLRewriter.php +++ b/pg4wp/rewriters/CreateTableSQLRewriter.php @@ -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..4e81d5e 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" ) );