From a9f1105fe51c28b641b61f9f9a68605ee57375fe Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Fri, 15 May 2020 19:17:31 -0300 Subject: [PATCH 1/2] Update IO#write return type annotation on Crystal 0.35.0 --- src/mysql/read_packet.cr | 12 +++++++++--- src/mysql/write_packet.cr | 18 +++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/mysql/read_packet.cr b/src/mysql/read_packet.cr index 2672ade..23a2a17 100644 --- a/src/mysql/read_packet.cr +++ b/src/mysql/read_packet.cr @@ -30,9 +30,15 @@ class MySql::ReadPacket < IO raise DB::ConnectionLost.new(@connection) end - def write(slice) : Nil - raise "not implemented" - end + {% if compare_versions(Crystal::VERSION, "0.35.0-0") >= 0 %} + def write(slice) : UInt64 + raise "not implemented" + end + {% else %} + def write(slice) : Nil + raise "not implemented" + end + {% end %} def read_byte! read_byte || raise "Unexpected EOF" diff --git a/src/mysql/write_packet.cr b/src/mysql/write_packet.cr index fe8bf5b..5815792 100644 --- a/src/mysql/write_packet.cr +++ b/src/mysql/write_packet.cr @@ -6,11 +6,19 @@ class MySql::WritePacket < IO raise "not implemented" end - def write(slice) : Nil - @io.write(slice) - rescue IO::EOFError - raise DB::ConnectionLost.new(@connection) - end + {% if compare_versions(Crystal::VERSION, "0.35.0-0") >= 0 %} + def write(slice) : UInt64 + @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_lenenc_string(s : String) write_lenenc_int(s.bytesize) From 7aaa126227d88e6474e55a0219fe6640288bef2a Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Fri, 29 May 2020 14:36:57 -0300 Subject: [PATCH 2/2] Update IO#write return type annotation on Crystal 0.35.0 --- src/mysql/read_packet.cr | 2 +- src/mysql/write_packet.cr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mysql/read_packet.cr b/src/mysql/read_packet.cr index 23a2a17..c5c0155 100644 --- a/src/mysql/read_packet.cr +++ b/src/mysql/read_packet.cr @@ -31,7 +31,7 @@ class MySql::ReadPacket < IO end {% if compare_versions(Crystal::VERSION, "0.35.0-0") >= 0 %} - def write(slice) : UInt64 + def write(slice) : Int64 raise "not implemented" end {% else %} diff --git a/src/mysql/write_packet.cr b/src/mysql/write_packet.cr index 5815792..9f300d1 100644 --- a/src/mysql/write_packet.cr +++ b/src/mysql/write_packet.cr @@ -7,7 +7,7 @@ class MySql::WritePacket < IO end {% if compare_versions(Crystal::VERSION, "0.35.0-0") >= 0 %} - def write(slice) : UInt64 + def write(slice) : Int64 @io.write(slice) rescue IO::EOFError raise DB::ConnectionLost.new(@connection)