aboutsummaryrefslogtreecommitdiffstats
path: root/config/initializers/activerecord_postgresql_adapter_fix.rb
blob: 719eb9f4a95cc13fec925a9c964321a0f39f00e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Monkeypatch ActiveRecord::PostgreSQLAdabper to work on
# Postgres 12 and later.
#
# Soure: https://stackoverflow.com/a/59331868/270280
#
require 'active_record/connection_adapters/postgresql_adapter'

module ActiveRecord
  module ConnectionAdapters
    class PostgreSQLAdapter
      def set_standard_conforming_strings
        old, self.client_min_messages = client_min_messages, 'warning'
        execute('SET standard_conforming_strings = on', 'SCHEMA') rescue nil
      ensure
        self.client_min_messages = old
      end
    end
  end
end