aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/initializers/activerecord_postgresql_adapter_fix.rb19
1 files changed, 19 insertions, 0 deletions
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