Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/mysql2/aurora.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ def self.method_missing(name, *args, &block) # rubocop:disable Style/MethodMissi
def self.const_missing(name)
Mysql2::Aurora::ORIGINAL_CLIENT_CLASS.const_get(name)
end

# Delegate const definition to class.
# @param [Symbol] name Const name
def self.const_defined?(name)
Mysql2::Aurora::ORIGINAL_CLIENT_CLASS.const_defined?(name)
end
end

# Swap Mysql2::Client
Expand Down
21 changes: 21 additions & 0 deletions spec/mysql2/aurora_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,27 @@
end
end

describe 'connection flags' do
let :multi_client do
Mysql2::Client.new(
host: ENV['TEST_DB_HOST'],
username: ENV['TEST_DB_USER'],
password: ENV['TEST_DB_PASS'],
aurora_max_retry: 10,
aurora_disconnect_on_readonly: aurora_disconnect_on_readonly,
flags: ["MULTI_STATEMENTS"]
)
end

subject do
multi_client.query('SELECT CURRENT_USER() AS user; SELECT CURRENT_USER() AS user;')
end

it 'supports multi statements after reconnect' do
expect { subject }.to_not raise_error
end
end

describe '#method_missing' do
subject do
client.ping
Expand Down