mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Add Fiber.yield to dummy driver to mimic real drivers IO
This commit is contained in:
parent
ce95cd2257
commit
48adceb764
1 changed files with 4 additions and 0 deletions
|
@ -19,6 +19,7 @@ class DummyDriver < DB::Driver
|
||||||
class DummyConnection < DB::Connection
|
class DummyConnection < DB::Connection
|
||||||
def initialize(options : DB::Connection::Options)
|
def initialize(options : DB::Connection::Options)
|
||||||
super(options)
|
super(options)
|
||||||
|
Fiber.yield
|
||||||
@connected = true
|
@connected = true
|
||||||
@@connections ||= [] of DummyConnection
|
@@connections ||= [] of DummyConnection
|
||||||
@@connections.not_nil! << self
|
@@connections.not_nil! << self
|
||||||
|
@ -113,6 +114,7 @@ class DummyDriver < DB::Driver
|
||||||
end
|
end
|
||||||
|
|
||||||
protected def perform_query(args : Enumerable) : DB::ResultSet
|
protected def perform_query(args : Enumerable) : DB::ResultSet
|
||||||
|
Fiber.yield
|
||||||
@connection.as(DummyConnection).check
|
@connection.as(DummyConnection).check
|
||||||
set_params args
|
set_params args
|
||||||
DummyResultSet.new self, command
|
DummyResultSet.new self, command
|
||||||
|
@ -161,6 +163,8 @@ class DummyDriver < DB::Driver
|
||||||
|
|
||||||
def initialize(statement, command)
|
def initialize(statement, command)
|
||||||
super(statement)
|
super(statement)
|
||||||
|
Fiber.yield
|
||||||
|
|
||||||
@top_values = command.split.map { |r| r.split(',') }.to_a
|
@top_values = command.split.map { |r| r.split(',') }.to_a
|
||||||
@column_count = @top_values.size > 0 ? @top_values[0].size : 2
|
@column_count = @top_values.size > 0 ? @top_values[0].size : 2
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue