add case insentive search

pull/1558/head
Ayrat Badykov 6 years ago
parent 089bc39fe4
commit fa9a281499
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 7
      apps/block_scout_web/test/block_scout_web/chain_test.exs
  2. 2
      apps/explorer/lib/explorer/chain.ex

@ -51,6 +51,13 @@ defmodule BlockScoutWeb.ChainTest do
assert {:ok, %Address{}} = name |> Chain.from_param()
end
test "finds a token by its name even if lowercase name was passed" do
name = "ayr"
insert(:token, symbol: String.upcase(name))
assert {:ok, %Address{}} = name |> Chain.from_param()
end
test "returns {:error, :not_found} when garbage is passed in" do
assert {:error, :not_found} = Chain.from_param("any ol' thing")
end

@ -640,7 +640,7 @@ defmodule Explorer.Chain do
def token_contract_address_from_token_name(name) when is_binary(name) do
query =
from(token in Token,
where: token.symbol == ^name,
where: ilike(token.symbol, ^name),
select: token.contract_address_hash
)

Loading…
Cancel
Save