Skip to content

Commit 55d8a32

Browse files
committed
Construct query directly as a string
1 parent 87e9778 commit 55d8a32

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

app/models/solid_cache/entry.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,9 @@ def upsert_unique_by
8585
end
8686

8787
def select_sql(keys)
88-
@get_sql ||= {}
89-
@get_sql[keys.count] ||= \
90-
where(key_hash: [ "1111", "2222" ])
91-
.select(:key, :value)
92-
.to_sql
93-
.gsub("1111, 2222", (["?"] * keys.count).join(", "))
88+
@select_sql ||= {}
89+
@select_sql[keys.count] ||= \
90+
"SELECT key, value FROM #{table_name} WHERE key_hash IN (#{Array.new(keys.count, "?").join(", ")})"
9491
end
9592

9693
def key_hash_for(key)

0 commit comments

Comments
 (0)