Method: ActiveRecord::PGExtensions::PostgreSQLAdapter#extension

Defined in:
lib/active_record/pg_extensions/postgresql_adapter.rb

#extension(extension) ⇒ Object

returns an Extension object for a particular extension


92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/active_record/pg_extensions/postgresql_adapter.rb', line 92

def extension(extension)
  @extensions ||= {}
  @extensions.fetch(extension.to_s) do
    rows = select_rows(<<~SQL, "SCHEMA")
      SELECT nspname, extversion
      FROM pg_extension
        INNER JOIN pg_namespace ON extnamespace=pg_namespace.oid
      WHERE extname=#{quote(extension)}
    SQL
    next nil if rows.empty?

    Extension.new(extension.to_s, rows[0][0], rows[0][1])
  end
end