Helpers for using SQL views with Ecto
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Reformat codebase

+7 -3
+5 -2
lib/ecto_view/migration.ex
··· 46 46 def create(%unquote(View){} = view), do: unquote(__MODULE__).__create_view__(view, false) 47 47 def create(other), do: unquote(create_mod).create(other) 48 48 49 - def create_or_replace(%unquote(View){} = view), do: unquote(__MODULE__).__create_view__(view, true) 49 + def create_or_replace(%unquote(View){} = view), 50 + do: unquote(__MODULE__).__create_view__(view, true) 50 51 51 52 def drop(%View{} = view), do: unquote(__MODULE__).__drop__(view, false) 52 53 def drop(other), do: unquote(create_mod).drop(other) ··· 137 138 138 139 defp validate_source(%Ecto.Query{from: %Ecto.Query.FromExpr{source: source}}) do 139 140 case source do 140 - {schema, nil} when is_binary(schema) -> :ok 141 + {schema, nil} when is_binary(schema) -> 142 + :ok 143 + 141 144 {_schema, mod} when is_atom(mod) -> 142 145 raise InvalidSource, schema: mod 143 146 end
+1 -1
test/ecto_view/migration_test.exs
··· 14 14 defmodule ExampleSchema do 15 15 use Ecto.Schema 16 16 17 - schema "example_schema", do: nil 17 + schema("example_schema", do: nil) 18 18 end 19 19 20 20 test "using schema as a source for view fails" do
+1
test/support/repo.ex
··· 8 8 use Ecto.Repo, 9 9 otp_app: :ecto_view, 10 10 adapter: Ecto.Adapters.Postgres 11 + 11 12 use EctoView 12 13 end