Skip to content

Instantly share code, notes, and snippets.

@yosiat
Created April 14, 2020 10:01
Show Gist options
  • Save yosiat/b6d5d8247f95b01bdb959fa5394914b0 to your computer and use it in GitHub Desktop.
Save yosiat/b6d5d8247f95b01bdb959fa5394914b0 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
class MiniSqlConnection
def self.cached_type_map
@@type_map ||= begin
pg_connection = ActiveRecord::Base.connection.raw_connection
MiniSql::Postgres::Connection.type_map(pg_connection)
end
end
def self.connection
MiniSql::Connection.get(ActiveRecord::Base.connection.raw_connection, type_map: cached_type_map)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment