Hi, I'm trying to pass data across a quick create/...
# box-products
d
Hi, I'm trying to pass data across a quick create/postInsert boundary, that is, I'd like to set a flag on the entity to conditionally run some stuff in
postInsert
. My initial attempts seem to indicate that values set on
this
as well as virtualAttributes are zero'd out (the entity instance on which the values are set, is not the entity instance on which the postInsert is called). Is there a mechanism for this? Am I mistaken in understanding the above behavior?
s
I think when we do this we use a
property
with
persistent=false
👀 1
d
seems to get zero'd out (set to empty string), doesn't make it across the jump into postInsert
s
I'm not sure I've seen the behavior you're describing about things getting zeroed out. When is the value intiailzied and when is it set to an empty string?
d
well, default initialized, to an empty string
s
you can slap a
default
on the property definition
d
yes, but the goal is not to have a default, but to have it set to the value it had, before postInsert
s
I don't follow what you're trying to do
we do something like this with a
firePostInsert
attribute on a couple entities though
d
yeah we do don't we ... that does work ... so there is a way
ah, our mechanism does work, but only in the
.setSomeFlag(...).fill(...).save()
pattern, but not in the
.setSomeFlag(...).create(...)
pattern
i was using
create
, will move to fill/save
s
you'd have to
create({ 'prop' : val })
d
with that I get an, probably due to the persistent=false
Copy code
The [...] attribute was not found on the [...] entity
with
ignoreNonExistentAttributes=true
it doesn't throw, but the value is always set to the default, rather than the value in the create(...) call
fill
+
save
it is, that works good
s
yeah I think I have a bug in on github about nonpersistent attributes being ignored by create from a while back
d
i guess conceptually
create
is a static member method