Simplify setting tsvector values
We make the code easier to read and at the same time we remove a SQL
injection false positive regarding the use of `WHERE id = #{id}`.
We still get a warning about SQL injection regarding the `tsv =` part.
It's a false positive, since the value of that parameter does not
depend on user input.
This commit is contained in:
@@ -6,8 +6,7 @@ module SearchCache
|
|||||||
end
|
end
|
||||||
|
|
||||||
def calculate_tsvector
|
def calculate_tsvector
|
||||||
ActiveRecord::Base.connection.execute("
|
self.class.where(id: id).update_all("tsv = (#{searchable_values_sql})")
|
||||||
UPDATE #{self.class.table_name} SET tsv = (#{searchable_values_sql}) WHERE id = #{id}")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
Reference in New Issue
Block a user