<commit_before>module OData
  module Model
    # Provides the proxy between OData::Query and OData::Model.
    class QueryProxy
      include Enumerable

      # Last filter criteria set on the query.
      attr_reader :last_criteria

      # Instantiates a new QueryProxy for the supplied OData::Model class.
      # @param model_class [Class]
      # @api private
      def initialize(model_class)
        @target = model_class
        @query = target.odata_entity_set.query
        @last_criteria = nil
        set_default_select
      end

      # Sets up a new criteria for filters for the given property name.
      # @param argument [Hash,to_sym]
      # @return [self]
      # @api private
      def where(argument)
        if argument.is_a?(Hash)
          argument.each do |property_name, value|
            self.where(property_name.to_sym).is(eq: value)
          end
        else
          @last_criteria = query[target.property_map[argument.to_sym]]
        end

        self
      end

      # Sets up last criteria with supplied argument sets.
      # @param arguments [Hash]
      # @return [self]
      def is(arguments)
        raise ArgumentError 'can only accept Hash argument' unless arguments.is_a?(Hash)
        property_name = last_criteria.property
        arguments.each do |operator, value|
          @last_criteria = query[property_name].send(operator.to_sym, value)
          query.where(@last_criteria)
        end
        self
      end

      # Specifies the limit for the query.
      # @param value [to_i]
      # @return [self]
      def limit(value)
        query.limit(value.to_i)
        self
      end

      # Specifies the number of entities to skip for the query.
      # @param value [to_i]<commit_msg>Added functionality to QueryProxy#where so that strings are passed straight down to the underlying OData::Query instance.<commit_after>module OData
  module Model
    # Provides the proxy between OData::Query and OData::Model.
    class QueryProxy
      include Enumerable

      # Last filter criteria set on the query.
      attr_reader :last_criteria

      # Instantiates a new QueryProxy for the supplied OData::Model class.
      # @param model_class [Class]
      # @api private
      def initialize(model_class)
        @target = model_class
        @query = target.odata_entity_set.query
        @last_criteria = nil
        set_default_select
      end

      # Sets up a new criteria for filters for the given property name.
      # @param argument [Hash,to_sym]
      # @return [self]
      # @api private
      def where(argument)
        if argument.is_a?(Hash)
          argument.each do |property_name, value|
            self.where(property_name).is(eq: value)
          end
        else
          if argument.is_a?(String)
            @last_criteria = query[argument]
          else
            @last_criteria = query[target.property_map[argument.to_sym]]
          end
        end

        self
      end

      # Sets up last criteria with supplied argument sets.
      # @param arguments [Hash]
      # @return [self]
      def is(arguments)
        raise ArgumentError 'can only accept Hash argument' unless arguments.is_a?(Hash)
        property_name = last_criteria.property
        arguments.each do |operator, value|
          @last_criteria = query[property_name].send(operator.to_sym, value)
          query.where(@last_criteria)
        end
        self
      end

      # Specifies the limit for the query.
      # @param value [to_i]
      # @return [self]
      def limit(value)
        query.limit(value.to_i)
        self
      end

      # Specifies the number of entities to skip for the query.
      # @param value [to_i]
{'fraction_non_alphanumeric': 0.07318390494193897, 'fraction_numerical': 0.0, 'mean_word_length': 2.1658119658119657, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2205394', 'n_tokens_mistral': 1036, 'n_tokens_neox': 1022, 'n_words': 320}