Skip to content

Commit

Permalink
Cast to CHAR rather than TEXT in ModelSearchFilter.
Browse files Browse the repository at this point in the history
  • Loading branch information
gregschmit committed May 7, 2021
1 parent 173077b commit 85c7bd6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rest_framework/filters.rb
Expand Up @@ -84,7 +84,7 @@ def get_filtered_data(data)
# Ensure we use array conditions to prevent SQL injection.
unless search.blank?
return data.where(fields.map { |f|
"CAST(#{f} AS text) #{@controller.send(:search_ilike) ? "ILIKE" : "LIKE"} ?"
"CAST(#{f} AS CHAR) #{@controller.send(:search_ilike) ? "ILIKE" : "LIKE"} ?"
}.join(' OR '), *(["%#{search}%"] * fields.length))
end

Expand Down

0 comments on commit 85c7bd6

Please sign in to comment.