Remove Default character set

This commit is contained in:
mattbucci
2024-01-08 04:22:59 +00:00
parent aca566b8bf
commit 5f27c893b3
3 changed files with 53 additions and 6 deletions

View File

@ -29,6 +29,7 @@ class CreateTableSQLRewriter extends AbstractSQLRewriter
" enum('0','1')" => ' smallint',
' COLLATE utf8mb4_unicode_520_ci' => '',
' COLLATE utf8_general_ci' => '',
' CHARACTER SET utf8' => '',
// For flash-album-gallery plugin
' tinyint' => ' smallint'

View File

@ -195,6 +195,52 @@ final class rewriteTest extends TestCase
$this->assertSame(trim($postgresql), trim($expected));
}
public function test_it_removes_character_sets()
{
$sql = <<<SQL
CREATE TABLE wp_statistics_useronline (
ID bigint(20) NOT NULL AUTO_INCREMENT,
ip varchar(60) NOT NULL,
created int(11),
timestamp int(10) NOT NULL,
date datetime NOT NULL,
referred text CHARACTER SET utf8 NOT NULL,
agent varchar(255) NOT NULL,
platform varchar(255),
version varchar(255),
location varchar(10),
`user_id` BIGINT(48) NOT NULL,
`page_id` BIGINT(48) NOT NULL,
`type` VARCHAR(100) NOT NULL,
PRIMARY KEY (ID)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci
SQL;
$expected = <<<SQL
CREATE TABLE wp_statistics_useronline (
"ID" bigserial,
ip varchar(60) NOT NULL,
created int,
timestamp int NOT NULL,
date timestamp NOT NULL,
referred text NOT NULL,
agent varchar(255) NOT NULL,
platform varchar(255),
version varchar(255),
location varchar(10),
user_id BIGINT(48) NOT NULL,
page_id BIGINT(48) NOT NULL,
type VARCHAR(100) NOT NULL,
PRIMARY KEY ( "ID" )
);
SQL;
$postgresql = pg4wp_rewrite($sql);
$this->assertSame(trim($postgresql), trim($expected));
}
protected function setUp(): void
{
global $wpdb;