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

Correctly fetch owners if metadata is falsey #9

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

martosaur
Copy link
Contributor

@martosaur martosaur commented Dec 3, 2024

Currently, it is impossible to fetch owner if stored metadata is falsey:

iex(1)> {:ok, pid} = NimbleOwnership.start_link(name: Server)
{:ok, #PID<0.199.0>}
iex(2)> {:ok, nil} = NimbleOwnership.get_and_update(Server, self(), :foo, fn metadata -> {nil, metadata} end)
{:ok, nil}
iex(3)> NimbleOwnership.fetch_owner(Server, [self()], :foo)
:error

The PR fixes it by replacing chained map access in cond with matching case.

@josevalim josevalim merged commit 1b115f2 into dashbitco:main Dec 3, 2024
3 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@martosaur martosaur deleted the am/nil_metadata branch December 3, 2024 16:16
@whatyouhide
Copy link
Collaborator

Nice! Great cathc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants