Fix DB::DriverSpecs#with_db connection_string query param support (#192)

This commit is contained in:
Lachlan Dowding 2023-10-31 23:10:25 +10:00 committed by GitHub
parent 38faf7eeba
commit a527cfdc4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -396,7 +396,16 @@ module DB
# :nodoc:
def with_db(options = nil)
@before.call
DB.open("#{connection_string}#{"?#{options}" if options}") do |db|
if options
uri = URI.parse connection_string
uri.query_params.merge! URI::Params.parse(options)
connection_string_with_options = uri.to_s
else
connection_string_with_options = connection_string
end
DB.open(connection_string_with_options) do |db|
db.exec(sql_drop_table("table1"))
db.exec(sql_drop_table("table2"))
db.exec(sql_drop_table("person"))