Menu

#17 _column_value casting None val

open
nobody
None
5
2008-08-19
2008-08-19
Anonymous
No

in the Sybase 0.39 version,

The _column_value function is defined as:

def _column_value(val, dbtype, outputmap):
if outputmap is not None:
converter = outputmap.get(dbtype, None)
if converter is not None:
val = converter(val)
return val

This can be a problem if the converter is a datetime converter and val is None.

I've added a condition to the method to return None instead of raising AttributeError: 'NoneType' object has no attribute 'year'

def _column_value(val, dbtype, outputmap):
if outputmap is not None:
converter = outputmap.get(dbtype, None)
if converter is not None:
if val is not None: # <--- added condition
val = converter(val)
return val

Just thought I'd pass that along...

Thanks,
Ricky
RickyChaddock@Gmail.com

Discussion


Log in to post a comment.