From e0ac73575e4485d80962221cdc0bce10239804c0 Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Mon, 29 May 2023 17:31:24 -0300 Subject: [PATCH] Update docs --- src/db/database.cr | 5 +++-- src/db/driver.cr | 13 +++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/db/database.cr b/src/db/database.cr index 6f2073e..c6d98d6 100644 --- a/src/db/database.cr +++ b/src/db/database.cr @@ -10,8 +10,9 @@ module DB # # ## Database URI # - # Connection parameters are configured in a URI. The format is specified by the individual - # database drivers. See the [reference book](https://crystal-lang.org/reference/database/) for examples. + # Connection parameters are usually in a URI. The format is specified by the individual + # database drivers, yet there are some common properties names usually shared. + # See the [reference book](https://crystal-lang.org/reference/database/) for examples. # # The connection pool can be configured from URI parameters: # diff --git a/src/db/driver.cr b/src/db/driver.cr index bb4e7a8..ed517f5 100644 --- a/src/db/driver.cr +++ b/src/db/driver.cr @@ -1,21 +1,23 @@ module DB # Database driver implementors must subclass `Driver`, # register with a driver_name using `DB#register_driver` and - # override the factory method `#build_connection`. + # override the factory method `#connection_builder`. # # ``` # require "db" # # class FakeDriver < DB::Driver - # def build_connection(context : DB::ConnectionContext) - # FakeConnection.new context + # def connection_builder(uri : URI) : Proc(DB::Connection) + # params = HTTP::Params.parse(uri.query || "") + # options = connection_options(params) + # ->{ FakeConnection.new(options).as(DB::Connection) } # end # end # # DB.register_driver "fake", FakeDriver # ``` # - # Access to this fake datbase will be available with + # Access to this fake database will be available with # # ``` # DB.open "fake://..." do |db| @@ -25,6 +27,9 @@ module DB # # Refer to `Connection`, `Statement` and `ResultSet` for further # driver implementation instructions. + # + # Override `#connection_options` and `#pool_options` to provide custom + # defaults or parsing of the connection string URI. abstract class Driver # Returns a new connection factory. #