Skip to content

Conversation

Copy link

Copilot AI commented Jan 20, 2026

Rails 8.1 deprecated AbstractAdapter#check_if_write_query(), which is called by the redshift adapters in execute_and_clear.

Changes

  • Added conditional implementation of check_if_write_query to redshift_8_0_adapter.rb, redshift_7_2_adapter.rb, and redshift_7_1_adapter.rb
  • Method is only defined when not present in AbstractAdapter, ensuring compatibility across Rails versions
# Rails 8.1 deprecated AbstractAdapter#check_if_write_query
# Implement it here for compatibility if it doesn't exist in the parent class
unless AbstractAdapter.method_defined?(:check_if_write_query)
  def check_if_write_query(sql)
    return unless preventing_writes? && write_query?(sql)

    raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
  end
end

This maintains identical behavior to the original Rails implementation while supporting both Rails versions with and without the deprecated method.

Original prompt

This section details on the original issue you should resolve

<issue_title>Rails 8.1 deprecated AbstractAdapter#check_if_write_query() method, which breaks compatibility of this library</issue_title>
<issue_description>## Problem
Rails 8.1 deprecated AbstractAdapter#check_if_write_query() method, which breaks compatibility of this library.

The original method code is this:

  def check_if_write_query(sql)
    return unless preventing_writes? && write_query?(sql)

    raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
  end

You can reimplement the same method for the 8.0-related adapter, but only if it doesn't exist yet in the runtime from the AbstractAdapter.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix Rails 8.1 deprecated method compatibility Add conditional check_if_write_query for Rails 8.1 compatibility Jan 20, 2026
Copilot AI requested a review from lancedikson January 20, 2026 15:31
@lancedikson lancedikson force-pushed the copilot/fix-rails-81-deprecation-issue branch from dfc80f4 to 6d2f4f5 Compare January 21, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rails 8.1 deprecated AbstractAdapter#check_if_write_query() method, which breaks compatibility of this library

2 participants