Browse Source

Merge branch '7.x-3.x' into 7.x-3.x-remotedata

Stephen Ficklin 7 years ago
parent
commit
7190bfe30e
1 changed files with 39 additions and 2 deletions
  1. 39 2
      tripal_chado/includes/tripal_chado.field_storage.inc

+ 39 - 2
tripal_chado/includes/tripal_chado.field_storage.inc

@@ -519,7 +519,7 @@ function tripal_chado_field_storage_query($query) {
         $field_obj = new $field_type($field, $instance);
         $field_obj->query($cquery, $condition);
       }
-      // If there is no ChadoField class for this field then add the
+      // If there is not a ChadoField class for this field then add the
       // condition as is.
       else {
         $alias = $field['field_name'];
@@ -532,7 +532,44 @@ function tripal_chado_field_storage_query($query) {
           // Get the base table column that is associated with the term
           // passed as $condition['column'].
           $base_field = tripal_get_chado_semweb_column($chado_table, $condition['column']);
-          $cquery->condition('base.' . $base_field , $condition['value'], $condition['operator']);
+
+          $matches = array();
+          $key = $condition['value'];
+          $op = '=';
+          if (preg_match('/^(.+);(.+)$/', $key, $matches)) {
+            $key = $matches[1];
+            $op = $matches[2];
+          }
+          switch ($op) {
+            case 'eq':
+              $op = '=';
+              break;
+            case 'gt':
+              $op = '>';
+              break;
+            case 'gte':
+              $op = '>=';
+              break;
+            case 'lt':
+              $op = '<';
+              break;
+            case 'lte':
+              $op = '<=';
+              break;
+            case 'ne':
+              $op = '<>';
+              break;
+            case 'contains':
+              $op = 'LIKE';
+              $key = '%' . $key;
+              break;
+            case 'starts':
+              $op = 'LIKE';
+              break;
+            default:
+              $op = '=';
+          }
+          $cquery->condition('base.' . $base_field , $key, $op);
         }
         if ($chado_table != $base_table) {
           // TODO: I don't think we'll get here because linker fields will