Skip to content

Commit

Permalink
closes #869
Browse files Browse the repository at this point in the history
  • Loading branch information
proceps committed Jun 23, 2020
1 parent 3807265 commit ca3210f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/queries/otu/autocomplete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def base_queries
autocomplete_named,
autocomplete_via_taxon_name_autocomplete,
autocomplete_identifier_cached_like,
autocomplete_common_name_exact,
autocomplete_common_name_like
]

queries.compact!
Expand Down
10 changes: 10 additions & 0 deletions lib/queries/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,5 +342,15 @@ def autocomplete_named
base_query.where(named.to_sql).limit(5)
end

def autocomplete_common_name_exact
return nil if no_terms?
query_base.joins(:common_names).where(common_names: {name: query_string}).limit(1)
end

def autocomplete_common_name_like
return nil if no_terms?
query_base.joins(:common_names).where('"common_names"."name" ILIKE ' + "'#{wildcard_pieces}'").limit(5)

This comment has been minimized.

Copy link
@mjy

mjy Jun 23, 2020

Member

Need to change to use a AREL matches() clause for security

end

end
end

0 comments on commit ca3210f

Please sign in to comment.