<commit_before>require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')

require 'sequel'
require 'logger'

# Establish database connection
DB = Sequel.connect('sqlite:///', :loggers => [Logger.new("#{File.dirname(__FILE__)}/../../sequel.log")])

module SequelTest
  class BaseTestCase < Test::Unit::TestCase
    def default_test
    end
    
    protected
      # Creates a new Sequel model (and the associated table)
      def new_model(create_table = :foo, &block)
        table_name = create_table || :foo
        table_identifier = ::Sequel::SQL::Identifier.new(table_name)
        class << table_identifier
          alias_method :original_to_s, :to_s
          def to_s(*args); args.empty? ? inspect : original_to_s(*args); end
        end
        
        DB.create_table!(table_identifier) do
          primary_key :id
          column :state, :string
        end if create_table
        model = Class.new(Sequel::Model(DB[table_identifier])) do<commit_msg>Conditionalize workaround in Sequel test setup for building models backed by tables with double underscores<commit_after>require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')

require 'sequel'
require 'logger'

# Establish database connection
DB = Sequel.connect('sqlite:///', :loggers => [Logger.new("#{File.dirname(__FILE__)}/../../sequel.log")])

module SequelTest
  class BaseTestCase < Test::Unit::TestCase
    def default_test
    end
    
    protected
      # Creates a new Sequel model (and the associated table)
      def new_model(create_table = :foo, &block)
        table_name = create_table || :foo
        table_identifier = ::Sequel::SQL::Identifier.new(table_name)
        
        if !defined?(Sequel::VERSION) || Gem::Version.new(::Sequel::VERSION) <= Gem::Version.new('3.26.0')
          class << table_identifier
            alias_method :original_to_s, :to_s
            def to_s(*args); args.empty? ? inspect : original_to_s(*args); end
          end
        end
        
        DB.create_table!(table_identifier) do
          primary_key :id
          column :state, :string
        end if create_table
        model = Class.new(Sequel::Model(DB[table_identifier])) do
{'fraction_non_alphanumeric': 0.12408759124087591, 'fraction_numerical': 0.0018248175182481751, 'mean_word_length': 2.9945355191256833, 'pattern_counts': {'":': 0, '<': 10, '<?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': '5699392', 'n_tokens_mistral': 640, 'n_tokens_neox': 637, 'n_words': 150}