factory_boy icon indicating copy to clipboard operation
factory_boy copied to clipboard

Factories doesn't seem to work if a session hasn't been used yet.

Open jpanganiban opened this issue 12 years ago • 2 comments

I'm working with SQLAlchemy (with a scoped_session). Here's what I'm getting:

class TestCase(unittest.TestCase):

    def setUp(self):
        self.obj = ObjectFactory()
        print self.obj.id  # None

    def test_scenario(self):
        print self.obj.id  # None; Weird.
        session.query(Object).first()
        print ObjectFactory().id  # 1; Weird.

EDIT: setUp doesn't seem to be the causing issue. It seems that _setup_next_sequency() doesn't get any primary keys to use if the session hasn't been used yet.

jpanganiban avatar Aug 12 '14 21:08 jpanganiban

Hmm, that would be "yet another automagic sequence counter bug" :/

I'll look into it, thanks for the report.

rbarrois avatar Sep 03 '14 20:09 rbarrois

This issue has been fixed in 13d310f, and will be part of the 2.5.0 release.

rbarrois avatar Mar 26 '15 21:03 rbarrois