Sfoglia il codice sorgente

Issue #72: Updating API to include 2.1 improvements: c82c25f

Stephen Ficklin 7 anni fa
parent
commit
a2304db37f
1 ha cambiato i file con 20 aggiunte e 0 eliminazioni
  1. 20 0
      tripal_chado_views/tripal_chado_views.views.inc

+ 20 - 0
tripal_chado_views/tripal_chado_views.views.inc

@@ -221,8 +221,28 @@ function tripal_chado_views_views_data() {
       foreach ($fields as $column => $attrs) {
         $base_fields[$column] = array(
           'column_name' => $column,
+          // Add a default for type since module developers may sometimes need to use a
+          // PostgreSQL-specific type.
           'type' => (isset($attrs['type'])) ? $attrs['type'] : 'text',
         );
+        // If PostgreSQL-specifc types are needed the module developer should be given
+        // a way to set the most closely matching type for views. They should also be
+        // allowed to override the type for views. This can be done by adding a views_type
+        // to the schema definition :-).
+        if (isset($attrs['views_type'])) {
+          $base_fields[$column]['type'] = $attrs['views_type'];
+        }
+        // Tell admin about this feature and warn them that we made an assumption for them.
+        if (!isset($attrs['type']) AND !isset($attrs['views_type'])) {
+          tripal_report_error(
+              'tripal_views',
+              TRIPAL_WARNING,
+              "Unable to determine the type for %column thus we have defaulted to type 'text'.
+              Tip: This may be due to setting a  postgresql-specific type. Solution: Add a
+              'views_type' to your schema definition to specify what type should be used.",
+              array('%column' => $column)
+          );
+        }
       }
 
       // get the field name and descriptions