Fixed the bug of ALTER TABLE ALTER COLUMN query.

git-svn-id: https://plugins.svn.wordpress.org/sqlite-integration/trunk@768830 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
kjmtsh 2013-09-09 06:02:18 +00:00
parent 72bc68b45b
commit a246ffa700
3 changed files with 5 additions and 3 deletions

View File

@ -151,7 +151,7 @@ class AlterQuery {
$tokens['command'] = $match_1.' '.$match_2; $tokens['command'] = $match_1.' '.$match_2;
$tokens['column_name'] = $match_3; $tokens['column_name'] = $match_3;
list($set_or_drop) = explode(' ', $the_rest); list($set_or_drop) = explode(' ', $the_rest);
if ($set_or_drop == 'set') { if (strtolower($set_or_drop) == 'set') {
$tokens['default_command'] = 'set default'; $tokens['default_command'] = 'set default';
$default_value = str_ireplace('set default', '', $the_rest); $default_value = str_ireplace('set default', '', $the_rest);
$tokens['default_value'] = trim($default_value); $tokens['default_value'] = trim($default_value);
@ -161,7 +161,7 @@ class AlterQuery {
} else { } else {
$tokens['command'] = $match_1.' column'; $tokens['command'] = $match_1.' column';
$tokens['column_name'] = $match_2; $tokens['column_name'] = $match_2;
if ($match_3 == 'set') { if (strtolower($match_3) == 'set') {
$tokens['default_command'] = 'set default'; $tokens['default_command'] = 'set default';
$default_value = str_ireplace('default', '', $the_rest); $default_value = str_ireplace('default', '', $the_rest);
$tokens['default_value'] = trim($default_value); $tokens['default_value'] = trim($default_value);
@ -388,7 +388,7 @@ class AlterQuery {
if (stripos($create_query, $tokenized_query['column_name']) === false) { if (stripos($create_query, $tokenized_query['column_name']) === false) {
return 'SELECT 1=1'; return 'SELECT 1=1';
} }
if (preg_match("/\\s*({$tokenized_query['column_name']}\\s*.*?)\\s*(DEFAULT\\s*.*)[,)]/im", $create_query, $match)) { if (preg_match("/\\s*({$tokenized_query['column_name']}\\s*.*?)\\s*(DEFAULT\\s*.*|)[,)]/im", $create_query, $match)) {
$col_def = trim($match[1]); $col_def = trim($match[1]);
$old_default = trim($match[2]); $old_default = trim($match[2]);
$create_query = preg_replace("/($col_def)\\s*$old_default/im", "\\1 $def_value", $create_query); $create_query = preg_replace("/($col_def)\\s*$old_default/im", "\\1 $def_value", $create_query);

View File

@ -169,6 +169,7 @@ SQLite Integrationのアップグレードに失敗するようなら、FTPを
= 1.3.1 () = = 1.3.1 () =
* SHOW INDEXクエリにWHERE句がある場合の処理を変更しました。 * SHOW INDEXクエリにWHERE句がある場合の処理を変更しました。
* ALTER TABLE ALTER COLUMNクエリのバグを修正しました。
= 1.3 (2013-09-04) = = 1.3 (2013-09-04) =
* データベースファイルのスナップショットをzipアーカイブとしてバックアップするユーティリティを追加しました。 * データベースファイルのスナップショットをzipアーカイブとしてバックアップするユーティリティを追加しました。

View File

@ -160,6 +160,7 @@ When auto upgrading of SQLite Integration fails, please try manual upgrade via F
= 1.3.1 () = = 1.3.1 () =
* Changed the manipulation of SHOW INDEX query with WHERE clause. * Changed the manipulation of SHOW INDEX query with WHERE clause.
* Fixed the bug of the manipulation of ALTER TABLE ALTER COLUMN query.
= 1.3 (2013-09-04) = = 1.3 (2013-09-04) =
* Added the backup utility that creates the zipped archive of the current snapshot of the database file. * Added the backup utility that creates the zipped archive of the current snapshot of the database file.