diff options
author | Your Name <you@example.com> | 2020-11-08 16:11:07 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2020-11-08 16:18:09 +0100 |
commit | 673fb46b7953c935518979d6cde764777e268467 (patch) | |
tree | 6dfc3893fc9a25876b7a49f9d20f05e8e38f3234 | |
parent | 9f2de32c4ce7f0ad3abf1387e1a7971d5caf8c36 (diff) | |
download | hmnoweb-673fb46b7953c935518979d6cde764777e268467.tar.gz hmnoweb-673fb46b7953c935518979d6cde764777e268467.tar.bz2 hmnoweb-673fb46b7953c935518979d6cde764777e268467.zip |
Monkeypatch psql adapter for postgres 12 compatibility.
-rw-r--r-- | config/initializers/activerecord_postgresql_adapter_fix.rb | 19 |
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 |