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

Returned map in steps is inconsistent with the result #80

Open
darwin67 opened this issue May 23, 2024 · 1 comment
Open

Returned map in steps is inconsistent with the result #80

darwin67 opened this issue May 23, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@darwin67
Copy link
Owner

Overview

When returning a map in a step like this.

result = step.run(ctx, "step", fn ->
  %{foo: "bar"}
end)

The result is set to %{ "foo" => "bar" } instead of %{foo: "bar"} which is what you'd expect from the code.

This will raise an error if you try to pattern match against the returned value when doing

%{foo: _} = step.run(ctx, "step", fn ->
  %{foo: "bar"}
end)
@darwin67 darwin67 added the bug Something isn't working label May 23, 2024
@darwin67
Copy link
Owner Author

Provided an options and make it step.run/3 so user can specify the map structure they expect.

Also provide a configurable library default option, with the steps being the final override.

Discussion:
https://elixirforum.com/t/pattern-match-on-map-keys-that-can-be-atoms-or-strings/63760/7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant