Take in input a field string and return its processed nulled and casted field string. Examples: MySQL input: VERSION() MySQL output: IFNULL(CAST(VERSION() AS CHAR(10000)), ' ') MySQL scope: VERSION() PostgreSQL input: VERSION() P
(self, field)
| 464 | return hexField |
| 465 | |
| 466 | def nullAndCastField(self, field): |
| 467 | """ |
| 468 | Take in input a field string and return its processed nulled and |
| 469 | casted field string. |
| 470 | |
| 471 | Examples: |
| 472 | |
| 473 | MySQL input: VERSION() |
| 474 | MySQL output: IFNULL(CAST(VERSION() AS CHAR(10000)), ' ') |
| 475 | MySQL scope: VERSION() |
| 476 | |
| 477 | PostgreSQL input: VERSION() |
| 478 | PostgreSQL output: COALESCE(CAST(VERSION() AS CHARACTER(10000)), ' ') |
| 479 | PostgreSQL scope: VERSION() |
| 480 | |
| 481 | Oracle input: banner |
| 482 | Oracle output: NVL(CAST(banner AS VARCHAR(4000)), ' ') |
| 483 | Oracle scope: SELECT banner FROM v$version WHERE ROWNUM=1 |
| 484 | |
| 485 | Microsoft SQL Server input: @@VERSION |
| 486 | Microsoft SQL Server output: ISNULL(CAST(@@VERSION AS VARCHAR(8000)), ' ') |
| 487 | Microsoft SQL Server scope: @@VERSION |
| 488 | |
| 489 | @param field: field string to be processed |
| 490 | @type field: C{str} |
| 491 | |
| 492 | @return: field string nulled and casted |
| 493 | @rtype: C{str} |
| 494 | """ |
| 495 | |
| 496 | match = re.search(r"(?i)(.+)( AS \w+)\Z", field) |
| 497 | if match: |
| 498 | field, suffix = match.groups() |
| 499 | else: |
| 500 | suffix = "" |
| 501 | |
| 502 | nulledCastedField = field |
| 503 | |
| 504 | if field and Backend.getIdentifiedDbms(): |
| 505 | rootQuery = queries[Backend.getIdentifiedDbms()] |
| 506 | |
| 507 | if field.startswith("(CASE") or field.startswith("(IIF") or conf.noCast and not (field.startswith("COUNT(") and Backend.getIdentifiedDbms() == DBMS.MSSQL): |
| 508 | nulledCastedField = field |
| 509 | else: |
| 510 | if not (Backend.isDbms(DBMS.SQLITE) and not isDBMSVersionAtLeast('3')): |
| 511 | nulledCastedField = rootQuery.cast.query % field |
| 512 | |
| 513 | if re.search(r"COUNT\(", field) and Backend.getIdentifiedDbms() in (DBMS.RAIMA,): |
| 514 | pass |
| 515 | elif Backend.getIdentifiedDbms() in (DBMS.ACCESS, DBMS.MCKOI): |
| 516 | nulledCastedField = rootQuery.isnull.query % (nulledCastedField, nulledCastedField) |
| 517 | else: |
| 518 | nulledCastedField = rootQuery.isnull.query % nulledCastedField |
| 519 | |
| 520 | kb.binaryField = conf.binaryFields and field in conf.binaryFields |
| 521 | if conf.hexConvert or kb.binaryField: |
| 522 | nulledCastedField = self.hexConvertField(nulledCastedField) |
| 523 |
no test coverage detected