Skip to content

Commit

Permalink
Bugfix: Coerce $end_of_table to []
Browse files Browse the repository at this point in the history
  • Loading branch information
sheharyarn committed Mar 17, 2019
1 parent 96e7712 commit a935b35
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
elixir 1.6.5
erlang 20.1
elixir 1.8.1
erlang 21.2.6
2 changes: 2 additions & 0 deletions lib/memento/query/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,8 @@ defmodule Memento.Query do
coerce_records(records)
end

defp coerce_records(:"$end_of_table"), do: []


# Raises error if tuple size and no. of attributes is not equal
defp validate_match_pattern!(table, pattern) do
Expand Down
9 changes: 9 additions & 0 deletions test/memento/query/query_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,15 @@ defmodule Memento.Tests.Query do
assert [%@table{} | _rest] = records
end
end


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

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

end
Expand Down

0 comments on commit a935b35

Please sign in to comment.