mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-07-29 09:17:14 +02:00
Merge pull request #132 from PostgreSQL-For-Wordpress/hotfix/primary_key_rewriting
remove key names which are not supported during key creation in postgres
This commit is contained in:
@ -82,10 +82,16 @@ class CreateTableSQLRewriter extends AbstractSQLRewriter
|
||||
$sql = preg_replace($pattern, '', $sql);
|
||||
|
||||
|
||||
// Rewrite unique keys to just be UNIQUE without a key name
|
||||
$pattern = "/(,\s*)?UNIQUE KEY\s+[a-zA-Z0-9_]+\s+(\([a-zA-Z0-9_,\s]+\))/";
|
||||
$replacement = "$1UNIQUE $2";
|
||||
$sql = preg_replace($pattern, $replacement, $sql);
|
||||
|
||||
// Rewrite Primary keys to not have a key name
|
||||
$pattern = '/PRIMARY KEY\s+\w+\s*\((.*?)\)/';
|
||||
$replacement = 'PRIMARY KEY ($1)';
|
||||
$sql = preg_replace($pattern, $replacement, $sql);
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
@ -702,7 +702,7 @@ final class rewriteTest extends TestCase
|
||||
mysqlcolumn_detail text NOT NULL DEFAULT '',
|
||||
type varchar(210) NOT NULL DEFAULT 'post',
|
||||
item bigint NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY doctermitem (doc, term, item)
|
||||
PRIMARY KEY (doc, term, item)
|
||||
);
|
||||
SQL;
|
||||
|
||||
|
Reference in New Issue
Block a user