<commit_before>module ODBCAdapter
  module Adapters
    # Overrides specific to PostgreSQL. Mostly taken from
    # ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
    class PostgreSQLODBCAdapter < ActiveRecord::ConnectionAdapters::ODBCAdapter
      BOOLEAN_TYPE = 'bool'.freeze
      PRIMARY_KEY  = 'SERIAL PRIMARY KEY'.freeze

      alias :create :insert

      # Override to handle booleans appropriately
      def native_database_types
        @native_database_types ||= super.merge(boolean: { name: 'bool' })
      end

      def arel_visitor
        Arel::Visitors::PostgreSQL.new(self)
      end

      # Filter for ODBCAdapter#tables
      # Omits table from #tables if table_filter returns true
      def table_filter(schema_name, table_type)
        %w[information_schema pg_catalog].include?(schema_name) || table_type !~ /TABLE/i
      end

      def truncate(table_name, name = nil)
        exec_query("TRUNCATE TABLE #{quote_table_name(table_name)}", name)
      end

      # Returns the sequence name for a table's primary key or some other
      # specified key.
      def default_sequence_name(table_name, pk = nil)
        serial_sequence(table_name, pk || 'id').split('.').last
      rescue ActiveRecord::StatementInvalid
        "#{table_name}_#{pk || 'id'}_seq"
      end

      def sql_for_insert(sql, pk, id_value, sequence_name, binds)
        unless pk
          table_ref = extract_table_ref_from_insert_sql(sql)<commit_msg>Correct function name for filtering<commit_after>module ODBCAdapter
  module Adapters
    # Overrides specific to PostgreSQL. Mostly taken from
    # ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
    class PostgreSQLODBCAdapter < ActiveRecord::ConnectionAdapters::ODBCAdapter
      BOOLEAN_TYPE = 'bool'.freeze
      PRIMARY_KEY  = 'SERIAL PRIMARY KEY'.freeze

      alias :create :insert

      # Override to handle booleans appropriately
      def native_database_types
        @native_database_types ||= super.merge(boolean: { name: 'bool' })
      end

      def arel_visitor
        Arel::Visitors::PostgreSQL.new(self)
      end

      # Filter for ODBCAdapter#tables
      # Omits table from #tables if table_filter returns true
      def table_filtered?(schema_name, table_type)
        %w[information_schema pg_catalog].include?(schema_name) || table_type !~ /TABLE/i
      end

      def truncate(table_name, name = nil)
        exec_query("TRUNCATE TABLE #{quote_table_name(table_name)}", name)
      end

      # Returns the sequence name for a table's primary key or some other
      # specified key.
      def default_sequence_name(table_name, pk = nil)
        serial_sequence(table_name, pk || 'id').split('.').last
      rescue ActiveRecord::StatementInvalid
        "#{table_name}_#{pk || 'id'}_seq"
      end

      def sql_for_insert(sql, pk, id_value, sequence_name, binds)
        unless pk
          table_ref = extract_table_ref_from_insert_sql(sql)
{'fraction_non_alphanumeric': 0.08557790658029321, 'fraction_numerical': 0.0, 'mean_word_length': 3.2460202604920405, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6641942', 'n_tokens_mistral': 898, 'n_tokens_neox': 866, 'n_words': 211}