Browse Source

Small fix to tripal views integration

Lacey Sanderson 10 years ago
parent
commit
4b2300b1bb

+ 1 - 1
tripal_views/includes/tripal_views_integration.inc

@@ -213,7 +213,7 @@ function tripal_views_get_integration_array_for_chado_table($table_name, $base_t
       // Note: Even though there can only be a single join  for a foreign key
       // we make the joins an array keyed by left_field to ensure that both
       // foeign key and referring_tables (see below) can be processed the same.
-      $defn_array['fields'][$left_field]['joins'][ $foreign_key_schema['table'] ][ $left_field ] = array(
+      $defn_array['fields'][$left_field]['joins'][ $foreign_key_schema['table'] ][ $right_field ] = array(
         'table' => $foreign_key_schema['table'],
         'field' => $right_field,
         'handler' => 'views_handler_join',

+ 6 - 1
tripal_views/tripal_views.views.inc

@@ -371,12 +371,17 @@ function tripal_views_views_data() {
         // account the left field and ensures all relationships for a single
         // left table are not condensed into a single relationship.
         if (array_key_exists($fake_field, $data[$base_table])) {
-          $improved_fake_field = $base_field . '_to_' . $left_table . "." . $left_field;
+
           // Again, note that we can't just change the fake_name after finding
           // there is more than one relationship because then the FIRST
           // relationship would keep the old fake_name rather than the LAST
           // which keeps backwards compatiblity since the old naming caused all
           // previous relationships be be overridden by the next one.
+          // Thus we first need to determine the left field of the previous
+          // join for this table combination and then use that to form our
+          // improved fake field.
+          $previous_left_field = $data[$base_table][$fake_field]['relationship']['base field'];
+          $improved_fake_field = $base_field . '_to_' . $left_table . "." . $previous_left_field;
           $data[$base_table][$improved_fake_field] = $data[$base_table][$fake_field];
         }
         $data[$base_table][$fake_field] = array(