Fix: On new clients, trying to get Client.by_code(None) would raise an error

This commit is contained in:
Tanshu 2014-09-01 21:59:42 +05:30
parent 78a064a723
commit fe811d9887
1 changed files with 2 additions and 0 deletions

View File

@ -45,6 +45,8 @@ class Client(Base):
@classmethod
def by_code(cls, code):
if code is None:
return None
if not isinstance(code, int):
code = int(code)
return DBSession.query(cls).filter(cls.code == code).first()