Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
crbelaus committed Mar 19, 2022
1 parent 6de358c commit 2d37bee
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
import_deps: [:ecto]
import_deps: [:ecto],
locals_without_parens: [translations: 3, translations: 4]
]
4 changes: 3 additions & 1 deletion lib/trans.ex
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,9 @@ defmodule Trans do
unless Enum.member?(Map.keys(module.__struct__()), container) do
raise ArgumentError,
message:
"The field #{container} used as the translation container is not defined in #{inspect module} struct"
"The field #{container} used as the translation container is not defined in #{
inspect(module)
} struct"
end
end

Expand Down
3 changes: 1 addition & 2 deletions lib/trans/query_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ if Code.ensure_loaded?(Ecto.Adapters.SQL) do
defp translate_field(module, schema, nil, default_locale, locales) do
table_alias = table_alias(schema)

funcall =
"translate_field(#{table_alias}, ?::varchar, ?::varchar, ?::varchar[])"
funcall = "translate_field(#{table_alias}, ?::varchar, ?::varchar, ?::varchar[])"

quote do
fragment(
Expand Down
28 changes: 15 additions & 13 deletions test/trans_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,21 @@ defmodule TransTest do
assert :translations in Trans.Magazine.__schema__(:fields)

assert {
:parameterized, Ecto.Embedded,
%Ecto.Embedded{
cardinality: :one,
field: :translations,
on_cast: nil,
on_replace: :update,
ordered: true,
owner: Trans.Magazine,
related: Trans.Magazine.Translations,
unique: true}} =
Trans.Magazine.__schema__(:type, :translations)
:parameterized,
Ecto.Embedded,
%Ecto.Embedded{
cardinality: :one,
field: :translations,
on_cast: nil,
on_replace: :update,
ordered: true,
owner: Trans.Magazine,
related: Trans.Magazine.Translations,
unique: true
}
} = Trans.Magazine.__schema__(:type, :translations)

assert [:es, :it, :de] = Trans.Magazine.Translations.__schema__(:fields)
assert [:title, :body] = Trans.Magazine.Translations.Fields.__schema__(:fields)
assert [:es, :it, :de] = Trans.Magazine.Translations.__schema__(:fields)
assert [:title, :body] = Trans.Magazine.Translations.Fields.__schema__(:fields)
end
end

0 comments on commit 2d37bee

Please sign in to comment.