Class: AppMap::Rails::SQLHandler::SQLExaminer::ActiveRecordExaminer

Inherits:
Object
  • Object
show all
Defined in:
lib/appmap/rails/sql_handler.rb

Constant Summary collapse

@@db_version_warning_issued =
{}

Instance Method Summary collapse

Instance Method Details

#database_typeObject



88
89
90
91
92
93
# File 'lib/appmap/rails/sql_handler.rb', line 88

def database_type
  type = ActiveRecord::Base.connection.adapter_name.downcase.to_sym
  type = :postgres if type == :postgresql

  type
end

#execute_query(sql) ⇒ Object



95
96
97
# File 'lib/appmap/rails/sql_handler.rb', line 95

def execute_query(sql)
  ActiveRecord::Base.connection.execute(sql).inject([]) { |memo, r| memo << r; memo }
end

#issue_warningObject



77
78
79
80
81
82
# File 'lib/appmap/rails/sql_handler.rb', line 77

def issue_warning
  db_type = database_type
  return if @@db_version_warning_issued[db_type]
  warn("AppMap: Unable to determine database version for #{db_type.inspect}") 
  @@db_version_warning_issued[db_type] = true
end

#server_versionObject



84
85
86
# File 'lib/appmap/rails/sql_handler.rb', line 84

def server_version
  ActiveRecord::Base.connection.try(:database_version) || issue_warning
end