Skip to content

Commit

Permalink
Fix deprecated function calls without parens
Browse files Browse the repository at this point in the history
  • Loading branch information
janpieper committed Jul 26, 2024
1 parent 6664ff9 commit 10f149e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
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

0 comments on commit 10f149e

Please sign in to comment.