unit-record icon indicating copy to clipboard operation
unit-record copied to clipboard

unit_record does not work correct with postgresql adapter.

Open jarl-dk opened this issue 15 years ago • 5 comments

Hi. I am using postgresql.

Now I wanted to use unit_record to speed up my tests. However I realise that it fails with NoMethodError: undefined method `indexes' for #ActiveRecord::ConnectionAdapters::UnitRecordAdapter:0x7fa18f27ba90

It seems like the postgresql_adapter implements this method, and it is called when invoking ActiveRecord::Base#Count

However If I monkeypatch like this (in unit_test_helper.rb) class ActiveRecord::ConnectionAdapters::UnitRecordAdapter def indexes(table_name, name = nil) [] end end

I get the correct behaviour "RuntimeError: ActiveRecord is disconnected; database access is unavailable in unit tests."

jarl-dk avatar Apr 19 '10 11:04 jarl-dk

Seems like the formatting of the monkey patch went wrong: class ActiveRecord::ConnectionAdapters::UnitRecordAdapter def indexes(table_name, name = nil) [] end end

jarl-dk avatar Apr 19 '10 12:04 jarl-dk

Thanks for reporting this bug. Which version of Rails / ActiveRecord?

dan-manges avatar Apr 22 '10 21:04 dan-manges

Rails version 2.3.5 activerecord 2.3.5

Notice that unit_record is intercepting calls to the adapter, and aparently when using postgresql adapter (and aparently only when using postgresql adapter) activerecord directly (or indirectly) calls a #indexes method.

I have no idea why.

jarl-dk avatar Apr 23 '10 06:04 jarl-dk

Dan, do you have any updates on this issue?

jarl-dk avatar Jul 05 '10 18:07 jarl-dk

I'll get this fixed and released this week.

dan-manges avatar Jul 06 '10 01:07 dan-manges