Project

General

Profile

« Previous | Next » 

Revision 2368

sql.py: run_query(): Exception parsing: Use non-greedy qualifier "?" in regexps wherever possible to avoid matching closing quotes later in the error message

View differences:

lib/sql.py
357 357
        msg = exc.str_(e)
358 358
        
359 359
        match = re.search(r'duplicate key value violates unique constraint '
360
            r'"((_?[^\W_]+)_[^"]+)"', msg)
360
            r'"((_?[^\W_]+)_[^"]+?)"', msg)
361 361
        if match:
362 362
            constraint, table = match.groups()
363 363
            try: cols = index_cols(db, table, constraint)
364 364
            except NotImplementedError: raise e
365 365
            else: raise DuplicateKeyException(constraint, cols, e)
366 366
        
367
        match = re.search(r'null value in column "(\w+)" violates not-null '
367
        match = re.search(r'null value in column "(\w+?)" violates not-null '
368 368
            r'constraint', msg)
369 369
        if match: raise NullValueException('NOT NULL', [match.group(1)], e)
370 370
        
371
        match = re.search(r'invalid input (?:syntax|value)\b.*: "(.+)"\n'
372
            r'(?:(?s).*)\bfunction "(\w+)".*\bat assignment', msg)
371
        match = re.search(r'invalid input (?:syntax|value)\b.*?: "(.+?)"\n'
372
            r'(?:(?s).*?)\bfunction "(\w+?)".*?\bat assignment', msg)
373 373
        if match:
374 374
            raise FunctionValueException(match.group(2),
375 375
                strings.to_unicode(match.group(1)), e)
376 376
        
377
        match = re.search(r'relation "(\w+)" already exists', msg)
377
        match = re.search(r'relation "(\w+?)" already exists', msg)
378 378
        if match: raise DuplicateTableException(match.group(1), e)
379 379
        
380
        match = re.search(r'function "(\w+)" already exists', msg)
380
        match = re.search(r'function "(\w+?)" already exists', msg)
381 381
        if match: raise DuplicateFunctionException(match.group(1), e)
382 382
        
383 383
        raise # no specific exception raised

Also available in: Unified diff