graze / dal

Data Access Layer
MIT License
8 stars 0 forks source link

Multiple flushes do not behave as expected #28

Open schettle opened 8 years ago

schettle commented 8 years ago
$dal = Container::make('dal.manager');

foreach (['a', 'b'] as $n) {
    foreach ([1, 2, 3, 4, 5] as $i) {
        $recipe = new Recipe();
        $recipe->setName($n . $i);

        $dal->persist($recipe);
        $dal->flush();
    }
}
$repository = $dal->getRepository('Graze\Lib\Entity\Product\Recipe');
dump($repository->findAll());

This inserts only b4 and b5, if I move the flush to after the for each loop, i.e. just one flush, it inserts all records as expected.

wpillar commented 7 years ago

In 1.0 I have written a functional test to cover this case: https://github.com/graze/dal/blob/1.0/tests/functional/DalManagerTest.php#L45

And it passes. If this is still an issue I can do further work to test on the older code.