app/models/concerns/agilibox/search.rb in agilibox-1.9.17 vs app/models/concerns/agilibox/search.rb in agilibox-1.9.18
- old
+ new
@@ -10,9 +10,11 @@
def search(q, *fields)
words = q.to_s.parameterize.split("-")
fields = default_search_fields if fields.empty?
+ return all if words.empty?
+
sql_query = words.map.with_index { |_word, index|
fields.map { |field|
"(UNACCENT(CAST(#{field} AS TEXT)) ILIKE :w#{index})"
}.join(" OR ")
}.map { |e| "(#{e})" }.join(" AND ")