Revision 2306
Added by Aaron Marcuse-Kubitza over 12 years ago
sql.py | ||
---|---|---|
46 | 46 |
self.name = name |
47 | 47 |
self.value = value |
48 | 48 |
|
49 |
class ExceptionWithColumns(DbException): |
|
50 |
def __init__(self, cols, cause=None): |
|
51 |
DbException.__init__(self, 'for columns: '+(', '.join(cols)), cause) |
|
49 |
class ConstraintException(DbException): |
|
50 |
def __init__(self, name, cols, cause=None): |
|
51 |
DbException.__init__(self, |
|
52 |
'for name: '+str(name)+'; columns: '+(', '.join(cols)), cause) |
|
53 |
self.name = name |
|
52 | 54 |
self.cols = cols |
53 | 55 |
|
54 | 56 |
class NameException(DbException): pass |
55 | 57 |
|
56 |
class DuplicateKeyException(ExceptionWithColumns): pass
|
|
58 |
class DuplicateKeyException(ConstraintException): pass
|
|
57 | 59 |
|
58 |
class NullValueException(ExceptionWithColumns): pass
|
|
60 |
class NullValueException(ConstraintException): pass
|
|
59 | 61 |
|
60 | 62 |
class FunctionValueException(ExceptionWithNameValue): pass |
61 | 63 |
|
... | ... | |
360 | 362 |
constraint, table = match.groups() |
361 | 363 |
try: cols = index_cols(db, table, constraint) |
362 | 364 |
except NotImplementedError: raise e |
363 |
else: raise DuplicateKeyException(cols, e) |
|
365 |
else: raise DuplicateKeyException(constraint, cols, e)
|
|
364 | 366 |
|
365 | 367 |
match = re.search(r'null value in column "(\w+)" violates not-null ' |
366 | 368 |
r'constraint', msg) |
367 |
if match: raise NullValueException([match.group(1)], e) |
|
369 |
if match: raise NullValueException('', [match.group(1)], e)
|
|
368 | 370 |
|
369 | 371 |
match = re.search(r'invalid input (?:syntax|value)\b.*: "(.+)"\n' |
370 | 372 |
r'(?:(?s).*)\bfunction "(\w+)".*\bat assignment', msg) |
Also available in: Unified diff
sql.py: Renamed ExceptionWithColumns to ConstraintException and added name field to contain the constraint name, if any