-
Notifications
You must be signed in to change notification settings - Fork 28
spec tweaks, and add select_continue
#39
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
base: master
Are you sure you want to change the base?
spec tweaks, and add select_continue
#39
Conversation
|
Thank you for the PR! This project was started before the Elixir formatter was created, and follows its own unique style-guide (which predates formatter). I do plan on updating the code formatting and style to use the modern formatter but that requires a bit of work from me before I'm ready to do that. Would you be kind enough to update your PR to only include the code changes, spec tweaks, etc. without the formatting? Thank you again! |
This reverts commit a4214bc.
|
That makes sense - I reverted the formatting changes in the last commit. Let me know if anything else should be changed! |
select_continueselect_continue
|
|
||
| :match_object | ||
| |> Mnesia.call([table, pattern, lock]) | ||
| |> coerce_records |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change, is it intentional? At least without the patch I get a map, and with the patch I get just the values as a tuple. Of course, calling Memento.Query.all(…, coerce: true) fixes this, but shouldn't the default be true here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm definitely unintentional. Could you share a snippet that reproduces this? I'm not sure how you could get a map out of parse_results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah sorry, I was referring to the individual results, not the whole data structure. Here's what I mean:
defmodule Dummy do
use Memento.Table, attributes: [:id, :title, :content]
def setup() do
Memento.Table.create(Dummy)
Memento.transaction(fn ->
Memento.Query.write(%Dummy{id: 1, title: "hi", content: "all"})
end)
end
def all_no_coerce() do
Memento.transaction(fn ->
Memento.Query.all(Dummy, coerce: false)
end)
end
def all_with_coerce() do
Memento.transaction(fn ->
Memento.Query.all(Dummy, coerce: true)
end)
end
end
# on this PR:
# iex(5)> Dummy.setup
# {:ok, %Dummy{__meta__: Memento.Table, id: 1, title: "hi", content: "all"}}
# iex(6)> Dummy.all_no_coerce
# {:ok, [{Dummy, 1, "hi", "all"}]}
# iex(7)> Dummy.all_with_coerce
# {:ok, [%Dummy{__meta__: Memento.Table, id: 1, title: "hi", content: "all"}]}
# on 0.5:
# iex(5)> Dummy.setup
# {:ok, %Dummy{__meta__: Memento.Table, id: 1, title: "hi", content: "all"}}
# iex(6)> Dummy.all_no_coerce
# {:ok, [%Dummy{__meta__: Memento.Table, id: 1, title: "hi", content: "all"}]}
# iex(7)> Dummy.all_with_coerce
# {:ok, [%Dummy{__meta__: Memento.Table, id: 1, title: "hi", content: "all"}]}I always specified coerce in the demo, so maybe the issue is not the default value, but that PR and release version behave differently when setting coerce: false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I see, thanks for the example. Yeah the default value for both all/1,2 and match/2,3 should be true just like the other functions. I'll push a fix in a bit, thanks for catching that. I don't think this is a breaking change, since it's adding a new option that wasn't supported before - giving coerce: false to all/1,2 on 0.5 isn't actually preventing the coercion (hence why you still get a struct on 0.5)
…est, fix select_raw test (breaking), fix dialyzer error (ets.continuation is opaque), use charlist sigil to avoid compile warning
|
Note: this does actually contain a breaking change, since |
Hello! Thanks for this lib, it's been very helpful in one of my projects as I learn Mnesia.
This PR fixes a couple of spec discrepancies dialyzer highlighted, adds support for
:coerceinread/3, and addsQuery.select_continue.I hope you don't mind, I also added aReviewing by these commits (with with actual functional changes) will be easier:.formatter.exsand formatted the project (a4214bc).:coerceinreadselect_continue