Merge pull request #27 from lyinfo/master-ck-match
Dereferencing of nones could lose error messages during import
This commit is contained in:
commit
072485799c
|
@ -5217,7 +5217,7 @@ def convert_pgerror_23502(model, fields, info, e):
|
|||
m = re.match(r'^null value in column "(?P<field>\w+)" violates '
|
||||
r'not-null constraint\n',
|
||||
str(e))
|
||||
field_name = m.group('field')
|
||||
field_name = m and m.group('field')
|
||||
if not m or field_name not in fields:
|
||||
return {'message': unicode(e)}
|
||||
message = _(u"Missing required value for the field '%s'.") % field_name
|
||||
|
@ -5232,7 +5232,7 @@ def convert_pgerror_23502(model, fields, info, e):
|
|||
def convert_pgerror_23505(model, fields, info, e):
|
||||
m = re.match(r'^duplicate key (?P<field>\w+) violates unique constraint',
|
||||
str(e))
|
||||
field_name = m.group('field')
|
||||
field_name = m and m.group('field')
|
||||
if not m or field_name not in fields:
|
||||
return {'message': unicode(e)}
|
||||
message = _(u"The value for the field '%s' already exists.") % field_name
|
||||
|
|
Loading…
Reference in New Issue