Răsfoiți Sursa

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 ani în urmă
părinte
comite
2e0a6e620d
1 a modificat fișierele cu 2 adăugiri și 8 ștergeri
  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);";
         }
       }