Skip to content

Commit 603eab7

Browse files
authored
Merge pull request rails#41884 from jhawthorn/null_pool_methods
Add more methods to NullPool
2 parents ad654a8 + 82b958a commit 603eab7

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ class NullPool # :nodoc:
2626

2727
attr_accessor :schema_cache
2828

29-
def connection_klass
30-
nil
31-
end
29+
def connection_klass; end
30+
def checkin(_); end
31+
def remove(_); end
32+
def async_executor; end
3233
end
3334

3435
# Connection pool base class for managing Active Record database
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# frozen_string_literal: true
2+
3+
require "cases/helper"
4+
require "support/connection_helper"
5+
6+
module ActiveRecord
7+
module ConnectionAdapters
8+
class StandaloneConnectionTest < ActiveRecord::TestCase
9+
def setup
10+
super
11+
12+
db_config = ActiveRecord::Base.configurations.configs_for(env_name: "arunit", name: "primary")
13+
@connection = ActiveRecord::Base.public_send(db_config.adapter_method, db_config.configuration_hash)
14+
end
15+
16+
def test_can_query
17+
result = @connection.select_all("SELECT 1")
18+
assert_equal [[1]], result.rows
19+
end
20+
21+
def test_silently_ignore_async
22+
result = @connection.select_all("SELECT 1", async: true)
23+
assert_equal [[1]], result.rows
24+
end
25+
26+
def test_can_throw_away
27+
@connection.throw_away!
28+
assert_not @connection.active?
29+
end
30+
31+
def test_can_close
32+
@connection.close
33+
end
34+
end
35+
end
36+
end

0 commit comments

Comments
 (0)