|  | @@ -76,10 +76,18 @@ function tripal_field_storage_query($query) {
 | 
	
		
			
				|  |  |    $select->join('tripal_bundle', 'TB', 'TE.bundle = TB.name');
 | 
	
		
			
				|  |  |    $select->fields('TE', array('id'));
 | 
	
		
			
				|  |  |    $select->fields('TB', array('name'));
 | 
	
		
			
				|  |  | +  
 | 
	
		
			
				|  |  | +  // Apply any entity condition filters.
 | 
	
		
			
				|  |  | +  if ($query->entityConditions) {
 | 
	
		
			
				|  |  | +    if (array_key_exists('bundle', $query->entityConditions)) {
 | 
	
		
			
				|  |  | +      $select->condition('TB.name', $query->entityConditions['bundle']['value']);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    // Add in any filters to the query.
 | 
	
		
			
				|  |  |    foreach ($query->fieldConditions as $index => $condition) {
 | 
	
		
			
				|  |  |      $field = $condition['field'];
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  |      // Skip conditions that don't belong to this storage type.
 | 
	
		
			
				|  |  |      if ($field['storage']['type'] != 'tripal_no_storage') {
 | 
	
		
			
				|  |  |        continue;
 | 
	
	
		
			
				|  | @@ -107,6 +115,18 @@ function tripal_field_storage_query($query) {
 | 
	
		
			
				|  |  |        $select->orderBy('TB.label', $direction);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | +  
 | 
	
		
			
				|  |  | +  // Add a range of records to retrieve
 | 
	
		
			
				|  |  | +  if (isset($query->range)) {
 | 
	
		
			
				|  |  | +    $select->range($query->range['start'], $query->range['length']);
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  
 | 
	
		
			
				|  |  | +  // Only include records that are deleted.  Tripal doesn't keep track of
 | 
	
		
			
				|  |  | +  // records that are deleted that need purging separately so we can do nothing
 | 
	
		
			
				|  |  | +  // with this.
 | 
	
		
			
				|  |  | +  if (isset($query->deleted)) {
 | 
	
		
			
				|  |  | +    // do nothing.
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    // Perform the query and return the results.
 | 
	
		
			
				|  |  |    $entities = $select->execute();
 |