Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/redshift_ecto/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ if Code.ensure_loaded?(Postgrex) do
], exprs}
end

defp from(%{from: from} = query, sources) do
defp from(%{from: %Ecto.Query.FromExpr{source: from}} = query, sources) do
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ecto 3 introduced FromExpr contains source: SubQuery, unlike just SubQuery like before.

{from, name} = get_source(query, sources, 0, from)
[" FROM ", from, " AS " | name]
end
Expand Down Expand Up @@ -546,15 +546,15 @@ if Code.ensure_loaded?(Postgrex) do
defp create_names(prefix, sources, pos, limit) when pos < limit do
current =
case elem(sources, pos) do
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very strange one. As case should work, it should match {table, schema, _alias} pattern even if there is :fragment in the beginning. That somehow worked in the original code, and had been broken after dependencies updating.

{table, schema, _alias} ->
name = [create_alias(table) | Integer.to_string(pos)]
{quote_table(prefix, table), name, schema}

{:fragment, _, _} ->
{nil, [?f | Integer.to_string(pos)], nil}

%Ecto.SubQuery{} ->
{nil, [?s | Integer.to_string(pos)], nil}

{table, schema, _alias} ->
name = [create_alias(table) | Integer.to_string(pos)]
{quote_table(prefix, table), name, schema}
end

[current | create_names(prefix, sources, pos + 1, limit)]
Expand Down