Skip to content

Commit

Permalink
Update crystal-db ~> 0.10.0 and Crystal 0.35.0 for logging support (#95)
Browse files Browse the repository at this point in the history
* Update crystal-db for logging support

* Update crystal-db ~> 0.10.0 and Crystal 0.35.0
  • Loading branch information
Brian J. Cardiff authored Sep 30, 2020
1 parent abffe3a commit f5eddfe
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
4 changes: 2 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ version: 0.11.2
dependencies:
db:
github: crystal-lang/crystal-db
version: ~> 0.9.0
version: ~> 0.10.0

authors:
- Juan Wajnerman <[email protected]>
- Brian J. Cardiff <[email protected]>

crystal: 0.30.0
crystal: 0.35.0

license: MIT
8 changes: 1 addition & 7 deletions src/mysql/connection.cr
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
require "socket"

class MySql::Connection < DB::Connection
{% if compare_versions(Crystal::VERSION, "0.34.0-0") > 0 %}
alias IOErrorOrErrno = IO::Error
{% else %}
alias IOErrorOrErrno = Errno
{% end %}

def initialize(context : DB::ConnectionContext)
super(context)
@socket = uninitialized TCPSocket
Expand Down Expand Up @@ -34,7 +28,7 @@ class MySql::Connection < DB::Connection
read_ok_or_err do |packet, status|
raise "packet #{status} not implemented"
end
rescue IOErrorOrErrno
rescue IO::Error
raise DB::ConnectionRefused.new
end
end
Expand Down
6 changes: 3 additions & 3 deletions src/mysql/statement.cr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class MySql::Statement < DB::Statement
@statement_id : Int32

def initialize(connection, @sql : String)
super(connection)
def initialize(connection, command : String)
super(connection, command)
@statement_id = 0
params = @params = [] of ColumnSpec
columns = @columns = [] of ColumnSpec
Expand All @@ -12,7 +12,7 @@ class MySql::Statement < DB::Statement
# http://dev.mysql.com/doc/internals/en/com-stmt-prepare.html#packet-COM_STMT_PREPARE
conn.write_packet do |packet|
packet.write_byte 0x16u8
packet << @sql
packet << command
end

# http://dev.mysql.com/doc/internals/en/com-stmt-prepare-response.html
Expand Down
6 changes: 3 additions & 3 deletions src/mysql/unprepared_statement.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class MySql::UnpreparedStatement < DB::Statement
def initialize(connection, @sql : String)
super(connection)
def initialize(connection, command : String)
super(connection, command)
end

protected def conn
Expand All @@ -21,7 +21,7 @@ class MySql::UnpreparedStatement < DB::Statement
conn = self.conn
conn.write_packet do |packet|
packet.write_byte 0x03u8
packet << @sql
packet << command
# TODO to support args an interpolation needs to be done
end

Expand Down

0 comments on commit f5eddfe

Please sign in to comment.