mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #42368 from engwan/postgresql-empty-query-check
Use an empty query instead of SELECT 1
This commit is contained in:
commit
ed3612e6d4
2 changed files with 7 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
* Use an empty query to check if the PostgreSQL connection is still active
|
||||
|
||||
An empty query is faster than `SELECT 1`.
|
||||
|
||||
*Heinrich Lee Yu*
|
||||
|
||||
* Add `ActiveRecord::Base#previously_persisted?`
|
||||
|
||||
Returns `true` if the object has been previously persisted but now it has been deleted.
|
||||
|
|
|
@ -292,7 +292,7 @@ module ActiveRecord
|
|||
# Is this connection alive and ready for queries?
|
||||
def active?
|
||||
@lock.synchronize do
|
||||
@connection.query "SELECT 1"
|
||||
@connection.query ";"
|
||||
end
|
||||
true
|
||||
rescue PG::Error
|
||||
|
|
Loading…
Reference in a new issue