Skip to content

Commit

Permalink
Upgrade support to Crystal 0.35 (#90)
Browse files Browse the repository at this point in the history
* Update IO#write return type annotation on Crystal 0.35.0
  • Loading branch information
Brian J. Cardiff committed Jun 9, 2020
1 parent a8c29eb commit 99cc05d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
12 changes: 9 additions & 3 deletions src/mysql/read_packet.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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) : Int64
raise "not implemented"
end
{% else %}
def write(slice) : Nil
raise "not implemented"
end
{% end %}

def read_byte!
read_byte || raise "Unexpected EOF"
Expand Down
18 changes: 13 additions & 5 deletions src/mysql/write_packet.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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) : 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_lenenc_string(s : String)
write_lenenc_int(s.bytesize)
Expand Down

0 comments on commit 99cc05d

Please sign in to comment.