Skip to content

Commit b54833f

Browse files
committed
Use lease_connection instead of soft deprecated connection [ci-skip]
1 parent 59c32ab commit b54833f

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

activerecord/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This will let you to drop multiple tables in a single call.
44

55
```ruby
6-
ActiveRecord::Base.connection.drop_table(:users, :posts)
6+
ActiveRecord::Base.lease_connection.drop_table(:users, :posts)
77
```
88

99
*Gabriel Sobrinho*

guides/source/active_record_postgresql.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ add_reference :alias, :person, foreign_key: { deferrable: :deferred }
628628
If the reference was created with the `foreign_key: true` option, the following transaction would fail when executing the first `INSERT` statement. It does not fail when the `deferrable: :deferred` option is set though.
629629

630630
```ruby
631-
ActiveRecord::Base.connection.transaction do
631+
ActiveRecord::Base.lease_connection.transaction do
632632
person = Person.create(id: SecureRandom.uuid, alias_id: SecureRandom.uuid, name: "John Doe")
633633
Alias.create(id: person.alias_id, person_id: person.id, name: "jaydee")
634634
end
@@ -637,8 +637,8 @@ end
637637
When the `:deferrable` option is set to `:immediate`, let the foreign keys keep the default behavior of checking the constraint immediately, but allow manually deferring the checks using `set_constraints` within a transaction. This will cause the foreign keys to be checked when the transaction is committed:
638638

639639
```ruby
640-
ActiveRecord::Base.connection.transaction do
641-
ActiveRecord::Base.connection.set_constraints(:deferred)
640+
ActiveRecord::Base.lease_connection.transaction do
641+
ActiveRecord::Base.lease_connection.set_constraints(:deferred)
642642
person = Person.create(alias_id: SecureRandom.uuid, name: "John Doe")
643643
Alias.create(id: person.alias_id, person_id: person.id, name: "jaydee")
644644
end

guides/source/active_record_querying.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,17 +2307,17 @@ irb> Customer.find_by_sql("SELECT * FROM customers INNER JOIN orders ON customer
23072307

23082308
### `select_all`
23092309

2310-
`find_by_sql` has a close relative called [`connection.select_all`][]. `select_all` will retrieve
2310+
`find_by_sql` has a close relative called [`lease_connection.select_all`][]. `select_all` will retrieve
23112311
objects from the database using custom SQL just like `find_by_sql` but will not instantiate them.
23122312
This method will return an instance of `ActiveRecord::Result` class and calling `to_a` on this
23132313
object would return you an array of hashes where each hash indicates a record.
23142314

23152315
```irb
2316-
irb> Customer.connection.select_all("SELECT first_name, created_at FROM customers WHERE id = '1'").to_a
2316+
irb> Customer.lease_connection.select_all("SELECT first_name, created_at FROM customers WHERE id = '1'").to_a
23172317
=> [{"first_name"=>"Rafael", "created_at"=>"2012-11-10 23:23:45.281189"}, {"first_name"=>"Eileen", "created_at"=>"2013-12-09 11:22:35.221282"}]
23182318
```
23192319

2320-
[`connection.select_all`]: https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#method-i-select_all
2320+
[`lease_connection.select_all`]: https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#method-i-select_all
23212321

23222322
### `pluck`
23232323

0 commit comments

Comments
 (0)