Skip to content

Commit

Permalink
Merge 9007b3a into de6ef5f
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnystorm committed Feb 10, 2019
2 parents de6ef5f + 9007b3a commit 44f8711
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/ecto_mnesia/record/context/match_spec.ex
Expand Up @@ -29,9 +29,9 @@ defmodule EctoMnesia.Record.Context.MatchSpec do

# Build match_spec head part (data placeholders)
defp match_head(%Context{table: %Context.Table{name: table_name}} = context) do
context
|> Context.get_fields_placeholders()
|> Enum.into([table_name])
[ table_name
| Context.get_fields_placeholders(context)
]
|> List.to_tuple()
end

Expand Down
12 changes: 7 additions & 5 deletions lib/ecto_mnesia/storage/migrator.ex
Expand Up @@ -123,7 +123,7 @@ defmodule EctoMnesia.Storage.Migrator do
|> Enum.map(fn index ->
case Mnesia.add_table_index(table, index) do
{:atomic, :ok} -> :ok
{:node_not_running, not_found_node} -> raise "Node #{inspect(not_found_node)} is not started"
{:aborted, {:node_not_running, not_found_node}} -> raise "Node #{inspect(not_found_node)} is not started"
{:aborted, {:already_exists, ^table, _}} -> raise "Index for field #{index} in table #{table} already exists"
end
end)
Expand All @@ -135,7 +135,7 @@ defmodule EctoMnesia.Storage.Migrator do
|> Enum.map(fn index ->
case Mnesia.add_table_index(table, index) do
{:atomic, :ok} -> :ok
{:node_not_running, not_found_node} -> raise "Node #{inspect(not_found_node)} is not started"
{:aborted, {:node_not_running, not_found_node}} -> raise "Node #{inspect(not_found_node)} is not started"
{:aborted, {:already_exists, ^table, _}} -> :ok
end
end)
Expand All @@ -147,7 +147,7 @@ defmodule EctoMnesia.Storage.Migrator do
|> Enum.map(fn index ->
case Mnesia.del_table_index(table, index) do
{:atomic, :ok} -> :ok
{:node_not_running, not_found_node} -> raise "Node #{inspect(not_found_node)} is not started"
{:aborted, {:node_not_running, not_found_node}} -> raise "Node #{inspect(not_found_node)} is not started"
{:aborted, {:no_exists, ^table, _}} -> raise "Index for field #{index} in table #{table} does not exists"
end
end)
Expand All @@ -159,7 +159,7 @@ defmodule EctoMnesia.Storage.Migrator do
|> Enum.map(fn index ->
case Mnesia.del_table_index(table, index) do
{:atomic, :ok} -> :ok
{:node_not_running, not_found_node} -> raise "Node #{inspect(not_found_node)} is not started"
{:aborted, {:node_not_running, not_found_node}} -> raise "Node #{inspect(not_found_node)} is not started"
{:aborted, {:no_exists, ^table, _}} -> :ok
end
end)
Expand Down Expand Up @@ -198,7 +198,9 @@ defmodule EctoMnesia.Storage.Migrator do

case Enum.find_index(fields, &(&1 == old_field)) do
nil ->
if on_not_found == :raise, do: raise("Field #{old_field} not found", else: fields)
if on_not_found == :raise,
do: raise("Field #{old_field} not found"),
else: fields

index when is_number(index) ->
List.replace_at(fields, index, new_field)
Expand Down
2 changes: 1 addition & 1 deletion lib/ecto_mnesia/table.ex
Expand Up @@ -23,7 +23,7 @@ defmodule EctoMnesia.Table do
defp _insert(table, record) do
case Mnesia.write(table, record, :write) do
:ok -> {:ok, record}
error -> {:error, error}
{:aborted, reason} -> {:error, reason}
end
end

Expand Down

0 comments on commit 44f8711

Please sign in to comment.