Skip to content

Commit c9ff811

Browse files
authored
Merge pull request ged#660 from larskanis/fix-ractor-constants
Fix some constants to be frozen and usable in a Ractor
2 parents 6b17435 + 0745dc9 commit c9ff811

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

lib/pg.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module PG
2121
POSTGRESQL_LIB_PATH = false
2222
end
2323
end
24+
POSTGRESQL_LIB_PATH.freeze
2425

2526
add_dll_path = proc do |path, &block|
2627
if RUBY_PLATFORM =~/(mswin|mingw)/i && path

lib/pg/version.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
module PG
23
# Library version
34
VERSION = '1.6.1'

spec/pg_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,14 @@
5757

5858
expect( bres ).to eq( 55 )
5959
end
60+
61+
it "should provide constants in a Ractor", :ractor do
62+
vals = Ractor.new(@conninfo) do |conninfo|
63+
[PG.library_version, PG.version_string, PG.threadsafe?, PG::VERSION, PG::POSTGRESQL_LIB_PATH]
64+
end.value
65+
66+
expect( vals ).to eq(
67+
[PG.library_version, PG.version_string, PG.threadsafe?, PG::VERSION, PG::POSTGRESQL_LIB_PATH]
68+
)
69+
end
6070
end

0 commit comments

Comments
 (0)