Skip to content

Commit

Permalink
Remove no need binds.empty? checking
Browse files Browse the repository at this point in the history
`#exec_stmt` is private method and only called in `#exec_query`. it
means `binds` is provided always. No need `binds.empty?` checking.
  • Loading branch information
kamipo committed Oct 23, 2015
1 parent b9d1e10 commit be0f317
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -383,7 +383,7 @@ def exec_stmt(sql, name, binds, cache_stmt: false)
type_casted_binds = binds.map { |attr| type_cast(attr.value_for_database) }

log(sql, name, binds) do
if binds.empty? || !cache_stmt
if !cache_stmt
stmt = @connection.prepare(sql)
else
cache = @statements[sql] ||= {
Expand All @@ -399,7 +399,7 @@ def exec_stmt(sql, name, binds, cache_stmt: false)
# place when an error occurs. To support older MySQL versions, we
# need to close the statement and delete the statement from the
# cache.
if binds.empty? || !cache_stmt
if !cache_stmt
stmt.close
else
@statements.delete sql
Expand All @@ -417,7 +417,7 @@ def exec_stmt(sql, name, binds, cache_stmt: false)
affected_rows = stmt.affected_rows

stmt.free_result
stmt.close if binds.empty?
stmt.close if !cache_stmt

[result_set, affected_rows]
end
Expand Down

0 comments on commit be0f317

Please sign in to comment.