File tree Expand file tree Collapse file tree
lib/active_storage/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ def download(key, &block)
5050
5151 def download_chunk ( key , range )
5252 instrument :download_chunk , key : key , range : range do
53+ # NOTE: from/size are derived from Range#begin and Range#size (always integers),
54+ # so string interpolation into SQL is safe here.
5355 from = range . begin + 1
5456 size = range . size
5557 args = adapter_sqlserver? || adapter_sqlite? ? "data, #{ from } , #{ size } " : "data FROM #{ from } FOR #{ size } "
@@ -81,7 +83,7 @@ def delete_prefixed(prefix)
8183 def exist? ( key )
8284 instrument :exist , key : key do |payload |
8385 comment = "DBService#exist?"
84- result = ::ActiveStorageDB ::File . annotate ( comment ) . where ( ref : key ) . exists?
86+ result = ::ActiveStorageDB ::File . annotate ( comment ) . exists? ( ref : key )
8587 payload [ :exist ] = result
8688 result
8789 end
@@ -172,7 +174,7 @@ def retrieve_file(key)
172174 def object_for ( key , fields : nil )
173175 comment = "DBService#object_for"
174176 scope = ::ActiveStorageDB ::File . annotate ( comment )
175- scope = scope . select ( * fields ) if fields
177+ scope = scope . select ( fields ) if fields
176178 scope . find_by ( ref : key )
177179 end
178180
You can’t perform that action at this time.
0 commit comments