Skip to content

Commit

Permalink
Update to crystal-db ~> 0.13 (#112)
Browse files Browse the repository at this point in the history
* Update to crystal-db ~> 0.13
* Update to crystal-db ~> 0.13.1
  • Loading branch information
bcardiff authored Dec 21, 2023
1 parent 0f37981 commit 6445cf7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
8 changes: 4 additions & 4 deletions src/mysql/read_packet.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 %}
Expand Down
22 changes: 7 additions & 15 deletions src/mysql/write_packet.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 6445cf7

Please sign in to comment.