mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
refactor and add specs for query without blocks
This commit is contained in:
parent
3464a1d1cc
commit
d4b2046a65
2 changed files with 15 additions and 23 deletions
|
@ -167,6 +167,13 @@ describe DB do
|
||||||
db.query("query", Slice(UInt8).new(4)) { }
|
db.query("query", Slice(UInt8).new(4)) { }
|
||||||
db.query("query", 1, "string", FooValue.new(5)) { }
|
db.query("query", 1, "string", FooValue.new(5)) { }
|
||||||
db.query "query", [1, "string", FooValue.new(5)] { }
|
db.query "query", [1, "string", FooValue.new(5)] { }
|
||||||
|
|
||||||
|
db.query("query").close
|
||||||
|
db.query("query", 1).close
|
||||||
|
db.query("query", 1, "string").close
|
||||||
|
db.query("query", Slice(UInt8).new(4)).close
|
||||||
|
db.query("query", 1, "string", FooValue.new(5)).close
|
||||||
|
db.query("query", [1, "string", FooValue.new(5)]).close
|
||||||
end
|
end
|
||||||
|
|
||||||
DB.open("bar://host") do |db|
|
DB.open("bar://host") do |db|
|
||||||
|
@ -177,6 +184,13 @@ describe DB do
|
||||||
db.query("query", Slice(UInt8).new(4)) { }
|
db.query("query", Slice(UInt8).new(4)) { }
|
||||||
db.query("query", 1, "string", BarValue.new(5)) { }
|
db.query("query", 1, "string", BarValue.new(5)) { }
|
||||||
db.query "query", [1, "string", FooValue.new(5)] { }
|
db.query "query", [1, "string", FooValue.new(5)] { }
|
||||||
|
|
||||||
|
db.query("query").close
|
||||||
|
db.query("query", 1).close
|
||||||
|
db.query("query", 1, "string").close
|
||||||
|
db.query("query", Slice(UInt8).new(4)).close
|
||||||
|
db.query("query", 1, "string", BarValue.new(5)).close
|
||||||
|
db.query("query", [1, "string", BarValue.new(5)]).close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -75,33 +75,11 @@ module DB
|
||||||
perform_query Slice(Any).new(0)
|
perform_query Slice(Any).new(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
# See `QueryMethods#query`
|
|
||||||
def query
|
|
||||||
perform_query(Slice(Any).new(0)).tap do |rs|
|
|
||||||
begin
|
|
||||||
yield rs
|
|
||||||
ensure
|
|
||||||
rs.close
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# See `QueryMethods#query`
|
# See `QueryMethods#query`
|
||||||
def query(args : Array)
|
def query(args : Array)
|
||||||
perform_query args
|
perform_query args
|
||||||
end
|
end
|
||||||
|
|
||||||
# See `QueryMethods#query`
|
|
||||||
def query(args : Array)
|
|
||||||
perform_query(args).tap do |rs|
|
|
||||||
begin
|
|
||||||
yield rs
|
|
||||||
ensure
|
|
||||||
rs.close
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# See `QueryMethods#query`
|
# See `QueryMethods#query`
|
||||||
def query(*args)
|
def query(*args)
|
||||||
perform_query args
|
perform_query args
|
||||||
|
@ -109,7 +87,7 @@ module DB
|
||||||
|
|
||||||
# See `QueryMethods#query`
|
# See `QueryMethods#query`
|
||||||
def query(*args)
|
def query(*args)
|
||||||
perform_query(args).tap do |rs|
|
query(*args).tap do |rs|
|
||||||
begin
|
begin
|
||||||
yield rs
|
yield rs
|
||||||
ensure
|
ensure
|
||||||
|
|
Loading…
Reference in a new issue