You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That have the exactly same logic with the additional issue that creation functions call insertion functions. So let’s deep dive on this issue:
Semantics
Following Phoenix context and Ecto semantics, insertion function should receive the already built struct of the schema OR a %Ecto.Changeset{} that represents the current schema via the data attribute.
On the other hand, creation functions should receive raw parameters as maps, trigger the changeset function to parse this parameter and then leverage the insertion function.
There’s no idea of “creation” on Ecto.Repo, as it leverages direct database API functions.
What’s on currently?
Currently the insertion and creation functions have the exactly same logic, as:
Currently we define:
insert/2
insert!/2
create/2
create!/2
That have the exactly same logic with the additional issue that creation functions call insertion functions. So let’s deep dive on this issue:
Semantics
Following Phoenix context and Ecto semantics, insertion function should receive the already built struct of the schema OR a
%Ecto.Changeset{}
that represents the current schema via thedata
attribute.On the other hand, creation functions should receive raw parameters as maps, trigger the
changeset
function to parse this parameter and then leverage the insertion function.There’s no idea of “creation” on
Ecto.Repo
, as it leverages direct database API functions.What’s on currently?
Currently the insertion and creation functions have the exactly same logic, as:
repo
insert/2
function from therepo
changeset/2
function__MODULE__
, passes it to the changeset function and then to the local insert functionProposal
I would like to make a suggestion:
The text was updated successfully, but these errors were encountered: