<commit_before>module Sequel
  class Model
    @allowed_columns = nil
    @association_reflections = {}
    @cache_store = nil
    @cache_ttl = nil
    @db = nil
    @db_schema = nil
    @dataset_methods = {}
    @hooks = {}
    @overridable_methods_module = nil
    @primary_key = :id
    @raise_on_save_failure = true
    @raise_on_typecast_failure = true
    @restrict_primary_key = true
    @restricted_columns = nil
    @simple_pk = nil
    @simple_table = nil
    @skip_superclass_validations = nil
    @sti_dataset = nil
    @sti_key = nil
    @strict_param_setting = true
    @transform = nil
    @typecast_empty_string_to_nil = true
    @typecast_on_assignment = true

    # Which columns should be the only columns allowed in a call to set
    # (default: all columns).
    metaattr_reader :allowed_columns

    # All association reflections defined for this model (default: none).
    metaattr_reader :association_reflections

    # Hash of dataset methods to add to this class and subclasses when
    # set_dataset is called.
    metaattr_reader :dataset_methods

    # The default primary key for classes (default: :id)
    metaattr_reader :primary_key

    # Whether to raise an error instead of returning nil on a failure
    # to save/create/save_changes/etc.
    metaattr_accessor :raise_on_save_failure

    # Whether to raise an error when unable to typecast data for a column
    # (default: true)
    metaattr_accessor :raise_on_typecast_failure

    # Which columns should not be update in a call to set
    # (default: no columns).
    metaattr_reader :restricted_columns

    # Should be the literal primary key column name if this Model's table has a simple primary key, or
    # nil if the model has a compound primary key or no primary key.
    metaattr_reader :simple_pk

    # Should be the literal table name if this Model's dataset is a simple table (no select, order, join, etc.),
    # or nil otherwise.
    metaattr_reader :simple_table

    # The base dataset for STI, to which filters are added to get
    # only the models for the specific STI subclass.
    metaattr_reader :sti_dataset

    # The column name holding the STI key for this model
    metaattr_reader :sti_key

    # Whether new/set/update and their variants should raise an error
    # if an invalid key is used (either that doesn't exist or that
    # access is restricted to it).
    metaattr_accessor :strict_param_setting

    # Whether to typecast the empty string ('') to nil for columns that
    # are not string or blob.
    metaattr_accessor :typecast_empty_string_to_nil

    # Whether to typecast attribute values on assignment (default: true)
    metaattr_accessor :typecast_on_assignment

    # Dataset methods to proxy via metaprogramming
    DATASET_METHODS = %w'<< all avg count delete distinct eager eager_graph each each_page 
       empty? except exclude filter first from from_self full_outer_join get graph 
       group group_and_count group_by having inner_join insert 
       insert_multiple intersect interval invert_order join join_table last 
       left_outer_join limit map multi_insert naked order order_by order_more 
       paginate print query range reverse_order right_outer_join select 
       select_all select_more server set set_graph_aliases single_value to_csv to_hash
       transform union unfiltered unordered update where with_sql'.map{|x| x.to_sym}

    # Instance variables that are inherited in subclasses
    INHERITED_INSTANCE_VARIABLES = {:@allowed_columns=>:dup, :@cache_store=>nil,
      :@cache_ttl=>nil, :@dataset_methods=>:dup, :@primary_key=>nil, 
      :@raise_on_save_failure=>nil, :@restricted_columns=>:dup, :@restrict_primary_key=>nil,
      :@simple_pk=>nil, :@simple_table=>nil,
      :@sti_dataset=>nil, :@sti_key=>nil, :@strict_param_setting=>nil,
      :@typecast_empty_string_to_nil=>nil, :@typecast_on_assignment=>nil,
      :@raise_on_typecast_failure=>nil, :@association_reflections=>:dup}
    
    # Empty instance variables, for -w compliance
    EMPTY_INSTANCE_VARIABLES = [:@overridable_methods_module, :@transform, :@db, :@skip_superclass_validations]

    # Returns the first record from the database matching the conditions.
    # If a hash is given, it is used as the conditions.  If another
    # object is given, it finds the first record whose primary key(s) match
    # the given argument(s).  If caching is used, the cache is checked
    # first before a dataset lookup is attempted unless a hash is supplied.
    def self.[](*args)
      args = args.first if (args.size == 1)
      return dataset[args] if args.is_a?(Hash)
      return cache_lookup(args) if @cache_store
      if t = simple_table and p = simple_pk
        with_sql("SELECT * FROM #{t} WHERE #{p} = #{dataset.literal(args)} LIMIT 1").first
      else<commit_msg>Remove Model.invert_order, as it called a private dataset method and hasn't worked in a long time<commit_after>module Sequel
  class Model
    @allowed_columns = nil
    @association_reflections = {}
    @cache_store = nil
    @cache_ttl = nil
    @db = nil
    @db_schema = nil
    @dataset_methods = {}
    @hooks = {}
    @overridable_methods_module = nil
    @primary_key = :id
    @raise_on_save_failure = true
    @raise_on_typecast_failure = true
    @restrict_primary_key = true
    @restricted_columns = nil
    @simple_pk = nil
    @simple_table = nil
    @skip_superclass_validations = nil
    @sti_dataset = nil
    @sti_key = nil
    @strict_param_setting = true
    @transform = nil
    @typecast_empty_string_to_nil = true
    @typecast_on_assignment = true

    # Which columns should be the only columns allowed in a call to set
    # (default: all columns).
    metaattr_reader :allowed_columns

    # All association reflections defined for this model (default: none).
    metaattr_reader :association_reflections

    # Hash of dataset methods to add to this class and subclasses when
    # set_dataset is called.
    metaattr_reader :dataset_methods

    # The default primary key for classes (default: :id)
    metaattr_reader :primary_key

    # Whether to raise an error instead of returning nil on a failure
    # to save/create/save_changes/etc.
    metaattr_accessor :raise_on_save_failure

    # Whether to raise an error when unable to typecast data for a column
    # (default: true)
    metaattr_accessor :raise_on_typecast_failure

    # Which columns should not be update in a call to set
    # (default: no columns).
    metaattr_reader :restricted_columns

    # Should be the literal primary key column name if this Model's table has a simple primary key, or
    # nil if the model has a compound primary key or no primary key.
    metaattr_reader :simple_pk

    # Should be the literal table name if this Model's dataset is a simple table (no select, order, join, etc.),
    # or nil otherwise.
    metaattr_reader :simple_table

    # The base dataset for STI, to which filters are added to get
    # only the models for the specific STI subclass.
    metaattr_reader :sti_dataset

    # The column name holding the STI key for this model
    metaattr_reader :sti_key

    # Whether new/set/update and their variants should raise an error
    # if an invalid key is used (either that doesn't exist or that
    # access is restricted to it).
    metaattr_accessor :strict_param_setting

    # Whether to typecast the empty string ('') to nil for columns that
    # are not string or blob.
    metaattr_accessor :typecast_empty_string_to_nil

    # Whether to typecast attribute values on assignment (default: true)
    metaattr_accessor :typecast_on_assignment

    # Dataset methods to proxy via metaprogramming
    DATASET_METHODS = %w'<< all avg count delete distinct eager eager_graph each each_page 
       empty? except exclude filter first from from_self full_outer_join get graph 
       group group_and_count group_by having inner_join insert 
       insert_multiple intersect interval join join_table last 
       left_outer_join limit map multi_insert naked order order_by order_more 
       paginate print query range reverse_order right_outer_join select 
       select_all select_more server set set_graph_aliases single_value to_csv to_hash
       transform union unfiltered unordered update where with_sql'.map{|x| x.to_sym}

    # Instance variables that are inherited in subclasses
    INHERITED_INSTANCE_VARIABLES = {:@allowed_columns=>:dup, :@cache_store=>nil,
      :@cache_ttl=>nil, :@dataset_methods=>:dup, :@primary_key=>nil, 
      :@raise_on_save_failure=>nil, :@restricted_columns=>:dup, :@restrict_primary_key=>nil,
      :@simple_pk=>nil, :@simple_table=>nil,
      :@sti_dataset=>nil, :@sti_key=>nil, :@strict_param_setting=>nil,
      :@typecast_empty_string_to_nil=>nil, :@typecast_on_assignment=>nil,
      :@raise_on_typecast_failure=>nil, :@association_reflections=>:dup}
    
    # Empty instance variables, for -w compliance
    EMPTY_INSTANCE_VARIABLES = [:@overridable_methods_module, :@transform, :@db, :@skip_superclass_validations]

    # Returns the first record from the database matching the conditions.
    # If a hash is given, it is used as the conditions.  If another
    # object is given, it finds the first record whose primary key(s) match
    # the given argument(s).  If caching is used, the cache is checked
    # first before a dataset lookup is attempted unless a hash is supplied.
    def self.[](*args)
      args = args.first if (args.size == 1)
      return dataset[args] if args.is_a?(Hash)
      return cache_lookup(args) if @cache_store
      if t = simple_table and p = simple_pk
        with_sql("SELECT * FROM #{t} WHERE #{p} = #{dataset.literal(args)} LIMIT 1").first
      else
{'fraction_non_alphanumeric': 0.0681513558098773, 'fraction_numerical': 0.00041241365089184453, 'mean_word_length': 3.6102661596958177, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 37, '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': '2232139', 'n_tokens_mistral': 2884, 'n_tokens_neox': 2787, 'n_words': 1003}