mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Fix offending spec
This commit is contained in:
parent
ae728b1695
commit
20e155846f
2 changed files with 20 additions and 4 deletions
|
@ -50,14 +50,16 @@ module DB
|
||||||
@options.prepared_statements
|
@options.prepared_statements
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def prepared_statements_cache? : Bool
|
||||||
|
@options.prepared_statements_cache
|
||||||
|
end
|
||||||
|
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
def fetch_or_build_prepared_statement(query) : Statement
|
def fetch_or_build_prepared_statement(query) : Statement
|
||||||
if @options.prepared_statements_cache
|
if @options.prepared_statements_cache
|
||||||
@statements_cache.fetch(query) { build_prepared_statement(query) }
|
@statements_cache.fetch(query) { build_prepared_statement(query) }
|
||||||
else
|
else
|
||||||
stmt = build_prepared_statement(query)
|
build_prepared_statement(query)
|
||||||
stmt.auto_close = true
|
|
||||||
stmt
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,27 @@ module DB
|
||||||
# be prepared or not.
|
# be prepared or not.
|
||||||
abstract def prepared_statements? : Bool
|
abstract def prepared_statements? : Bool
|
||||||
|
|
||||||
|
abstract def prepared_statements_cache? : Bool
|
||||||
|
|
||||||
abstract def fetch_or_build_prepared_statement(query) : Stmt
|
abstract def fetch_or_build_prepared_statement(query) : Stmt
|
||||||
|
|
||||||
abstract def build_unprepared_statement(query) : Stmt
|
abstract def build_unprepared_statement(query) : Stmt
|
||||||
|
|
||||||
def build(query) : Stmt
|
def build(query) : Stmt
|
||||||
if prepared_statements?
|
if prepared_statements?
|
||||||
fetch_or_build_prepared_statement(query)
|
stmt = fetch_or_build_prepared_statement(query)
|
||||||
|
|
||||||
|
# #build is a :nodoc: method used on QueryMethods where
|
||||||
|
# the statements are not exposed. As such if the cache
|
||||||
|
# is disabled we should auto_close the statement.
|
||||||
|
# When the statements are build explicitly the #prepared
|
||||||
|
# and #unprepared methods are used. In that case the
|
||||||
|
# statement is closed by the user explicitly also.
|
||||||
|
if !prepared_statements_cache?
|
||||||
|
stmt.auto_close = true if stmt.responds_to?(:auto_close=)
|
||||||
|
end
|
||||||
|
|
||||||
|
stmt
|
||||||
else
|
else
|
||||||
build_unprepared_statement(query)
|
build_unprepared_statement(query)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue