diff --git a/src/db.cr b/src/db.cr index c0e0b64..5697155 100644 --- a/src/db.cr +++ b/src/db.cr @@ -152,7 +152,12 @@ module DB end private def self.build_database(uri : URI) - Database.new(build_driver(uri), uri) + driver = build_driver(uri) + params = HTTP::Params.parse(uri.query || "") + connection_options = driver.connection_options(params) + pool_options = driver.pool_options(params) + factory = driver.connection_builder(uri) + Database.new(connection_options, pool_options, &factory) end private def self.build_connection(connection_string : String) diff --git a/src/db/database.cr b/src/db/database.cr index b4a555b..6f2073e 100644 --- a/src/db/database.cr +++ b/src/db/database.cr @@ -39,15 +39,6 @@ module DB @setup_connection : Connection -> Nil @statements_cache = StringKeyCache(PoolPreparedStatement).new - # :nodoc: - def initialize(driver : Driver, uri : URI) - params = HTTP::Params.parse(uri.query || "") - connection_options = driver.connection_options(params) - pool_options = driver.pool_options(params) - factory = driver.connection_builder(uri) - initialize(connection_options, pool_options, &factory) - end - # Initialize a database with the specified options and connection factory. # This covers more advanced use cases that might not be supported by an URI connection string such as tunneling connection. def initialize(connection_options : Connection::Options, pool_options : Pool::Options, &factory : -> Connection)