From 673fb46b7953c935518979d6cde764777e268467 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 8 Nov 2020 16:11:07 +0100 Subject: Monkeypatch psql adapter for postgres 12 compatibility. --- .../activerecord_postgresql_adapter_fix.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 config/initializers/activerecord_postgresql_adapter_fix.rb (limited to 'config/initializers/activerecord_postgresql_adapter_fix.rb') diff --git a/config/initializers/activerecord_postgresql_adapter_fix.rb b/config/initializers/activerecord_postgresql_adapter_fix.rb new file mode 100644 index 0000000..719eb9f --- /dev/null +++ b/config/initializers/activerecord_postgresql_adapter_fix.rb @@ -0,0 +1,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 -- cgit v1.2.3