Fork me on GitHub
#fulcro
<
2022-12-25
>
Jakub Holý (HolyJak)18:12:26

I observe weird behavior in rad-template, namely active? on a newly created entity does not have :account/active? {:before nil} as I would expect for a new entity but instead it has :before true : > _rad.pathom:- 46 - transaction: [{(com.fulcrologic.rad.form/save-form {:com.fulcrologic.rad.form/id #fulcro/tempid[“dc85612d-31b3-4919-8b26-938b78cdb228”], :com.fulcrologic.rad.form/delta {[:account/id #fulcro/tempid[“dc85612d-31b3-4919-8b26-938b78cdb228"]] {:account/email {:before nil, :after "[email protected]"}, :account/active? {:before true, :after true}, :account/files {:before [], :after []}}}, :com.fulcrologic.rad.form/master-pk :account/id}) [:account/id :com.fulcrologic.rad.form/errors :account/email :account/active? {:account/files [:file/id :com.fulcrologic.rad.form/errors :file/uploaded-on :file/sha :file.sha/filename :file.sha/url :file.sha/progress :file.sha/status]} :tempids]}] As a result, active? is not stored into the DB and the account is inactive. I assume it is related by fo/default-value true on the attribute. But is it not bug anyway that we get :before true in the diff? The DB has no idea about Fulcro’s default values. Or should it? Thank you! Note: fulcro-rad-asami only stores values that have been changed so if before == after it won’t change it even if the entity does not exist (b/c I assumed that this would never happen for a new entity).

tony.kay21:12:37

Yeah probably a bug in the order of initialization. The call to add form config copies what is in state. So that is causing the before values to have data that it should not have

👍 1
Jakub Holý (HolyJak)08:12:29

BTW it has the same problem with enums

tony.kay09:12:12

@U0522TWDA Try using Fulcro 3.5.33-SNAPSHOT. I consider this a bug in the core primitive of add-form-config, not in RAD.

👍 1
Jakub Holý (HolyJak)10:12:20

It works! Thank you!