Class: PG::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/pg/em.rb

Instance Method Summary collapse

Instance Method Details

#check_result(connection, result) ⇒ Object

pg_check_result is internal ext function. I wish it was rubified. bitbucket.org/ged/ruby-pg/issue/123/rubify-pg_check_result



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/pg/em.rb', line 21

def check_result(connection, result)
  if result.nil?
    if (error_message = connection.error_message)
      error = PG::Error.new(error_message)
    end
  else
    case result.result_status
      when PG::PGRES_BAD_RESPONSE,
           PG::PGRES_FATAL_ERROR,
           PG::PGRES_NONFATAL_ERROR
        error = PG::Error.new(result.error_message)
        error.instance_variable_set('@result', result)
    end
  end
  if error
    error.instance_variable_set('@connection', connection)
    raise error 
  end
end