Skip to content

Commit d23d6eb

Browse files
committed
add in reference column type
1 parent 3738456 commit d23d6eb

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

lib/ecto/adapters/postgres/connection.ex

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,7 @@ if Code.ensure_loaded?(Postgrex) do
15481548
defp column_change(table, {:modify, name, %Reference{} = ref, opts}) do
15491549
reference_column_type = reference_column_type(ref.type, opts)
15501550
from_column_type = extract_column_type(opts[:from])
1551+
from_opts = extract_opts(opts[:from])
15511552

15521553
drop_reference_expr = drop_reference_expr(opts[:from], table, name)
15531554
prefix_with_comma = (drop_reference_expr != [] && ", ") || ""
@@ -1558,7 +1559,7 @@ if Code.ensure_loaded?(Postgrex) do
15581559
modify_default(name, ref.type, opts)
15591560
]
15601561

1561-
if reference_column_type == reference_column_type(from_column_type, opts) do
1562+
if reference_column_type == reference_column_type(from_column_type, from_opts) do
15621563
[
15631564
drop_reference_expr,
15641565
prefix_with_comma,
@@ -1580,7 +1581,7 @@ if Code.ensure_loaded?(Postgrex) do
15801581
defp column_change(table, {:modify, name, type, opts}) do
15811582
column_type = column_type(type, opts)
15821583
from_column_type = extract_column_type(opts[:from])
1583-
from_opts = extract_opts(opts)
1584+
from_opts = extract_opts(opts[:from])
15841585

15851586
drop_reference_expr = drop_reference_expr(opts[:from], table, name)
15861587
any_drop_ref? = drop_reference_expr != []
@@ -1845,14 +1846,8 @@ if Code.ensure_loaded?(Postgrex) do
18451846
[type, generated_expr(generated)]
18461847
end
18471848

1848-
defp extract_opts(opts) do
1849-
with {:ok, from} <- Keyword.fetch(opts, :from),
1850-
{_type, from_opts} <- from do
1851-
from_opts
1852-
else
1853-
_ -> opts
1854-
end
1855-
end
1849+
defp extract_opts({_type, opts}), do: opts
1850+
defp extract_opts(_opts), do: []
18561851

18571852
defp extract_column_type({type, _}) when is_atom(type), do: type
18581853
defp extract_column_type(type) when is_atom(type), do: type

0 commit comments

Comments
 (0)