From 5bdec546576f91dd5a57c4845a5ca5d6d39a9d25 Mon Sep 17 00:00:00 2001 From: Lachlan Dowding Date: Fri, 11 Oct 2024 10:58:52 +1000 Subject: [PATCH 1/2] Fix `undefined constant ConnectionBuilder` compilation error Compiling the TDS driver with Crystal v1.14.0 results in the following error: C:\crystal-tds>crystal spec Showing last frame. Use --error-trace for full trace. In src\tds\driver.cr:13:5 13 | ConnectionBuilder.new(connection_options(params), TDS::Connection::Options.from_uri(uri)) ^---------------- Error: undefined constant ConnectionBuilder The `ConnectionBuilder` class had inadvertently been declared with an extra `TDS` level in its namespace by mistake: TDS::Driver::TDS::ConnectionBuilder Then it was later referred to using `TDS::ConnectionBuilder` which somehow worked on previous versions of the compiler. This fix removes the extra `TDS` level from the `ConnectionBuilder` namespace, as this was a typo, and changes references to use the fully-qualified name `TDS::Driver::ConnectionBuilder`. --- src/tds/driver.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tds/driver.cr b/src/tds/driver.cr index 4eb4359..1426692 100644 --- a/src/tds/driver.cr +++ b/src/tds/driver.cr @@ -1,5 +1,5 @@ class TDS::Driver < DB::Driver - class TDS::ConnectionBuilder < DB::ConnectionBuilder + class ConnectionBuilder < DB::ConnectionBuilder def initialize(@options : DB::Connection::Options, @tds_options : TDS::Connection::Options) end @@ -10,7 +10,7 @@ class TDS::Driver < DB::Driver def connection_builder(uri : URI) : DB::ConnectionBuilder params = HTTP::Params.parse(uri.query || "") - ConnectionBuilder.new(connection_options(params), TDS::Connection::Options.from_uri(uri)) + TDS::Driver::ConnectionBuilder.new(connection_options(params), TDS::Connection::Options.from_uri(uri)) end end From c9a236664f3ab00300874496ed1d3acfefe8befd Mon Sep 17 00:00:00 2001 From: Lachlan Dowding Date: Fri, 11 Oct 2024 11:00:55 +1000 Subject: [PATCH 2/2] Fix `sleep(Number)` deprecation compilation warning Compiling the TDS driver with Crystal v1.14.0 results in the following warning: C:\crystal-tds>crystal spec In spec\spec_helper.cr:16:7 16 | sleep(5) ^---- Warning: Deprecated ::sleep. Use `::sleep(Time::Span)` instead A total of 1 warnings were found. The `sleep(Number)` method has been deprecated in Crystal v1.14.0, refer: https://github.com/crystal-lang/crystal/pull/14962. This fix changes the use of `sleep(Number)` to `sleep(Time::Span)` in the `spec_helper.cr` file. --- spec/spec_helper.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr index 067777f..7c718b0 100644 --- a/spec/spec_helper.cr +++ b/spec/spec_helper.cr @@ -13,7 +13,7 @@ def connect(connection_string) return DB.open(uri) rescue exc : DB::ConnectionRefused raise exc if Time.local > expiry - sleep(5) + sleep(5.seconds) end end end