Browse Source

get chado_get_property to pass test

bradford.condon 6 years ago
parent
commit
5f56d762ea

+ 2 - 1
tests/tripal_chado/api/TripalChadoPropertyAPITest.php

@@ -71,7 +71,8 @@ class TripalChadoPropertyAPITest extends TripalTestCase {
 
     $record = ['prop_id' => $prop['featureprop_id'], 'table' => 'feature'];
     $retrieved = chado_get_property($record, $property);
-    $this->assertNotFalse($retrieved);
+
+    $this->assertNotNull($retrieved);
     $this->assertEquals($value, $retrieved->value);
   }
 

+ 7 - 2
tripal_chado/api/tripal_chado.property.api.inc

@@ -24,7 +24,7 @@
  *     -id: The primary key value of the base table. The property will be
  *         associated with the record that matches this id.
  *     -prop_id: The primary key in the [table]prop table.  If this value
- *         is supplied then the 'table' and 'id' keys are not needed.
+ *         is supplied then the 'id' key is not needed.
  * @param $property
  *   An associative array used to specify the property to be selected.  It can
  *   contain the following keys. The keys must be specified to uniquely identify
@@ -98,15 +98,20 @@ function chado_get_property($record, $property) {
 
   // Construct the array of values to be selected.
   $values = array(
-    $fkcol => $base_id,
     'type_id' => $type,
   );
 
+  //Can supply either base_id or prop_id.
+  if ($base_id){
+    $values[$fkcol] = $base_id;
+  }
+
   // If we have the unique property_id make sure to add that to the values.
   if ($prop_id) {
     $property_pkey = $table_desc['primary key'][0];
     $values[$property_pkey] = $prop_id;
   }
+
   $results = chado_generate_var($base_table . 'prop', $values);
   if ($results) {
     $results = chado_expand_var($results, 'field', $base_table . 'prop.value');