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

twistar.validation.presenceOf is broken

erikkaplun opened this issue · comments

class MyModel(DBObject):
    field = None
MyModel.validatesPresenceOf('field')

assert MyModel().isValid()  # succeeds

this is because presenceOf has:

    if getattr(obj, name, "") == "":

but should have:

    if getattr(obj, name, None) is None:

optionally you can add checking for "" depending on how you want to interpret empty strings:

if getattr(obj, name, None) in (None, ""):

Fixed in 1cd603a - thanks!