>>> from lib.core.common import Backend >>> Backend.setVersion('2.0') ['2.0'] >>> Syntax.escape("SELECT 'abcdefgh' FROM foobar") == "SELECT 'abcdefgh' FROM foobar" True >>> Backend.setVersion('2.1') ['2.1'] >>> Syntax.escape("SELECT 'a
(expression, quote=True)
| 12 | class Syntax(GenericSyntax): |
| 13 | @staticmethod |
| 14 | def escape(expression, quote=True): |
| 15 | """ |
| 16 | >>> from lib.core.common import Backend |
| 17 | >>> Backend.setVersion('2.0') |
| 18 | ['2.0'] |
| 19 | >>> Syntax.escape("SELECT 'abcdefgh' FROM foobar") == "SELECT 'abcdefgh' FROM foobar" |
| 20 | True |
| 21 | >>> Backend.setVersion('2.1') |
| 22 | ['2.1'] |
| 23 | >>> Syntax.escape("SELECT 'abcdefgh' FROM foobar") == "SELECT ASCII_CHAR(97)||ASCII_CHAR(98)||ASCII_CHAR(99)||ASCII_CHAR(100)||ASCII_CHAR(101)||ASCII_CHAR(102)||ASCII_CHAR(103)||ASCII_CHAR(104) FROM foobar" |
| 24 | True |
| 25 | """ |
| 26 | |
| 27 | def escaper(value): |
| 28 | return "||".join("ASCII_CHAR(%d)" % _ for _ in getOrds(value)) |
| 29 | |
| 30 | retVal = expression |
| 31 | |
| 32 | if isDBMSVersionAtLeast("2.1"): |
| 33 | retVal = Syntax._escape(expression, quote, escaper) |
| 34 | |
| 35 | return retVal |
nothing calls this directly
no test coverage detected