Explorar o código

added the tripal_get_custom_schema to the tripal_core_get_chado_table_schema_function. This will allow the tripal_core_chado_insert (etc) functions to work with custom tables as well. Had to fix other places in the views integration where the tripal_get_custom_schema was being called.

spficklin %!s(int64=12) %!d(string=hai) anos
pai
achega
841aaa543d

+ 5 - 0
tripal_core/api/tripal_core.api.inc

@@ -2803,6 +2803,11 @@ function tripal_core_get_chado_table_schema($table) {
    // get the table array from the proper chado schema
    $v = preg_replace("/\./", "_", $v); // reformat version for hook name
    $table_arr = module_invoke_all("chado_schema_v" . $v . "_" . $table);
+   
+   // if the table_arr is empty then maybe this is a custom table
+   if(!is_array($table_arr) or count($table_arr) == 0){
+     $table_arr = tripal_get_chado_custom_schema($table);
+   }
 
    return $table_arr;
 }

+ 1 - 14
tripal_views/includes/tripal_views_integration.inc

@@ -424,15 +424,6 @@ function tripal_views_integration_form(&$form_state, $setup_id = NULL) {
           $columns[] = "$column " . $attrs['type'];
         }
       }
-
-      // now do the same for the custom tables
-      $table_desc = tripal_get_chado_custom_schema($table_name);
-      if ($table_desc) {
-        $fields = $table_desc['fields'];
-        foreach ($fields as $column => $attrs) {
-          $columns[] = "$column " . $attrs['type'];
-        }
-      }
     }
 
     $i=1;
@@ -589,12 +580,8 @@ function tripal_views_integration_form(&$form_state, $setup_id = NULL) {
 
       $columns = array();
       if ($default_join_table) {
-        // get the table description in the typical way and if it returns
-        // nothing then get the custom table description
+        // get the table description
         $table_desc = tripal_core_get_chado_table_schema($default_join_table);
-        if (!$table_desc) {
-          $table_desc = tripal_get_chado_custom_schema($default_join_table);
-        }
         foreach ($table_desc['fields'] as $column => $def) {
           $columns[$column] = $column;
         }

+ 2 - 5
tripal_views/tripal_views.views.inc

@@ -326,12 +326,9 @@ function tripal_views_views_data() {
         continue;
       }
 
-      // The chado table could be a regular Chado table or a custom table
-      // in the chado database.  Therefore we'll check both
+      // get the table description
       $table_desc = tripal_core_get_chado_table_schema($base_table);
-      if (!$table_desc) {
-        $table_desc = tripal_get_chado_custom_schema($base_table);
-      }
+      
       $fields = $table_desc['fields'];
       if (!is_array($fields)) {
         $fields = array();