mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-07-29 17:27:13 +02:00
Remove Default character set
This commit is contained in:
@ -16,7 +16,7 @@ class AlterTableSQLRewriter extends AbstractSQLRewriter
|
||||
'default \'0000-00-00 00:00:00\'' => 'DEFAULT now()',
|
||||
'\'0000-00-00 00:00:00\'' => 'now()',
|
||||
' datetime' => ' timestamp',
|
||||
'DEFAULT CHARACTER SET utf8' => '',
|
||||
' DEFAULT CHARACTER SET utf8' => '',
|
||||
|
||||
// WP 2.7.1 compatibility
|
||||
' int(4)' => ' smallint',
|
||||
@ -25,7 +25,7 @@ class AlterTableSQLRewriter extends AbstractSQLRewriter
|
||||
' tinyint(2)' => ' smallint',
|
||||
' tinyint(1)' => ' smallint',
|
||||
" enum('0','1')" => ' smallint',
|
||||
' COLLATE utf8_general_ci' => ' ',
|
||||
' COLLATE utf8_general_ci' => '',
|
||||
|
||||
// For flash-album-gallery plugin
|
||||
' tinyint' => ' smallint'
|
||||
|
@ -17,8 +17,8 @@ class CreateTableSQLRewriter extends AbstractSQLRewriter
|
||||
'default \'0000-00-00 00:00:00\'' => 'DEFAULT now()',
|
||||
'\'0000-00-00 00:00:00\'' => 'now()',
|
||||
'datetime' => 'timestamp',
|
||||
'DEFAULT CHARACTER SET utf8mb4' => '',
|
||||
'DEFAULT CHARACTER SET utf8' => '',
|
||||
' DEFAULT CHARACTER SET utf8mb4' => '',
|
||||
' DEFAULT CHARACTER SET utf8' => '',
|
||||
|
||||
// WP 2.7.1 compatibility
|
||||
' int(4)' => ' smallint',
|
||||
@ -27,8 +27,9 @@ class CreateTableSQLRewriter extends AbstractSQLRewriter
|
||||
' tinyint(2)' => ' smallint',
|
||||
' tinyint(1)' => ' smallint',
|
||||
" enum('0','1')" => ' smallint',
|
||||
'COLLATE utf8mb4_unicode_520_ci' => '',
|
||||
'COLLATE utf8_general_ci' => '',
|
||||
' COLLATE utf8mb4_unicode_520_ci' => '',
|
||||
' COLLATE utf8_general_ci' => '',
|
||||
' CHARACTER SET utf8' => '',
|
||||
|
||||
// For flash-album-gallery plugin
|
||||
' tinyint' => ' smallint'
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user