From a246ffa700882cdb84284cc1e9a6bd67ecd02e6b Mon Sep 17 00:00:00 2001 From: kjmtsh Date: Mon, 9 Sep 2013 06:02:18 +0000 Subject: [PATCH] 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 --- query_alter.class.php | 6 +++--- readme-ja.txt | 1 + readme.txt | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/query_alter.class.php b/query_alter.class.php index 4964619..1d52765 100644 --- a/query_alter.class.php +++ b/query_alter.class.php @@ -151,7 +151,7 @@ class AlterQuery { $tokens['command'] = $match_1.' '.$match_2; $tokens['column_name'] = $match_3; list($set_or_drop) = explode(' ', $the_rest); - if ($set_or_drop == 'set') { + if (strtolower($set_or_drop) == 'set') { $tokens['default_command'] = 'set default'; $default_value = str_ireplace('set default', '', $the_rest); $tokens['default_value'] = trim($default_value); @@ -161,7 +161,7 @@ class AlterQuery { } else { $tokens['command'] = $match_1.' column'; $tokens['column_name'] = $match_2; - if ($match_3 == 'set') { + if (strtolower($match_3) == 'set') { $tokens['default_command'] = 'set default'; $default_value = str_ireplace('default', '', $the_rest); $tokens['default_value'] = trim($default_value); @@ -388,7 +388,7 @@ class AlterQuery { if (stripos($create_query, $tokenized_query['column_name']) === false) { 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]); $old_default = trim($match[2]); $create_query = preg_replace("/($col_def)\\s*$old_default/im", "\\1 $def_value", $create_query); diff --git a/readme-ja.txt b/readme-ja.txt index 7af2528..51bc8ba 100644 --- a/readme-ja.txt +++ b/readme-ja.txt @@ -169,6 +169,7 @@ SQLite Integrationのアップグレードに失敗するようなら、FTPを = 1.3.1 () = * SHOW INDEXクエリにWHERE句がある場合の処理を変更しました。 +* ALTER TABLE ALTER COLUMNクエリのバグを修正しました。 = 1.3 (2013-09-04) = * データベースファイルのスナップショットをzipアーカイブとしてバックアップするユーティリティを追加しました。 diff --git a/readme.txt b/readme.txt index 324fcf6..da1bb2b 100644 --- a/readme.txt +++ b/readme.txt @@ -160,6 +160,7 @@ When auto upgrading of SQLite Integration fails, please try manual upgrade via F = 1.3.1 () = * 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) = * Added the backup utility that creates the zipped archive of the current snapshot of the database file.