(key, for_types)
| 376 | |
| 377 | @staticmethod |
| 378 | def needsQuoting(key, for_types): |
| 379 | value = key |
| 380 | val_noarray = value |
| 381 | |
| 382 | # check if the string is number or not |
| 383 | if isinstance(value, int): |
| 384 | return True |
| 385 | # certain types should not be quoted even though it contains a space. |
| 386 | # Evilness. |
| 387 | elif for_types and value.endswith('[]'): |
| 388 | val_noarray = value[:-2] |
| 389 | |
| 390 | if for_types and val_noarray.lower() in [ |
| 391 | 'bit varying', |
| 392 | '"char"', |
| 393 | 'character varying', |
| 394 | 'double precision', |
| 395 | 'timestamp without time zone', |
| 396 | 'timestamp with time zone', |
| 397 | 'time without time zone', |
| 398 | 'time with time zone', |
| 399 | '"trigger"', |
| 400 | '"unknown"' |
| 401 | ]: |
| 402 | return False |
| 403 | |
| 404 | # If already quoted?, If yes then do not quote again |
| 405 | if for_types and val_noarray and \ |
| 406 | (val_noarray.startswith('"') or val_noarray.endswith('"')): |
| 407 | return False |
| 408 | |
| 409 | if '0' <= val_noarray[0] <= '9': |
| 410 | return True |
| 411 | |
| 412 | if re.search('[^a-z_0-9]+', val_noarray): |
| 413 | return True |
| 414 | |
| 415 | # check string is keywaord or not |
| 416 | category = Driver.ScanKeywordExtraLookup(value) |
| 417 | |
| 418 | if category is None: |
| 419 | return False |
| 420 | |
| 421 | # UNRESERVED_KEYWORD |
| 422 | if category == 0: |
| 423 | return False |
| 424 | |
| 425 | # COL_NAME_KEYWORD |
| 426 | if for_types and category == 1: |
| 427 | return False |
| 428 | |
| 429 | return True |
| 430 | |
| 431 | @staticmethod |
| 432 | def qtTypeIdent(conn, *args): |
no test coverage detected