thephpleague / factory-muffin

Enables the rapid creation of objects for testing
https://factory-muffin.thephpleague.com/
MIT License
532 stars 72 forks source link

How to place an Auto-increment id in v3.1 #464

Open sharan1 opened 4 years ago

sharan1 commented 4 years ago

when we updated factory muffin from v2.1 to v3.1

For auto-incrementing ids, we used to use the following function:

function () {
        static $last;
         if ($last === null) {
             return $last = 1;
         }
         return ++$last;
}

But after upgrading the same function always started returning 1, resulting in errors for duplication of primary key in our test database.

Any idea what could be the issue and how to resolve it?

Originally posted by @sharan1 in https://github.com/thephpleague/factory-muffin/issues/382#issuecomment-582616072

GrahamCampbell commented 4 years ago

Thanks for the report. I can't quite remember why this would have been broken. I'll have a think. ;)