Skip to content

Commit 8380604

Browse files
authored
Merge pull request rails#55368 from yahonda/pg18-warn-if-pg-gem-less-than-16
Emit a warning when `pg` gem < 1.6.0 is used with PostgreSQL 18+
2 parents 8cb4f8c + 85ebf8b commit 8380604

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

activerecord/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Emit a warning for pg gem < 1.6.0 when using PostgreSQL 18+
2+
3+
*Yasuo Honda*
4+
15
* Fix `#merge` with `#or` or `#and` and a mixture of attributes and SQL strings resulting in an incorrect query.
26

37
```ruby

activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,9 @@ def check_version # :nodoc:
666666
if database_version < 9_03_00 # < 9.3
667667
raise "Your version of PostgreSQL (#{database_version}) is too old. Active Record supports PostgreSQL >= 9.3."
668668
end
669+
if database_version >= 18_00_00 && Gem::Version.new(PG::VERSION) < Gem::Version.new("1.6.0")
670+
warn "pg gem version #{PG::VERSION} is known to be incompatible with PostgreSQL 18+. Please upgrade to pg 1.6.0 or later."
671+
end
669672
end
670673

671674
class << self

activerecord/test/cases/adapters/postgresql/transaction_test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ class Sample < ActiveRecord::Base
181181
end
182182

183183
test "raises Interrupt when canceling statement via interrupt" do
184+
if ActiveRecord::Base.lease_connection.database_version >= 18_00_00 && Gem::Version.new(PG::VERSION) < Gem::Version.new("1.6.0")
185+
skip "pg gem version #{PG::VERSION} is known to be incompatible with PostgreSQL 18+. "
186+
end
184187
start_time = Time.now
185188
thread = Thread.new do
186189
Sample.transaction do

0 commit comments

Comments
 (0)