From 069ed7ff52bdf8e7f63da94dbcfb28c63f8747d2 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 11 Dec 2012 14:40:49 +0100 Subject: [PATCH] BUG Normalize index specs to avoid false positives on schema regen --- code/SQLite3Database.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/code/SQLite3Database.php b/code/SQLite3Database.php index 6d530d8..27dd3ae 100644 --- a/code/SQLite3Database.php +++ b/code/SQLite3Database.php @@ -538,7 +538,16 @@ class SQLite3Database extends SS_Database { foreach(DB::query('PRAGMA index_info("' . $index["name"] . '")') as $details) $list[] = $details['name']; $indexList[$index["name"]] = implode(',', $list); } - foreach($indexList as $name => $val) $indexList[$name] = "\"$val\""; + foreach($indexList as $name => $val) { + // Normalize quoting to avoid false positives when checking for index changes + // during schema generation + $valParts = preg_split('/\s*,\s*/', $val); + foreach($valParts as $i => $valPart) { + $valParts[$i] = preg_replace('/^"?(.*)"?$/', '$1', $valPart); + } + + $indexList[$name] = '"' . implode('","', $valParts) . '"'; + } return $indexList; }