<commit_before>module ::ArJdbc
  module MsSQL
    module LimitHelpers
      module_function
      def get_table_name(sql)
        if sql =~ /^\s*insert\s+into\s+([^\(\s,]+)\s*|^\s*update\s+([^\(\s,]+)\s*/i
          $1
        elsif sql =~ /\bfrom\s+([^\(\s,]+)\s*/i
          $1
        else
          nil
        end
      end

      def get_primary_key(order, table_name)
        if order =~ /(\w*id\w*)/i
          $1
        else
          table_name[/\[+(.*)\]+/i]
          models = ActiveRecord::Base.descendants
          model = models.select{|model| model.table_name == $1}.first
          if model then
            model.primary_key
          else
           'id'
          end
        end
      end

      module SqlServer2000ReplaceLimitOffset<commit_msg>add rails 2 compatibility<commit_after>module ::ArJdbc
  module MsSQL
    module LimitHelpers
      module_function
      def get_table_name(sql)
        if sql =~ /^\s*insert\s+into\s+([^\(\s,]+)\s*|^\s*update\s+([^\(\s,]+)\s*/i
          $1
        elsif sql =~ /\bfrom\s+([^\(\s,]+)\s*/i
          $1
        else
          nil
        end
      end

      def get_primary_key(order, table_name)
        if order =~ /(\w*id\w*)/i
          $1
        else
          table_name[/\[+(.*)\]+/i]

          # rails 2 vs rails 3
          if ActiveRecord::VERSION::MAJOR >= 3
            models = ActiveRecord::Base.descendants
          else
            models = ActiveRecord::Base.send(:subclasses)
          end

          model = models.select{|model| model.table_name == $1}.first
          if model then
            model.primary_key
          else
           'id'
          end
        end
      end

      module SqlServer2000ReplaceLimitOffset
{'fraction_non_alphanumeric': 0.14194299011052938, 'fraction_numerical': 0.011634671320535195, 'mean_word_length': 1.478386167146974, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5504797', 'n_tokens_mistral': 572, 'n_tokens_neox': 542, 'n_words': 108}