rails-sqlserver/activerecord-sqlserver-adapter

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

andsip opened this issue · 2 comments

andsip commented

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
)

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

Updated README in #1242