Skip to content

Commit

Permalink
go back to what what it was before
Browse files Browse the repository at this point in the history
  • Loading branch information
ollym committed Jul 3, 2024
1 parent c8221c9 commit e957b5b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions app/models/solid_cache/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,12 @@ def get_sql
end

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))
if connection.prepared_statements?
@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("?, ?", "?")
end
end

def build_sql(relation)
Expand All @@ -127,12 +131,12 @@ def build_sql(relation)

def select_all_no_query_cache(query, values)
uncached do
binds = Array(values).map do |value|
ActiveRecord::Relation::QueryAttribute.new("key_hash", value, SolidCache::Entry.type_for_attribute("key_hash"))
if connection.prepared_statements?
result = connection.select_all(sanitize_sql(query), "#{name} Load", Array(values), preparable: true)
else
result = connection.select_all(sanitize_sql([ query, Array(values) ]), "#{name} Load", Array(values), preparable: false)
end

result = connection.select_all(sanitize_sql(query), "#{name} Load", binds, preparable: true)

result.cast_values(SolidCache::Entry.attribute_types)
end
end
Expand Down

0 comments on commit e957b5b

Please sign in to comment.