mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Updated to Crystal 0.17.4
This commit is contained in:
parent
6ee8c90ba7
commit
f834b0f8a6
4 changed files with 18 additions and 14 deletions
|
@ -37,7 +37,7 @@ class DummyDriver < DB::Driver
|
||||||
class DummyStatement < DB::Statement
|
class DummyStatement < DB::Statement
|
||||||
property params
|
property params
|
||||||
|
|
||||||
def initialize(connection, @query)
|
def initialize(connection, @query : String)
|
||||||
@params = Hash(Int32 | String, DB::Any).new
|
@params = Hash(Int32 | String, DB::Any).new
|
||||||
super(connection)
|
super(connection)
|
||||||
end
|
end
|
||||||
|
@ -49,7 +49,7 @@ class DummyDriver < DB::Driver
|
||||||
|
|
||||||
protected def perform_exec(args : Slice(DB::Any))
|
protected def perform_exec(args : Slice(DB::Any))
|
||||||
set_params args
|
set_params args
|
||||||
DB::ExecResult.new 0, 0
|
DB::ExecResult.new 0, 0_i64
|
||||||
end
|
end
|
||||||
|
|
||||||
private def set_params(args)
|
private def set_params(args)
|
||||||
|
@ -66,10 +66,15 @@ class DummyDriver < DB::Driver
|
||||||
|
|
||||||
class DummyResultSet < DB::ResultSet
|
class DummyResultSet < DB::ResultSet
|
||||||
@@next_column_type = String
|
@@next_column_type = String
|
||||||
|
@top_values : Array(Array(String))
|
||||||
|
@values : Array(String)?
|
||||||
|
|
||||||
|
@@last_result_set : self?
|
||||||
|
@@next_column_type : Nil.class | String.class | Int32.class | Int64.class | Float32.class | Float64.class | Slice(UInt8).class
|
||||||
|
|
||||||
def initialize(statement, query)
|
def initialize(statement, query)
|
||||||
super(statement)
|
super(statement)
|
||||||
@iterator = query.split.map { |r| r.split(',') }.to_a.each
|
@top_values = query.split.map { |r| r.split(',') }.to_a
|
||||||
|
|
||||||
@@last_result_set = self
|
@@last_result_set = self
|
||||||
end
|
end
|
||||||
|
@ -83,11 +88,8 @@ class DummyDriver < DB::Driver
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_next
|
def move_next
|
||||||
@iterator.next.tap do |n|
|
@values = @top_values.shift?
|
||||||
return false if n.is_a?(Iterator::Stop)
|
!!@values
|
||||||
@values = n.each
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def column_count
|
def column_count
|
||||||
|
@ -107,8 +109,8 @@ class DummyDriver < DB::Driver
|
||||||
end
|
end
|
||||||
|
|
||||||
private def read? : DB::Any?
|
private def read? : DB::Any?
|
||||||
n = @values.not_nil!.next
|
n = @values.not_nil!.shift?
|
||||||
raise "end of row" if n.is_a?(Iterator::Stop)
|
raise "end of row" if n.is_a?(Nil)
|
||||||
return nil if n == "NULL"
|
return nil if n == "NULL"
|
||||||
|
|
||||||
if n == "?"
|
if n == "?"
|
||||||
|
@ -159,7 +161,7 @@ DB.register_driver "dummy", DummyDriver
|
||||||
class Witness
|
class Witness
|
||||||
getter count
|
getter count
|
||||||
|
|
||||||
def initialize(@count)
|
def initialize(@count = 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check
|
def check
|
||||||
|
|
|
@ -76,7 +76,7 @@ module DB
|
||||||
alias Any = Nil | String | Int32 | Int64 | Float32 | Float64 | Slice(UInt8)
|
alias Any = Nil | String | Int32 | Int64 | Float32 | Float64 | Slice(UInt8)
|
||||||
|
|
||||||
# Result of a `#exec` statement.
|
# Result of a `#exec` statement.
|
||||||
record ExecResult, rows_affected, last_insert_id
|
record ExecResult, rows_affected : Int32, last_insert_id : Int64
|
||||||
|
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
def self.driver_class(driver_name) : Driver.class
|
def self.driver_class(driver_name) : Driver.class
|
||||||
|
|
|
@ -13,8 +13,10 @@ module DB
|
||||||
# Returns the uri with the connection settings to the database
|
# Returns the uri with the connection settings to the database
|
||||||
getter uri
|
getter uri
|
||||||
|
|
||||||
|
@connection : Connection?
|
||||||
|
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
def initialize(@driver, @uri)
|
def initialize(@driver : Driver, @uri : URI)
|
||||||
@in_pool = true
|
@in_pool = true
|
||||||
@connection = @driver.build_connection(self)
|
@connection = @driver.build_connection(self)
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@ module DB
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
getter connection
|
getter connection
|
||||||
|
|
||||||
def initialize(@connection)
|
def initialize(@connection : Connection)
|
||||||
end
|
end
|
||||||
|
|
||||||
protected def do_close
|
protected def do_close
|
||||||
|
|
Loading…
Reference in a new issue