From 4b4441bb3791cb6a295bb965e682a2ce3cf16fcf Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Thu, 6 Jun 2019 12:36:16 -0300 Subject: [PATCH] Code cleanup due to Crystal >= 0.28.0 --- spec/driver_spec.cr | 8 +------- spec/pool_spec.cr | 7 +------ src/sqlite3/connection.cr | 10 +--------- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/spec/driver_spec.cr b/spec/driver_spec.cr index fe1d963..fbd64b5 100644 --- a/spec/driver_spec.cr +++ b/spec/driver_spec.cr @@ -19,13 +19,7 @@ describe Driver do assert_filename("sqlite3:/path/to/file.db", "/path/to/file.db") assert_filename("sqlite3:///path/to/file.db", "/path/to/file.db") - {% if compare_versions(Crystal::VERSION, "0.28.0") >= 0 %} - # Before 0.28.0 the filename had the query string in this case - # but it didn't bother when deleting the file in pool_spec.cr. - # After 0.28.0 the behavior is changed, but can't be fixed prior that - # due to the use of URI#opaque. - assert_filename("sqlite3:./file.db?max_pool_size=5", "./file.db") - {% end %} + assert_filename("sqlite3:./file.db?max_pool_size=5", "./file.db") assert_filename("sqlite3:/path/to/file.db?max_pool_size=5", "/path/to/file.db") assert_filename("sqlite3://./file.db?max_pool_size=5", "./file.db") assert_filename("sqlite3:///path/to/file.db?max_pool_size=5", "/path/to/file.db") diff --git a/spec/pool_spec.cr b/spec/pool_spec.cr index edd3f2f..4971b94 100644 --- a/spec/pool_spec.cr +++ b/spec/pool_spec.cr @@ -21,12 +21,7 @@ describe DB::Pool do fibers.times { channel.receive } # all numbers were inserted - s : Int32 - {% if compare_versions(Crystal::VERSION, "0.28.0") >= 0 %} - s = fibers * max_n * (max_n + 1) // 2 - {% else %} - s = fibers * max_n * (max_n + 1) / 2 - {% end %} + s = fibers * max_n * (max_n + 1) // 2 db.scalar("select sum(n) from numbers").should eq(s) # numbers were not inserted one fiber at a time diff --git a/src/sqlite3/connection.cr b/src/sqlite3/connection.cr index 3b5c917..d02a875 100644 --- a/src/sqlite3/connection.cr +++ b/src/sqlite3/connection.cr @@ -9,15 +9,7 @@ class SQLite3::Connection < DB::Connection end def self.filename(uri : URI) - {% if compare_versions(Crystal::VERSION, "0.28.0") >= 0 %} - URI.unescape((uri.host || "") + uri.path) - {% else %} - URI.unescape (if path = uri.path - (uri.host || "") + path - else - uri.opaque.not_nil! - end) - {% end %} + URI.unescape((uri.host || "") + uri.path) end def build_prepared_statement(query)