Closed ckbx-cakebox closed 1 year ago
Essentially, the problem is that DataCompiler::compileEntity()
(does explicitly) ignore $dataFromDefaultTemplate
but doesn't ignore $dataFromDefaultAssociations
, when EntityInterface
is injected. Thus I supposed it is a bug. I guess that both should be ignored.
The smallest reproductive code is the following:
$article = ArticleFactory::make()->persist();
print count($article->comments); // 1
ArticleFactory::make($article)->persist();
print count($article->comments); // 2
Yes, this looks like a bug, nice catch!
If you can fix the pipe (psalm), I'll merge that. https://github.com/vierge-noire/cakephp-fixture-factories/actions/runs/5845958439/job/16108103706
Thank you, I have just fixed the psalm error!
Merged, thank you!
For example, we supposed to have three tables; Authors, Articles, Comments. Article has many Comments and Authors.
First we call
with()
method on hasMany associations insidesetDefaultTemplate()
.To call
with()
method with entity occurs unexpected increase of its associations.Otherwise, do I have a mistake about the usage of the
with()
method?