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
I have Model_Product which has_many Model_Images and relates to Model_Category in a many_to_many
When editing a Model_Product the original_relations entry for it's Model_Images is getting set to an array of empty strings.
$product = Model_Product::find(1);
// $product->images == [ 1, 2, 3, 4, 5, 6 ]
unset($product->images);
$product->image = Model_Image::query()->where('id', 'IN', [ 20, 21, 22 ])->get();
...// Within another method which is only passed the product's id
Model_Category::query()
->related('products')
->where('products.id', $product_id)
->get();
...// $product->_original_relations['images'] == [ '', '', '' ]$product->save();
// $product->images == [ 1, 2, 3, 4, 5, 6, 20, 21, 22 ]
After stepping through the execution of ORM I have isolated the problem to be the call to Orm\Model::_update_original_relations() from Orm\Query::hydrate() which is run as part of executing the Model_Category::query().
I think that #312 might solve this issue in my instance because the relations are already loaded when Orm\Query::hydrate() is run. However, in a more general case I think it might be necessary to check within Orm\Model::_update_original_relations() that the data the "original" IDs are being retrieved from is not new.
The text was updated successfully, but these errors were encountered:
I have
Model_Product
which has_manyModel_Image
s and relates toModel_Category
in a many_to_manyWhen editing a
Model_Product
the original_relations entry for it'sModel_Image
s is getting set to an array of empty strings.After stepping through the execution of ORM I have isolated the problem to be the call to
Orm\Model::_update_original_relations()
fromOrm\Query::hydrate()
which is run as part of executing theModel_Category::query()
.I think that #312 might solve this issue in my instance because the relations are already loaded when
Orm\Query::hydrate()
is run. However, in a more general case I think it might be necessary to check withinOrm\Model::_update_original_relations()
that the data the "original" IDs are being retrieved from is not new.The text was updated successfully, but these errors were encountered: