Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated function calls without parens #35

Merged
Show file tree
Hide file tree
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
13 changes: 7 additions & 6 deletions lib/memento/query/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ defmodule Memento.Query do
"""
@spec all(Table.name, options) :: list(Table.record)
def all(table, opts \\ []) do
pattern = table.__info__.query_base
pattern = table.__info__().query_base
lock = Keyword.get(opts, :lock, :read)

:match_object
Expand Down Expand Up @@ -420,8 +420,10 @@ defmodule Memento.Query do
@result [:"$_"]
@spec select(Table.name, list(tuple) | tuple, options) :: list(Table.record)
def select(table, guards, opts \\ []) do
attr_map = table.__info__.query_map
match_head = table.__info__.query_base
info = table.__info__()

attr_map = info.query_map
match_head = info.query_base
guards = Memento.Query.Spec.build(guards, attr_map)

select_raw(table, [{ match_head, guards, @result }], opts)
Expand Down Expand Up @@ -491,7 +493,7 @@ defmodule Memento.Query do
Return all records:

```
match_head = Movie.__info__.query_base
match_head = Movie.__info__().query_base
result = [:"$_"]
guards = []

Expand Down Expand Up @@ -674,8 +676,7 @@ defmodule Memento.Query do

# Raises error if tuple size and no. of attributes is not equal
defp validate_match_pattern!(table, pattern) do
same_size? =
(tuple_size(pattern) == table.__info__.size)
same_size? = (tuple_size(pattern) == table.__info__().size)

unless same_size? do
Memento.Error.raise(
Expand Down
2 changes: 1 addition & 1 deletion test/memento/mnesia_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ defmodule Memento.Tests.Mnesia do
describe "#handle_result" do
test "reraises specific erlang errors as elixir exceptions" do
assert_raise(UndefinedFunctionError, ~r/is undefined/i, result_for(fn ->
RandomModule.undefined_fun
RandomModule.undefined_fun()
end))
end

Expand Down
4 changes: 2 additions & 2 deletions test/memento/query/query_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ defmodule Memento.Tests.Query do

describe "#select_raw" do
@table Tables.Movie
@match_all [{ @table.__info__.query_base, [], [:"$_"] }]
@match_all [{ @table.__info__().query_base, [], [:"$_"] }]

setup do
Memento.Table.create(@table)
Expand Down Expand Up @@ -368,7 +368,7 @@ defmodule Memento.Tests.Query do


test "Returns empty list when nothing matches and limit is non-nil" do
match_none = [{ @table.__info__.query_base, [{:==, :id, :invalid}], [:"$_"] }]
match_none = [{ @table.__info__().query_base, [{:==, :id, :invalid}], [:"$_"] }]

Support.Mnesia.transaction fn ->
assert [] = Query.select_raw(@table, match_none, limit: 5)
Expand Down
Loading