瀏覽代碼

Fixed bug in MViews where the index was not being created properly. The index should have been made for each field individually in the argument. However, it was creating a single 'unique' index using all values. This kept some materialized views from being populated.

stephen 13 年之前
父節點
當前提交
2e0a6e620d
共有 1 個文件被更改,包括 2 次插入8 次删除
  1. 2 8
      base/tripal_core/mviews.php

+ 2 - 8
base/tripal_core/mviews.php

@@ -58,14 +58,11 @@ function tripal_add_mview ($name,$modulename,$mv_table,$mv_specs,$indexed,$query
       // now construct the indexes
       $index = '';
       if($indexed){
-         // remove extra spaces and index field names
-        $indexed = preg_replace("/\s+,/",",",$indexed);
-        $indexed = preg_replace("/\s+\n/","\n",$indexed);
-        $indexed = preg_replace("/,\n/","\n",$indexed);
         // add to the array of values
         $vals = preg_split("/[\n,]+/",$indexed);
         $index = '';
         foreach ($vals as $field){
+           $field = trim($field);
            $index .= "CREATE INDEX idx_${mv_table}_${field} ON $mv_table ($field);";
         }
       }
@@ -149,14 +146,11 @@ function tripal_edit_mview ($mview_id,$name,$modulename,$mv_table,$mv_specs,$ind
       // now construct the indexes
       $index = '';
       if($indexed){
-         // remove extra spaces and index field names
-        $indexed = preg_replace("/\s+,/",",",$indexed);
-        $indexed = preg_replace("/\s+\n/","\n",$indexed);
-        $indexed = preg_replace("/,\n/","\n",$indexed);
         // add to the array of values
         $vals = preg_split("/[\n,]+/",$indexed);
         $index = '';
         foreach ($vals as $field){
+           $field = trim($field);
            $index .= "CREATE INDEX idx_${mv_table}_${field} ON $mv_table ($field);";
         }
       }