<commit_before>
require 'dm-is-reflective/is/adapters/abstract_adapter'

module DataMapper
  module Is::Reflective
    module PostgresAdapter
      def storages
        sql = <<-SQL.compress_lines
          SELECT table_name FROM "information_schema"."tables"
          WHERE table_schema = current_schema()
        SQL

        select(sql)
      end

      private
      def reflective_query_storage storage
        sql = <<-SQL.compress_lines
          SELECT column_name FROM "information_schema"."key_column_usage"
          WHERE table_schema = current_schema() AND table_name = ?
        SQL

        keys = query(sql, storage).to_set

        sql = <<-SQL.compress_lines
          SELECT column_name, column_default, is_nullable,
                 character_maximum_length, udt_name
          FROM "information_schema"."columns"
          WHERE table_schema = current_schema() AND table_name = ?
        SQL

        select(sql, storage).map{ |struct|
          struct.instance_eval <<-END_EVAL
            def key?
              #{keys.member?(struct.column_name)}
            end<commit_msg>yet another query => select<commit_after>
require 'dm-is-reflective/is/adapters/abstract_adapter'

module DataMapper
  module Is::Reflective
    module PostgresAdapter
      def storages
        sql = <<-SQL.compress_lines
          SELECT table_name FROM "information_schema"."tables"
          WHERE table_schema = current_schema()
        SQL

        select(sql)
      end

      private
      def reflective_query_storage storage
        sql = <<-SQL.compress_lines
          SELECT column_name FROM "information_schema"."key_column_usage"
          WHERE table_schema = current_schema() AND table_name = ?
        SQL

        keys = select(sql, storage).to_set

        sql = <<-SQL.compress_lines
          SELECT column_name, column_default, is_nullable,
                 character_maximum_length, udt_name
          FROM "information_schema"."columns"
          WHERE table_schema = current_schema() AND table_name = ?
        SQL

        select(sql, storage).map{ |struct|
          struct.instance_eval <<-END_EVAL
            def key?
              #{keys.member?(struct.column_name)}
            end
{'fraction_non_alphanumeric': 0.07862629914143697, 'fraction_numerical': 0.0, 'mean_word_length': 2.232116788321168, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 4, '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': '367400', 'n_tokens_mistral': 610, 'n_tokens_neox': 586, 'n_words': 136}