<commit_before># This patches the default behavior of ActiveRecord not recovering from PG::Error
# connection failures.
#
# When an ActiveRecord connection to PostgreSQL fails, it returns a
# PG::Error: connection not open.
#
# However, this does not close the connection, which is reused over and over,
# causing a failure even if the PostgreSQL server is already back.
#
# The original code was taken from:
# https://github.com/rails/rails/pull/6557
# which was not merged for some reason - instead
# https://github.com/rails/rails/pull/6654
# was merged, which does not fix the issue as, even though verify! now works,
# it is never called actively by Rails (tested on latest 3.2.x version).
#

module PostgreSQLAutoReconnectionPatch
  # Queries the database and returns the results in an Array-like object
  def query(sql, name = nil) #:nodoc:
    with_auto_reconnect(sql, name) do
      super
    end<commit_msg>Remove extra parameters from reconnect patch<commit_after># This patches the default behavior of ActiveRecord not recovering from PG::Error
# connection failures.
#
# When an ActiveRecord connection to PostgreSQL fails, it returns a
# PG::Error: connection not open.
#
# However, this does not close the connection, which is reused over and over,
# causing a failure even if the PostgreSQL server is already back.
#
# The original code was taken from:
# https://github.com/rails/rails/pull/6557
# which was not merged for some reason - instead
# https://github.com/rails/rails/pull/6654
# was merged, which does not fix the issue as, even though verify! now works,
# it is never called actively by Rails (tested on latest 3.2.x version).
#

module PostgreSQLAutoReconnectionPatch
  # Queries the database and returns the results in an Array-like object
  def query(sql, name = nil) #:nodoc:
    with_auto_reconnect do
      super
    end
{'fraction_non_alphanumeric': 0.07389428263214672, 'fraction_numerical': 0.010787486515641856, 'mean_word_length': 4.225352112676056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3212626', 'n_tokens_mistral': 530, 'n_tokens_neox': 507, 'n_words': 237}