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

to_existing_atom blows up when loading new values from DB #4

Open
kenips opened this issue Apr 27, 2018 · 2 comments
Open

to_existing_atom blows up when loading new values from DB #4

kenips opened this issue Apr 27, 2018 · 2 comments

Comments

@kenips
Copy link

kenips commented Apr 27, 2018

Not sure the rationale behind using to_existing_atom on load, but I guess the idea is that you're not trusting the database? If we input a new string value in the DB the current load function would blow up as the atom doesn't exist.

@janpieper
Copy link

Warning: this function creates atoms dynamically and atoms are not garbage-collected. Therefore, string should not be an untrusted value, such as input received from a socket or during a web request. Consider using to_existing_atom/1 instead.

See https://hexdocs.pm/elixir/String.html#to_atom/1

@voughtdq
Copy link

I created a version using the new Ecto.ParameterizedType behaviour that does what you're asking:

https://gist.github.com/voughtdq/a4930fd9c8ce10f2899a3476e94aba1a

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

No branches or pull requests

3 participants