From 48c07ad1abab1bd0681a15309c396cdfc4b9f244 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Wed, 15 Oct 2014 10:32:44 +1300 Subject: [PATCH] Use parseIndexSpec to cleanup fulltext specification --- code/PostgreSQLDatabase.php | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/code/PostgreSQLDatabase.php b/code/PostgreSQLDatabase.php index 441bb66..5bfecfd 100644 --- a/code/PostgreSQLDatabase.php +++ b/code/PostgreSQLDatabase.php @@ -477,23 +477,12 @@ class PostgreSQLDatabase extends SS_Database { $fulltexts=''; $triggers=''; if($indexes){ - foreach($indexes as $name=>$this_index){ - if(is_array($this_index) && $this_index['type']=='fulltext'){ - $ts_details=$this->fulltext($this_index, $tableName, $name); - $fulltexts.=$ts_details['fulltexts'] . ', '; - $triggers.=$ts_details['triggers']; - } else if(is_string($this_index)) { - preg_match('/^fulltext\ \((.+)\)$/i', $this_index, $matches); - if(count($matches) == 2) { - $index = array( - 'type' => 'fulltext', - 'name' => $name, - 'value' => $matches[1] - ); - $ts_details=$this->fulltext($index, $tableName, $name); - $fulltexts.=$ts_details['fulltexts'] . ', '; - $triggers.=$ts_details['triggers']; - } + foreach($indexes as $name => $indexSpec) { + $indexSpec = $this->parseIndexSpec($name, $indexSpec); + if($indexSpec['type'] === 'fulltext') { + $ts_details = $this->fulltext($indexSpec, $tableName, $name); + $fulltexts .= $ts_details['fulltexts'] . ', '; + $triggers .= $ts_details['triggers']; } } }