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

conform is converting MapSets to Lists in nested schema #47

Closed
asianfilm opened this issue Feb 11, 2020 · 1 comment · Fixed by #49
Closed

conform is converting MapSets to Lists in nested schema #47

asianfilm opened this issue Feb 11, 2020 · 1 comment · Fixed by #49

Comments

@asianfilm
Copy link

asianfilm commented Feb 11, 2020

Example taken from my code in another issue (#30).

iex> Todo.gen() |> Enum.take(1) |> IO.inspect() |> conform(coll_of(Todo.s()))
[
  %Todo{
    what: "Watch movie",
    when: "Sun",
    who: #MapSet<[
      %Person.Student{name: "Prudence", school: "Academy of the Unseen Arts"},
      %Person.Programmer{
        languages: #MapSet<["Elixir", "Elm", "Haskell"]>,
        name: "Chris",
        university: %Algae.Maybe.Nothing{}
      }
    ]>
  }
]

{:ok,
 [
   %Todo{
     what: "Watch movie",
     when: "Sun",
     who: [
       %Person.Student{name: "Prudence", school: "Academy of the Unseen Arts"},
       %Person.Programmer{
         languages: ["Elixir", "Elm", "Haskell"],
         name: "Chris",
         university: %Algae.Maybe.Nothing{}
       }
     ]
   }
 ]}

Issue seems to be when MapSets are nested inside other collections (including lists). For example, here (after revising the code) only languages is expected to be a MapSet:

iex> Todo.gen() |> Enum.take(1) |> List.first() |> IO.inspect() |> conform(Todo.s())
%Todo{
  what: "Grocery shop",
  when: "Tue",
  who: [
    %Person.Programmer{
      languages: #MapSet<["Cobol", "Elm"]>,
      name: "Wojtek",
      university: %Algae.Maybe.Nothing{}
    },
    %Person.Student{name: "Sabrina", school: "Baxter High School"}
  ]
}

{:ok,
 %Todo{
   what: "Grocery shop",
   when: "Tue",
   who: [
     %Person.Programmer{
       languages: ["Cobol", "Elm"],
       name: "Wojtek",
       university: %Algae.Maybe.Nothing{}
     },
     %Person.Student{name: "Sabrina", school: "Baxter High School"}
   ]
 }
}
@keathley
Copy link
Member

keathley commented Feb 23, 2020

I've opened a PR that should address these issues. While I was in there I also added more docs around coll_of. That function does a lot more then we've really shown.

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 a pull request may close this issue.

2 participants