Using Ecto changeset with dynamic schemaless data

248 views
Skip to first unread message

Lars Wikman

unread,
Apr 21, 2021, 4:27:33 AM4/21/21
to elixi...@googlegroups.com
Hey

Having conceded that I will need to use the adapter query escape hatch for querying fields defined at runtime I would still like to be able to use changesets. But even passing a data and types tuple (schemaless style) I will have to pass atom keys.

My structure is user defined and so I don't want to turn my string keys into atoms since that's easily abused. But I would like to use cast/validate_required and friends.

I'm guessing this isn't a desirable change for the common case but I figured I'd raise the question about accepting string keys before figuring out much harder options.

-Lars Wikman

José Valim

unread,
Apr 21, 2021, 6:28:06 AM4/21/21
to elixi...@googlegroups.com
This is probably too outside of what Ecto.Changeset was designed for and doing all changes would be non-trivial. Perhaps it is easier to use the subset that they share (i.e. Ecto.Type) and build on top of it.

--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/CADqW%2BqnLTOABeptceVnygzuChGt2N-J178C-%3DMLLdw1nwmpL3w%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages