diff --git a/lib/neighbor/model.rb b/lib/neighbor/model.rb index 4165025..6264da4 100644 --- a/lib/neighbor/model.rb +++ b/lib/neighbor/model.rb @@ -154,7 +154,7 @@ def self.neighbor_attributes if operator == "BIT_COUNT" "BIT_COUNT(#{quoted_attribute} ^ #{query})" else - "DISTANCE(#{quoted_attribute}, #{query}, #{connection.quote(operator)})" + "DISTANCE(#{quoted_attribute}, #{query}, #{connection_pool.with_connection { |c| c.quote(operator) }})" end else if operator == "#" diff --git a/lib/neighbor/utils.rb b/lib/neighbor/utils.rb index cfcbbcc..fe0b6ec 100644 --- a/lib/neighbor/utils.rb +++ b/lib/neighbor/utils.rb @@ -50,7 +50,7 @@ def self.adapter(model) when /sqlite/i :sqlite when /mysql|trilogy/i - model.connection.try(:mariadb?) ? :mariadb : :mysql + model.connection_pool.with_connection { |c| c.try(:mariadb?) } ? :mariadb : :mysql else :postgresql end