From fba1a65712c4a3bf052369b5c1cd3f2b3000eb47 Mon Sep 17 00:00:00 2001 From: Joshua Pinter Date: Tue, 23 Jan 2024 14:27:57 -0700 Subject: [PATCH] Transform options keys to symbols. Before this, any options with a String key (e.g. "host") instead of a Symbol key (e.g. :host) would get silently ignored. This is surprising in general but in particular, when using Rails and reading the `database.yml` config, they are all String keys so have no affect unless they are transformed before passing to `Trilogy.new`. This reduces the surprises and ensures the keys are all transformed to Symbols before accessing them. --- contrib/ruby/lib/trilogy.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/ruby/lib/trilogy.rb b/contrib/ruby/lib/trilogy.rb index bde8a033..700cb558 100644 --- a/contrib/ruby/lib/trilogy.rb +++ b/contrib/ruby/lib/trilogy.rb @@ -8,6 +8,7 @@ class Trilogy def initialize(options = {}) + options = options.transform_keys(&:to_sym) options[:port] = options[:port].to_i if options[:port] mysql_encoding = options[:encoding] || "utf8mb4" encoding = Trilogy::Encoding.find(mysql_encoding)