Skip to content

Commit fbac40f

Browse files
undo
1 parent 9dc36d3 commit fbac40f

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

lib/ecto/query/planner.ex

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,11 +2563,7 @@ defmodule Ecto.Query.Planner do
25632563
defp field_source({source, schema, _}, field) when is_binary(source) and schema != nil do
25642564
# If the field is not found we return the field itself
25652565
# which will be checked and raise later.
2566-
2567-
case schema.__schema__(:field_source, field) do
2568-
nil -> if is_binary(field), do: String.to_existing_atom(field), else: field
2569-
field_source -> field_source
2570-
end
2566+
schema.__schema__(:field_source, field) || field
25712567
end
25722568

25732569
defp field_source(_, field) do

lib/ecto/schema.ex

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -598,16 +598,11 @@ defmodule Ecto.Schema do
598598
end
599599
end
600600

601-
for clauses <-
602-
Ecto.Schema.__schema__(fields, field_sources, assocs, embeds, virtual_fields, read_only),
603-
clause <- clauses do
604-
case clause do
605-
{args, body} ->
606-
def __schema__(unquote_splicing(args)), do: unquote(body)
607-
608-
{args, when_expr, body} ->
609-
def __schema__(unquote_splicing(args)) when(unquote(when_expr)), do: unquote(body)
610-
end
601+
def __schema__(:source), do: unquote(source)
602+
def __schema__(:prefix), do: unquote(Macro.escape(prefix))
603+
604+
for clauses <- bags_of_clauses, {args, body} <- clauses do
605+
def __schema__(unquote_splicing(args)), do: unquote(body)
611606
end
612607

613608
:ok

0 commit comments

Comments
 (0)