Skip to content

Commit

Permalink
Merge pull request #215 from byroot/fix-ractor-support
Browse files Browse the repository at this point in the history
Fix Ractor support
  • Loading branch information
jhawthorn authored Dec 18, 2024
2 parents 857c167 + 5d36347 commit 19ac866
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions contrib/ruby/lib/trilogy/encoding.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Trilogy
module Encoding
RUBY_ENCODINGS = {
Expand Down
10 changes: 10 additions & 0 deletions contrib/ruby/test/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1131,4 +1131,14 @@ def test_error_classes_exclusively_match_subclasses
assert_operator SystemCallError, :===, klass.new
assert_operator Trilogy::ConnectionError, :===, klass.new
end

if defined?(::Ractor)
def test_is_ractor_compatible
ractor = Ractor.new do
client = TrilogyTest.new(nil).new_tcp_client
client.query("SELECT 1")
end
assert_equal [[1]], ractor.take.to_a
end
end
end
6 changes: 3 additions & 3 deletions contrib/ruby/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
end

class TrilogyTest < Minitest::Test
DEFAULT_HOST = ENV["MYSQL_HOST"] || "127.0.0.1"
DEFAULT_HOST = (ENV["MYSQL_HOST"] || "127.0.0.1").freeze
DEFAULT_PORT = (port = ENV["MYSQL_PORT"].to_i) && port != 0 ? port : 3306
DEFAULT_USER = ENV["MYSQL_USER"] || "root"
DEFAULT_PASS = ENV["MYSQL_PASS"]
DEFAULT_USER = (ENV["MYSQL_USER"] || "root").freeze
DEFAULT_PASS = ENV["MYSQL_PASS"].freeze

def assert_equal_timestamp(time1, time2)
assert_equal time1.to_i, time2.to_i
Expand Down

0 comments on commit 19ac866

Please sign in to comment.