def perform_query(query, operand)
#      STDERR.puts "perform_query(q '#{query}', op '#{operand}')"
      records = []
		    
      if operand.is_a?(DataMapper::Query::Conditions::NotOperation)
#	STDERR.puts "operand is a NOT operation"
	subject = operand.first.subject
	value = operand.first.value
      elsif operand.subject.is_a?(DataMapper::Associations::ManyToOne::Relationship)
#	STDERR.puts "operand subject is a many-to-one relation: '#{operand.subject.inspect}'"
	if operand.subject.parent_model == NamedQuery && operand.subject.child_model == Bug
	  name = operand.value[operand.subject.parent_key.first.name]
	  bugs = named_query(name)
	  bugs.each do |bug|
	    records << bug_to_record(query.model, bug)
	  end
	  return records
	else
	  raise "Unknown parent (#{operand.subject.parent_model}) child (#{operand.subject.child_model}) relation"
	end
      else
#	STDERR.puts "operand is normal"
	subject = operand.subject
	value =  operand.value
      end
      
      if subject.is_a?(DataMapper::Associations::ManyToOne::Relationship)
#	STDERR.puts "subject is a many-to-one relation"
	subject = subject.child_key.first
      end
      
      # typical queries
      #
      
#      STDERR.puts "perform_query(subject '#{subject.inspect}', value '#{value.inspect}')"
      case query.model.name
      when "Bug"
	if query.model.key.include?(subject)
	  # get single <bug>
	  bugs = get_bugs(value)
	  records << bug_to_record(query.model, bugs.first)
	else
	  raise "Unknown query for bug"
	end
      when "NamedQuery"
	records << { subject.name.to_s => value }
	# be lazy: do the actual named query when NamedQuery#bugs gets accessed
      else
	raise "Unsupported model '#{query.model.name}'"
      end
      
      records
    end
def perform_query(query, operand)
#      STDERR.puts "perform_query(q '#{query}', op '#{operand}')"
      records = []
		    
      if operand.is_a?(DataMapper::Query::Conditions::NotOperation)
#	STDERR.puts "operand is a NOT operation"
	subject = operand.first.subject
	value = operand.first.value
      elsif operand.subject.is_a?(DataMapper::Associations::ManyToOne::Relationship)
#	STDERR.puts "operand subject is a many-to-one relation: '#{operand.subject.inspect}'"
	if operand.subject.parent_model == NamedQuery && operand.subject.child_model == Bug
	  name = operand.value[operand.subject.parent_key.first.name]
	  bugs = named_query(name)
	  bugs.each do |bug|
	    records << bug_to_record(query.model, bug)
	  end
	  return records
	else
	  raise "Unknown parent (#{operand.subject.parent_model}) child (#{operand.subject.child_model}) relation"
	end
      else
#	STDERR.puts "operand is normal"
	subject = operand.subject
	value =  operand.value
      end
      
      if subject.is_a?(DataMapper::Associations::ManyToOne::Relationship)
#	STDERR.puts "subject is a many-to-one relation"
	subject = subject.child_key.first
      end
      
      # typical queries
      #
      
#      STDERR.puts "perform_query(subject '#{subject.inspect}', value '#{value.inspect}')"
      case query.model.name
      when "Bug"
	if query.model.key.include?(subject)
	  # get single <bug>
	  bugs = get_bugs(value)
	  records << bug_to_record(query.model, bugs.first)
	else
	  raise "Unknown query for bug"
	end
      when "NamedQuery"
	records << { subject.name.to_s => value }
	# be lazy: do the actual named query when NamedQuery#bugs gets accessed
      else
	raise "Unsupported model '#{query.model.name}'"
      end
      
      records
    end
def

 Find records that match have a matching value

 @param [DataMapper::Query] query
   The query used to locate the resources

 @param [DataMapper::Operation] the operation for the query

 @return [Array]
   An array of hashes of all of the records for a particular model

 @api private