Repository: rails/rails
File: activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb (Ruby)

Code before:
      # `nil` is the default value and maintains default behavior. If an array of column names is passed -
      # the result will contain values of the specified columns from the inserted row.
      def exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil, returning: nil)
        ActiveRecord.deprecator.warn("exec_insert is deprecated and will be removed in Rails 8.2. " \
                                     "Please use #insert instead.")

        intent = QueryIntent.new(raw_sql: sql, name: name, binds: binds)

        _exec_insert(intent, pk, sequence_name, returning: returning)
      end

      def _exec_insert(intent, pk = nil, sequence_name = nil, returning: nil) # :nodoc:
        # Call sql_for_insert and write results back to intent
        sql, binds = sql_for_insert(intent.raw_sql, pk, intent.binds, returning)
        intent.raw_sql = sql
        intent.binds = binds

        raw_exec_query(intent)
      end

      # Executes delete +sql+ statement in the context of this connection using
      # +binds+ as the bind substitutes. +name+ is logged along with
      # the executed +sql+ statement.
      def exec_delete(sql, name = nil, binds = [])
        ActiveRecord.deprecator.warn("exec_delete is deprecated and will be removed in Rails 8.2. " \
                                     "Please use #delete instead.")

        affected_rows(internal_execute(sql, name, binds))
      end

      # Executes update +sql+ statement in the context of this connection using
      # +binds+ as the bind substitutes. +name+ is logged along with
      # the executed +sql+ statement.
      def exec_update(sql, name = nil, binds = [])
        ActiveRecord.deprecator.warn("exec_update is deprecated and will be removed in Rails 8.2. " \
                                     "Please use #update instead.")

        affected_rows(internal_execute(sql, name, binds))
      end

      def exec_insert_all(sql, name) # :nodoc:
        internal_exec_query(sql, name)
      end

      def explain(arel, binds = [], options = []) # :nodoc:
        raise NotImplementedError
      end

      # Executes an INSERT query and returns the new record's ID
      #
      # +id_value+ will be returned unless the value is +nil+, in

Review comment (refactor):
Nitpick: You could use `deprecate_methods` helper for all of these.

Code after:
      # `nil` is the default value and maintains default behavior. If an array of column names is passed -
      # the result will contain values of the specified columns from the inserted row.
      def exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil, returning: nil)
        intent = QueryIntent.new(raw_sql: sql, name: name, binds: binds)

        _exec_insert(intent, pk, sequence_name, returning: returning)
      end

      def _exec_insert(intent, pk = nil, sequence_name = nil, returning: nil) # :nodoc:
        sql, binds = sql_for_insert(intent.raw_sql, pk, intent.binds, returning)
        intent.raw_sql = sql
        intent.binds = binds

        raw_exec_query(intent)
      end

      # Executes delete +sql+ statement in the context of this connection using
      # +binds+ as the bind substitutes. +name+ is logged along with
      # the executed +sql+ statement.
      def exec_delete(sql, name = nil, binds = [])
        affected_rows(internal_execute(sql, name, binds))
      end

      # Executes update +sql+ statement in the context of this connection using
      # +binds+ as the bind substitutes. +name+ is logged along with
      # the executed +sql+ statement.
      def exec_update(sql, name = nil, binds = [])
        affected_rows(internal_execute(sql, name, binds))
      end

      deprecate :exec_insert, :exec_delete, :exec_update, deprecator: ActiveRecord.deprecator

      def exec_insert_all(sql, name) # :nodoc:
        internal_exec_query(sql, name)
      end

      def explain(arel, binds = [], options = []) # :nodoc:
        raise NotImplementedError
      end

      # Executes an INSERT query and returns the new record's ID
      #
      # +id_value+ will be returned unless the value is +nil+, in
      # which case the database will attempt to calculate the last inserted
      # id and return that value.
      #
      # If the next id was calculated in advance (as in Oracle), it should be
      # passed in as +id_value+.
      # Some adapters support the `returning` keyword argument which allows defining the return value of the method:
      # `nil` is the default value and maintains default behavior. If an array of column names is passed -
      # an array of is returned from the method representing values of the specified columns from the inserted row.