From 2e609784f22face9ee92b87a9c9e9a9c27311640 Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Tue, 20 Jun 2023 21:35:04 -0300 Subject: [PATCH] Update for ConnectionBuilder --- src/sqlite3/driver.cr | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/sqlite3/driver.cr b/src/sqlite3/driver.cr index 4309def..93ae0b0 100644 --- a/src/sqlite3/driver.cr +++ b/src/sqlite3/driver.cr @@ -1,9 +1,16 @@ class SQLite3::Driver < DB::Driver - def connection_builder(uri : URI) : Proc(::DB::Connection) + class ConnectionBuilder < ::DB::ConnectionBuilder + def initialize(@options : ::DB::Connection::Options, @sqlite3_options : SQLite3::Connection::Options) + end + + def build : ::DB::Connection + SQLite3::Connection.new(@options, @sqlite3_options) + end + end + + def connection_builder(uri : URI) : ::DB::ConnectionBuilder params = HTTP::Params.parse(uri.query || "") - options = connection_options(params) - sqlite3_options = SQLite3::Connection::Options.from_uri(uri) - ->{ SQLite3::Connection.new(options, sqlite3_options).as(::DB::Connection) } + ConnectionBuilder.new(connection_options(params), SQLite3::Connection::Options.from_uri(uri)) end end