bmuller / twistar

Twistar is an object-relational mapper (ORM) for Python that uses the Twisted library to provide asynchronous DB interaction.

Home Page:http://findingscience.com/twistar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Non-working BelongsTo.clear

himikof opened this issue · comments

If a BelongsTo relationship is cleared, the foreign-key atrribute is set to None, but such attributes are ignored during save(). The
test_clear_belongs_to is broken because it does not call refresh, it checks only in-memory value. This testcase demonstrates the problem:

@inlineCallbacks
    def test_clear_belongs_to(self):
        picture = yield Picture(name="a pic", size=10, user_id=self.user.id).save()
        yield picture.user.clear()
        user = yield picture.user.get()
        self.assertEqual(user, None)
        yield picture.refresh()
        user = yield picture.user.get()
        self.assertEqual(user, None)

This is a bug. Fixing now...