From 9ded3b9da5ed5f5a3c87ba50ec2a3cdeee77f829 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Thu, 27 Apr 2023 10:55:10 +0200 Subject: [PATCH] Fix error on warn with category on Truffleruby Avoid error "uninitialized constant Truffle::WarningOperations" on Truffleruby up to 22.3.1 The error was triggered by adding the :deprecation category in #528 --- lib/pg.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/pg.rb b/lib/pg.rb index a8884b740..159ff20b6 100644 --- a/lib/pg.rb +++ b/lib/pg.rb @@ -115,4 +115,15 @@ module TextEncoder require 'pg/tuple' autoload :VERSION, 'pg/version' + + # Avoid "uninitialized constant Truffle::WarningOperations" on Truffleruby up to 22.3.1 + if RUBY_ENGINE=="truffleruby" && !defined?(Truffle::WarningOperations) + module TruffleFixWarn + def warn(str, category=nil) + super(str) + end + end + Warning.extend(TruffleFixWarn) + end + end # module PG