Skip to content

Commit 622adbb

Browse files
committed
fix: lease_connection -> connection
1 parent d8764da commit 622adbb

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

test/cases/primary_keys_test.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,38 @@ def test_schema_dump_primary_key_integer_with_default_nil
9797
assert_match %r{create_table "int_defaults", id: :bigint, default: nil}, schema
9898
end
9999
end
100+
101+
class PrimaryKeyHiddenColumnTest < ActiveRecord::TestCase
102+
class Rocket < ActiveRecord::Base
103+
end
104+
105+
def setup
106+
connection = ActiveRecord::Base.connection
107+
connection.execute <<-SQL
108+
CREATE TABLE rockets(
109+
id SERIAL PRIMARY KEY USING HASH WITH (bucket_count=4)
110+
)
111+
SQL
112+
end
113+
114+
def teardown
115+
ActiveRecord::Base.connection.drop_table :rockets
116+
end
117+
118+
def test_to_key_with_hidden_primary_key_part
119+
rocket = Rocket.new
120+
assert_nil rocket.to_key
121+
rocket.save
122+
assert_equal rocket.to_key, [rocket.id]
123+
end
124+
125+
def test_read_attribute_with_hidden_primary_key_part
126+
rocket = Rocket.create!
127+
id = assert_not_deprecated(ActiveRecord.deprecator) do
128+
rocket.read_attribute(:id)
129+
end
130+
131+
assert_equal rocket.id, id
132+
end
133+
end
100134
end

test/cases/schema_dumper_test.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ class SchemaDumperTest < ActiveRecord::TestCase
1010
include SchemaDumpingHelper
1111
self.use_transactional_tests = false
1212

13-
setup do
14-
@schema_migration = ActiveRecord::Base.connection_pool.schema_migration
15-
@schema_migration.create_table
16-
end
17-
1813
# See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/347
1914
def test_dump_index_rather_than_unique_constraints
2015
ActiveRecord::Base.with_connection do |conn|
@@ -207,7 +202,7 @@ def down
207202
$stdout = original
208203
end
209204

210-
if ActiveRecord::Base.lease_connection.supports_check_constraints?
205+
if ActiveRecord::Base.connection.supports_check_constraints?
211206
def test_schema_dumps_check_constraints
212207
constraint_definition = dump_table_schema("products").split(/\n/).grep(/t.check_constraint.*products_price_check/).first.strip
213208
if current_adapter?(:Mysql2Adapter)

0 commit comments

Comments
 (0)