Repository: rails/rails
File: activerecord/lib/active_record/relation/query_methods.rb (Ruby)

Code before:
        Arel::SelectManager.new(subquery).project(select_value).tap do |arel|
          arel.optimizer_hints(*optimizer_hints_values) unless optimizer_hints_values.empty?
        end
      end

      def build_where_clause(opts, rest = []) # :nodoc:
        opts = sanitize_forbidden_attributes(opts)

        if opts.is_a?(Array)
          opts, *rest = opts
        end

        case opts
        when String
          if rest.empty?
            if Arel.arel_node?(opts)
              parts = [opts]
            else
              parts = [Arel.sql(opts)]
            end
          elsif rest.first.is_a?(Hash) && /:\w+/.match?(opts)
            parts = [build_named_bound_sql_literal(opts, rest.first)]
          elsif opts.include?("?")
            parts = [build_bound_sql_literal(opts, rest)]
          else
            parts = [Arel.sql(model.sanitize_sql([opts, *rest]))]
          end
        when Hash
          opts = opts.transform_keys do |key|
            if key.is_a?(Array)
              key.map { |k| model.attribute_aliases[k.to_s] || k.to_s }
            else
              key = key.to_s
              model.attribute_aliases[key] || key
            end
          end
          references = PredicateBuilder.references(opts)
          self.references_values |= references unless references.empty?

          parts = predicate_builder.build_from_hash(opts) do |table_name|
            lookup_table_klass_from_join_dependencies(table_name)
          end
        when Arel::Nodes::Node
          parts = [opts]
        else
          raise ArgumentError, "Unsupported argument type: #{opts} (#{opts.class})"
        end

        Relation::WhereClause.new(parts)
      end
      alias :build_having_clause :build_where_clause

Review comment (suggestion):
The `rest.empty?` check appears to have been dead code since 8e6a5deca626c944933211d7977f4e7e76869e74

Code after:
    protected
      def build_subquery(subquery_alias, select_value) # :nodoc:
        subquery = except(:optimizer_hints).arel.as(subquery_alias)

        Arel::SelectManager.new(subquery).project(select_value).tap do |arel|
          arel.optimizer_hints(*optimizer_hints_values) unless optimizer_hints_values.empty?
        end
      end

      def build_where_clause(opts, rest = []) # :nodoc:
        opts = sanitize_forbidden_attributes(opts)

        if opts.is_a?(Array)
          opts, *rest = opts
        end

        case opts
        when String
          if rest.empty?
            parts = [Arel.sql(opts)]
          elsif rest.first.is_a?(Hash) && /:\w+/.match?(opts)
            parts = [build_named_bound_sql_literal(opts, rest.first)]
          elsif opts.include?("?")
            parts = [build_bound_sql_literal(opts, rest)]
          else
            parts = [Arel.sql(model.sanitize_sql([opts, *rest]))]
          end
        when Hash
          opts = opts.transform_keys do |key|
            if key.is_a?(Array)
              key.map { |k| model.attribute_aliases[k.to_s] || k.to_s }
            else
              key = key.to_s
              model.attribute_aliases[key] || key
            end
          end
          references = PredicateBuilder.references(opts)
          self.references_values |= references unless references.empty?

          parts = predicate_builder.build_from_hash(opts) do |table_name|
            lookup_table_klass_from_join_dependencies(table_name)
          end
        when Arel::Nodes::Node
          parts = [opts]
        else
          raise ArgumentError, "Unsupported argument type: #{opts} (#{opts.class})"
        end

        Relation::WhereClause.new(parts)
      end
      alias :build_having_clause :build_where_clause