mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-08-01 18:54:25 +02:00
handle table charsets
This commit is contained in:
@@ -30,6 +30,7 @@ class CreateTableSQLRewriter extends AbstractSQLRewriter
|
|||||||
' COLLATE utf8mb4_unicode_520_ci' => '',
|
' COLLATE utf8mb4_unicode_520_ci' => '',
|
||||||
' COLLATE utf8_general_ci' => '',
|
' COLLATE utf8_general_ci' => '',
|
||||||
' CHARACTER SET utf8' => '',
|
' CHARACTER SET utf8' => '',
|
||||||
|
' DEFAULT CHARSET=utf8' => '',
|
||||||
|
|
||||||
// For flash-album-gallery plugin
|
// For flash-album-gallery plugin
|
||||||
' tinyint' => ' smallint'
|
' tinyint' => ' smallint'
|
||||||
@@ -46,7 +47,12 @@ class CreateTableSQLRewriter extends AbstractSQLRewriter
|
|||||||
$table = $matches[1];
|
$table = $matches[1];
|
||||||
|
|
||||||
// Remove trailing spaces
|
// Remove trailing spaces
|
||||||
$sql = trim($sql) . ';';
|
$sql = trim($sql);
|
||||||
|
|
||||||
|
// Add a slash if needed
|
||||||
|
if (substr($sql,strlen($sql)-1, 1) != ";") {
|
||||||
|
$sql = $sql . ";";
|
||||||
|
}
|
||||||
|
|
||||||
// Translate types and some other replacements
|
// Translate types and some other replacements
|
||||||
$sql = str_ireplace(
|
$sql = str_ireplace(
|
||||||
|
@@ -280,6 +280,32 @@ final class rewriteTest extends TestCase
|
|||||||
$this->assertSame(trim($expected), trim($postgresql));
|
$this->assertSame(trim($expected), trim($postgresql));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function test_it_removes_table_charsets()
|
||||||
|
{
|
||||||
|
$sql = <<<SQL
|
||||||
|
CREATE TABLE `wp_yoast_migrations` (
|
||||||
|
`id` int(11) UNSIGNED auto_increment NOT NULL,
|
||||||
|
`version` varchar(191),
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) DEFAULT CHARSET=utf8;
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
$expected = <<<SQL
|
||||||
|
CREATE TABLE wp_yoast_migrations (
|
||||||
|
id serial NOT NULL,
|
||||||
|
version varchar(191),
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
$postgresql = pg4wp_rewrite($sql);
|
||||||
|
$this->assertSame(trim($expected), trim($postgresql));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
Reference in New Issue
Block a user