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

Fix error -- cast from Array(String) to String #895

Merged
merged 4 commits into from
Oct 17, 2022

Conversation

akadusei
Copy link
Contributor

@akadusei akadusei commented Oct 14, 2022

Fixes #884

You can now instantiate Avram::Params passing a hash with array values or string values or a mixture of both.

```
cast from Array(String) to String failed
```

Fixes luckyframework#884.
@akadusei akadusei changed the title Fix error Fix error -- cast from Array(String) to String Oct 14, 2022
Copy link
Member

@jwoertink jwoertink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on. One thing I'd like to see would be a spec that allows me to pass in an array value, and then one with a mixed value. So like...

it "should work" do
  params = Avram::Params.new({"key" => ["val1", "val2"]})
  SomeOperation.create(params) do |o, v|
    v.should_not be_nil
  end
end

it "should also work" do
  params = Avram::Params.new({"key" => ["val1", "val2"], "key2" => "123"})
  SomeOperation.create(params) do |o, v|
    v.should_not be_nil
  end
end

I think having those two test cases, we should be solid enough to know this all works well.

Comment on lines +4 to +6
@hash : Hash(String, Array(String) | String) | \
Hash(String, Array(String)) | \
Hash(String, String)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, interesting! I think this is where I got tripped up before. I didn't think to also do a union of each one. Nice 👍

Copy link
Member

@jwoertink jwoertink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! I think this looks good.

@matthewmcgarvey matthewmcgarvey merged commit 77eda15 into luckyframework:main Oct 17, 2022
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.

cast from Array(String) to String failed from Avram::Params
3 participants