From ce4f5bb84441a82e3b5a994689e4a752b3d1576b Mon Sep 17 00:00:00 2001 From: aelaa Date: Mon, 11 May 2020 18:03:35 +0300 Subject: [PATCH 1/2] Fix wrong case matching --- lib/redshift_ecto/connection.ex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/redshift_ecto/connection.ex b/lib/redshift_ecto/connection.ex index 8bf9784..fd89835 100644 --- a/lib/redshift_ecto/connection.ex +++ b/lib/redshift_ecto/connection.ex @@ -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 - {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)] From 2bf7d7181e2564b16a00136742684aa98dea60bc Mon Sep 17 00:00:00 2001 From: aelaa Date: Mon, 11 May 2020 18:29:25 +0300 Subject: [PATCH 2/2] Fix from expression --- lib/redshift_ecto/connection.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/redshift_ecto/connection.ex b/lib/redshift_ecto/connection.ex index fd89835..848e1db 100644 --- a/lib/redshift_ecto/connection.ex +++ b/lib/redshift_ecto/connection.ex @@ -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 {from, name} = get_source(query, sources, 0, from) [" FROM ", from, " AS " | name] end