<commit_before>module DBCode
  class Schema
    attr_reader :name, :connection
    def initialize(name:, connection:)
      @name, @connection = name, connection
    end

    delegate :execute, to: :connection

    def reset!
      execute <<-SQL
        drop schema if exists #@name cascade;
        create schema #@name;
      SQL
    end

    def digest=(digest)
      execute <<-SQL
        comment on schema #@name is 'dbcode_md5:#{digest}'
      SQL
    end

    def digest
      comment = execute(<<-SQL).first
        select pg_catalog.obj_description(n.oid, 'pg_namespace') as md5
        from pg_catalog.pg_namespace n where n.nspname = '#@name'
      SQL
      if comment
        comment.fetch('md5').match(/^dbcode_md5:(?<md5>.+)$/)[:md5]
      end
    end<commit_msg>fix no md5 case<commit_after>module DBCode
  class Schema
    attr_reader :name, :connection
    def initialize(name:, connection:)
      @name, @connection = name, connection
    end

    delegate :execute, to: :connection

    def reset!
      execute <<-SQL
        drop schema if exists #@name cascade;
        create schema #@name;
      SQL
    end

    def digest=(digest)
      execute <<-SQL
        comment on schema #@name is 'dbcode_md5:#{digest}'
      SQL
    end

    def digest
      comment = execute(<<-SQL).first
        select pg_catalog.obj_description(n.oid, 'pg_namespace') as md5
        from pg_catalog.pg_namespace n where n.nspname = '#@name'
      SQL
      if comment
        comment.fetch('md5') && comment.fetch('md5').match(/^dbcode_md5:(?<md5>.+)$/)[:md5]
      end
    end
{'fraction_non_alphanumeric': 0.11538461538461539, 'fraction_numerical': 0.008827238335435058, 'mean_word_length': 2.398286937901499, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 5, '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': '6677629', 'n_tokens_mistral': 505, 'n_tokens_neox': 488, 'n_words': 137}