Skip to content

Commit

Permalink
add test for ecto builder with unicode value #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Davide Colombo committed Nov 23, 2022
1 parent 3451514 commit 31bfb54
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 0 additions & 2 deletions lib/query_builders/sql_query_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ defmodule FIQLEx.QueryBuilders.SQLQueryBuilder do

@impl true
def build(ast, {query, opts}) do
query = :binary.bin_to_list(query) |> to_string

select =
case Keyword.get(opts, :select, :all) do
:all ->
Expand Down
17 changes: 17 additions & 0 deletions test/ecto_query_builder_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ defmodule EctoQueryBuilderTest do
assert inspect(expected) == inspect(result)
end

test "single fiql filter with an unicode value" do
{:ok, result} =
FIQLEx.build_query(FIQLEx.parse!("firstname==さよなら"), EctoQueryBuilder,
schema: UserSchema,
select: :from_selectors
)

expected =
from(u0 in FIQLEx.Test.Support.User,
where: u0.firstname == ^"'さよなら'",
order_by: [],
select: [:firstname]
)

assert inspect(expected) == inspect(result)
end

test "single fiql filter with select all fields" do
{:ok, result} =
FIQLEx.build_query(FIQLEx.parse!("firstname==John"), EctoQueryBuilder,
Expand Down

0 comments on commit 31bfb54

Please sign in to comment.