diff --git a/lib/ecto_view/migration.ex b/lib/ecto_view/migration.ex index 95b3467..bc7314e 100644 --- a/lib/ecto_view/migration.ex +++ b/lib/ecto_view/migration.ex @@ -46,7 +46,8 @@ defmodule EctoView.Migration do def create(%unquote(View){} = view), do: unquote(__MODULE__).__create_view__(view, false) def create(other), do: unquote(create_mod).create(other) - def create_or_replace(%unquote(View){} = view), do: unquote(__MODULE__).__create_view__(view, true) + def create_or_replace(%unquote(View){} = view), + do: unquote(__MODULE__).__create_view__(view, true) def drop(%View{} = view), do: unquote(__MODULE__).__drop__(view, false) def drop(other), do: unquote(create_mod).drop(other) @@ -137,7 +138,9 @@ defmodule EctoView.Migration do defp validate_source(%Ecto.Query{from: %Ecto.Query.FromExpr{source: source}}) do case source do - {schema, nil} when is_binary(schema) -> :ok + {schema, nil} when is_binary(schema) -> + :ok + {_schema, mod} when is_atom(mod) -> raise InvalidSource, schema: mod end diff --git a/test/ecto_view/migration_test.exs b/test/ecto_view/migration_test.exs index 522a2f0..8621dd0 100644 --- a/test/ecto_view/migration_test.exs +++ b/test/ecto_view/migration_test.exs @@ -14,7 +14,7 @@ defmodule EctoView.MigrationTest do defmodule ExampleSchema do use Ecto.Schema - schema "example_schema", do: nil + schema("example_schema", do: nil) end test "using schema as a source for view fails" do diff --git a/test/support/repo.ex b/test/support/repo.ex index c61aa16..6c9b3ba 100644 --- a/test/support/repo.ex +++ b/test/support/repo.ex @@ -8,5 +8,6 @@ defmodule EctoView.Repo do use Ecto.Repo, otp_app: :ecto_view, adapter: Ecto.Adapters.Postgres + use EctoView end