Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update example in section "Configure Connection" in README.md #1241

Closed
andsip opened this issue Oct 10, 2024 · 2 comments
Closed

Update example in section "Configure Connection" in README.md #1241

andsip opened this issue Oct 10, 2024 · 2 comments

Comments

@andsip
Copy link
Contributor

andsip commented Oct 10, 2024

The following example code is proposed at the moment:

module ActiveRecord
  module ConnectionAdapters
    class SQLServerAdapter < AbstractAdapter
      def configure_connection
        super
        @raw_connection.execute("SET TEXTSIZE #{64.megabytes}").do
      end
    end
  end
end

However, as of commit 4842d2e, this implementation no longer works, as far as I see it.

This is because method #configure_connection was defined on SQLServerAdapter in that commit, which means that the example in the Readme will override this method, causing a call to super to invoke AbstractAdapter#configure_connection and not SQLServerAdapter#configure_connection (as intended).

The following adaptation of the example code works for me:

ActiveRecord::ConnectionAdapters::SQLServerAdapter.prepend(
  Module.new do
    def configure_connection
      super
      @raw_connection.execute("SET TEXTSIZE #{64.megabytes}").do
    end
  end
)
@aidanharan
Copy link
Contributor

@andsip Good point! Could you review #1242 and see what you think?

@aidanharan
Copy link
Contributor

Updated README in #1242

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

No branches or pull requests

2 participants