From 4fd11290f99e92d413ceb29cd5a787b9f40995bd Mon Sep 17 00:00:00 2001 From: Cal Heldenbrand Date: Wed, 26 Jun 2019 14:43:39 -0500 Subject: [PATCH] Check that @config exists. Fixes #413 Error message is: ActiveRecord::StatementInvalid: NoMethodError: undefined method `[]' for nil:NilClass: from octopus/lib/octopus/abstract_adapter.rb:23:in `octopus_shard' from octopus/lib/octopus/abstract_adapter.rb:12:in `instrument' from vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract_adapter.rb:478:in `log' This has shown to surface in the ibm_db and sqlserver adapters. --- lib/octopus/abstract_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/octopus/abstract_adapter.rb b/lib/octopus/abstract_adapter.rb index f6ce7956..646f2272 100644 --- a/lib/octopus/abstract_adapter.rb +++ b/lib/octopus/abstract_adapter.rb @@ -19,7 +19,7 @@ def method_missing(meth, *args, &block) end def octopus_shard - @config[:octopus_shard] + @config && @config[:octopus_shard] end def initialize(*args)