>>> from lib.core.common import Backend >>> Backend.setVersion('12.10') ['12.10'] >>> Syntax.escape("SELECT 'abcdefgh' FROM foobar") == "SELECT CHR(97)||CHR(98)||CHR(99)||CHR(100)||CHR(101)||CHR(102)||CHR(103)||CHR(104) FROM foobar" True
(expression, quote=True)
| 15 | class Syntax(GenericSyntax): |
| 16 | @staticmethod |
| 17 | def escape(expression, quote=True): |
| 18 | """ |
| 19 | >>> from lib.core.common import Backend |
| 20 | >>> Backend.setVersion('12.10') |
| 21 | ['12.10'] |
| 22 | >>> Syntax.escape("SELECT 'abcdefgh' FROM foobar") == "SELECT CHR(97)||CHR(98)||CHR(99)||CHR(100)||CHR(101)||CHR(102)||CHR(103)||CHR(104) FROM foobar" |
| 23 | True |
| 24 | """ |
| 25 | |
| 26 | def escaper(value): |
| 27 | return "||".join("CHR(%d)" % _ for _ in getOrds(value)) |
| 28 | |
| 29 | retVal = expression |
| 30 | |
| 31 | if isDBMSVersionAtLeast("11.70"): |
| 32 | excluded = {} |
| 33 | for _ in re.findall(r"DBINFO\([^)]+\)", expression): |
| 34 | excluded[_] = randomStr() |
| 35 | expression = expression.replace(_, excluded[_]) |
| 36 | |
| 37 | retVal = Syntax._escape(expression, quote, escaper) |
| 38 | |
| 39 | for _ in excluded.items(): |
| 40 | retVal = retVal.replace(_[1], _[0]) |
| 41 | |
| 42 | return retVal |
nothing calls this directly
no test coverage detected