Skip to content

Commit 203381c

Browse files
committed
Do not call connection directly
1 parent 4d57270 commit 203381c

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

test/cases/adapter_test_sqlserver.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
6161
end
6262

6363
it "test table existence across database schemas" do
64-
arunit_connection = Topic.connection
65-
arunit2_connection = College.connection
64+
arunit_connection = Topic.lease_connection
65+
arunit2_connection = College.lease_connection
6666

6767
arunit_database = arunit_connection.pool.db_config.database
6868
arunit2_database = arunit2_connection.pool.db_config.database

test/cases/coerced_tests.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ def test_implicit_order_column_is_configurable_coerced
10181018
assert_equal topics(:fifth), Topic.first
10191019
assert_equal topics(:third), Topic.last
10201020

1021-
c = Topic.connection
1021+
c = Topic.lease_connection
10221022
assert_sql(/ORDER BY #{Regexp.escape(c.quote_table_name("topics.title"))} DESC, #{Regexp.escape(c.quote_table_name("topics.id"))} DESC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY.*@0 = 1/i) {
10231023
Topic.last
10241024
}
@@ -1032,7 +1032,7 @@ def test_implicit_order_set_to_primary_key_coerced
10321032
old_implicit_order_column = Topic.implicit_order_column
10331033
Topic.implicit_order_column = "id"
10341034

1035-
c = Topic.connection
1035+
c = Topic.lease_connection
10361036
assert_sql(/ORDER BY #{Regexp.escape(c.quote_table_name("topics.id"))} DESC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY.*@0 = 1/i) {
10371037
Topic.last
10381038
}
@@ -1046,7 +1046,7 @@ def test_implicit_order_for_model_without_primary_key_coerced
10461046
old_implicit_order_column = NonPrimaryKey.implicit_order_column
10471047
NonPrimaryKey.implicit_order_column = "created_at"
10481048

1049-
c = NonPrimaryKey.connection
1049+
c = NonPrimaryKey.lease_connection
10501050

10511051
assert_sql(/ORDER BY #{Regexp.escape(c.quote_table_name("non_primary_keys.created_at"))} DESC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY.*@0 = 1/i) {
10521052
NonPrimaryKey.last
@@ -1067,7 +1067,7 @@ def test_member_on_unloaded_relation_with_composite_primary_key_coerced
10671067
# Check for `FETCH NEXT x ROWS` rather then `LIMIT`.
10681068
coerce_tests! :test_implicit_order_column_prepends_query_constraints
10691069
def test_implicit_order_column_prepends_query_constraints_coerced
1070-
c = ClothingItem.connection
1070+
c = ClothingItem.lease_connection
10711071
ClothingItem.implicit_order_column = "description"
10721072
quoted_type = Regexp.escape(c.quote_table_name("clothing_items.clothing_type"))
10731073
quoted_color = Regexp.escape(c.quote_table_name("clothing_items.color"))
@@ -1083,7 +1083,7 @@ def test_implicit_order_column_prepends_query_constraints_coerced
10831083
# Check for `FETCH NEXT x ROWS` rather then `LIMIT`.
10841084
coerce_tests! %r{#last for a model with composite query constraints}
10851085
test "#last for a model with composite query constraints coerced" do
1086-
c = ClothingItem.connection
1086+
c = ClothingItem.lease_connection
10871087
quoted_type = Regexp.escape(c.quote_table_name("clothing_items.clothing_type"))
10881088
quoted_color = Regexp.escape(c.quote_table_name("clothing_items.color"))
10891089

@@ -1095,7 +1095,7 @@ def test_implicit_order_column_prepends_query_constraints_coerced
10951095
# Check for `FETCH NEXT x ROWS` rather then `LIMIT`.
10961096
coerce_tests! %r{#first for a model with composite query constraints}
10971097
test "#first for a model with composite query constraints coerced" do
1098-
c = ClothingItem.connection
1098+
c = ClothingItem.lease_connection
10991099
quoted_type = Regexp.escape(c.quote_table_name("clothing_items.clothing_type"))
11001100
quoted_color = Regexp.escape(c.quote_table_name("clothing_items.color"))
11011101

@@ -1107,7 +1107,7 @@ def test_implicit_order_column_prepends_query_constraints_coerced
11071107
# Check for `FETCH NEXT x ROWS` rather then `LIMIT`.
11081108
coerce_tests! :test_implicit_order_column_reorders_query_constraints
11091109
def test_implicit_order_column_reorders_query_constraints_coerced
1110-
c = ClothingItem.connection
1110+
c = ClothingItem.lease_connection
11111111
ClothingItem.implicit_order_column = "color"
11121112
quoted_type = Regexp.escape(c.quote_table_name("clothing_items.clothing_type"))
11131113
quoted_color = Regexp.escape(c.quote_table_name("clothing_items.color"))
@@ -1131,7 +1131,7 @@ def test_include_on_unloaded_relation_with_composite_primary_key_coerced
11311131
# Check for `FETCH NEXT x ROWS` rather then `LIMIT`.
11321132
coerce_tests! :test_nth_to_last_with_order_uses_limit
11331133
def test_nth_to_last_with_order_uses_limit_coerced
1134-
c = Topic.connection
1134+
c = Topic.lease_connection
11351135
assert_sql(/ORDER BY #{Regexp.escape(c.quote_table_name("topics.id"))} DESC OFFSET @(\d) ROWS FETCH NEXT @(\d) ROWS ONLY.*@\1 = 1.*@\2 = 1/i) do
11361136
Topic.second_to_last
11371137
end
@@ -2338,7 +2338,7 @@ def test_preloads_has_many_on_model_with_a_composite_primary_key_through_id_attr
23382338
assert_equal 2, sql.size
23392339
preload_sql = sql.last
23402340

2341-
c = Cpk::OrderAgreement.connection
2341+
c = Cpk::OrderAgreement.lease_connection
23422342
order_id_column = Regexp.escape(c.quote_table_name("cpk_order_agreements.order_id"))
23432343
order_id_constraint = /#{order_id_column} = @0.*@0 = \d+$/
23442344
expectation = /SELECT.*WHERE.* #{order_id_constraint}/
@@ -2362,7 +2362,7 @@ def test_preloads_belongs_to_a_composite_primary_key_model_through_id_attribute_
23622362
assert_equal 2, sql.size
23632363
preload_sql = sql.last
23642364

2365-
c = Cpk::Order.connection
2365+
c = Cpk::Order.lease_connection
23662366
order_id = Regexp.escape(c.quote_table_name("cpk_orders.id"))
23672367
order_constraint = /#{order_id} = @0.*@0 = \d+$/
23682368
expectation = /SELECT.*WHERE.* #{order_constraint}/

0 commit comments

Comments
 (0)