From 6445cf7c4a4663decde12bb64a47b48d8898401f Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Thu, 21 Dec 2023 11:10:59 -0300 Subject: [PATCH] Update to crystal-db ~> 0.13 (#112) * Update to crystal-db ~> 0.13 * Update to crystal-db ~> 0.13.1 --- shard.yml | 2 +- src/mysql/read_packet.cr | 8 ++++---- src/mysql/write_packet.cr | 22 +++++++--------------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/shard.yml b/shard.yml index abbc4ad..6ddc8ab 100644 --- a/shard.yml +++ b/shard.yml @@ -4,7 +4,7 @@ version: 0.15.0 dependencies: db: github: crystal-lang/crystal-db - version: ~> 0.12.0 + version: ~> 0.13.1 authors: - Juan Wajnerman diff --git a/src/mysql/read_packet.cr b/src/mysql/read_packet.cr index 56745f4..5606a3b 100644 --- a/src/mysql/read_packet.cr +++ b/src/mysql/read_packet.cr @@ -12,8 +12,8 @@ class MySql::ReadPacket < IO io.read_fully(header.to_slice) @length = @remaining = header[0].to_i + (header[1].to_i << 8) + (header[2].to_i << 16) @seq = header[3] - rescue IO::EOFError - raise DB::ConnectionLost.new(@connection) + rescue e : IO::EOFError + raise DB::ConnectionLost.new(@connection, cause: e) end end @@ -26,8 +26,8 @@ class MySql::ReadPacket < IO read_bytes = @io.read_fully(slice) @remaining -= read_bytes read_bytes - rescue IO::EOFError - raise DB::ConnectionLost.new(@connection) + rescue e : IO::EOFError + raise DB::ConnectionLost.new(@connection, cause: e) end {% if compare_versions(Crystal::VERSION, "0.35.0") == 0 %} diff --git a/src/mysql/write_packet.cr b/src/mysql/write_packet.cr index e858452..b6365b2 100644 --- a/src/mysql/write_packet.cr +++ b/src/mysql/write_packet.cr @@ -6,19 +6,11 @@ class MySql::WritePacket < IO raise "not implemented" end - {% if compare_versions(Crystal::VERSION, "0.35.0") == 0 %} - def write(slice) : Int64 - @io.write(slice) - rescue IO::EOFError - raise DB::ConnectionLost.new(@connection) - end - {% else %} - def write(slice) : Nil - @io.write(slice) - rescue IO::EOFError - raise DB::ConnectionLost.new(@connection) - end - {% end %} + def write(slice) : Nil + @io.write(slice) + rescue e : IO::EOFError + raise DB::ConnectionLost.new(@connection, cause: e) + end def write_lenenc_string(s : String) write_lenenc_int(s.bytesize) @@ -44,8 +36,8 @@ class MySql::WritePacket < IO def write_string(s : String) @io << s - rescue IO::EOFError - raise DB::ConnectionLost.new(@connection) + rescue e : IO::EOFError + raise DB::ConnectionLost.new(@connection, cause: e) end def write_blob(v : Bytes)