Skip to content

Commit

Permalink
fix unprepared statements
Browse files Browse the repository at this point in the history
  • Loading branch information
ollym committed Jul 3, 2024
1 parent f13a81b commit f06bb0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/solid_cache/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ def get_all_sql(key_hashes)
@get_all_sql_binds ||= {}
@get_all_sql_binds[key_hashes.count] ||= build_sql(where(key_hash: key_hashes).select(:key, :value))
else
@get_all_sql_no_binds ||= build_sql(where(key_hash: [ 1, 2 ]).select(:key, :value)).gsub("?, ?", "?")
if keys.size == 1
@get_all_sql_no_binds_one_key ||= build_sql(where(key_hash: 1).select(:key, :value))
else
@get_all_sql_no_binds_many_keys ||= build_sql(where(key_hash: [ 1, 2 ]).select(:key, :value)).gsub("?, ?", "?")
end
end
end

Expand Down
1 change: 1 addition & 0 deletions test/unit/behaviors/cache_store_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def test_read_multi
@cache.write(other_key, "baz")
@cache.write(SecureRandom.alphanumeric, "biz")
assert_equal({ key => "bar", other_key => "baz" }, @cache.read_multi(key, other_key))
assert_equal({ key => "bar" }, @cache.read_multi(key))
end

def test_read_multi_empty_list
Expand Down

0 comments on commit f06bb0b

Please sign in to comment.