diff options
author | Marko Kreen | 2008-03-12 12:50:56 +0000 |
---|---|---|
committer | Marko Kreen | 2008-03-12 12:50:56 +0000 |
commit | 9f3bb6204dabb8c7c45a57f97b843adc4a14bacd (patch) | |
tree | 14f0379b9c1d4bc10ddfee954715c4bc41fdc60a | |
parent | c73f2559e3a26c31ff1d82b2f55b892e22fcf532 (diff) |
slight comments cleanup
-rw-r--r-- | python/modules/cquoting.c | 8 | ||||
-rw-r--r-- | python/skytools/_pyquoting.py | 14 |
2 files changed, 14 insertions, 8 deletions
diff --git a/python/modules/cquoting.c b/python/modules/cquoting.c index a929233d..2dcfc227 100644 --- a/python/modules/cquoting.c +++ b/python/modules/cquoting.c @@ -304,8 +304,12 @@ static PyObject *quote_bytea_raw(PyObject *self, PyObject *args) /* SQL unquote */ static const char doc_unquote_literal[] = -"Unquote SQL quoted string.\n\n" -"C implementation."; +"Unquote SQL value.\n\n" +"E'..' -> extended quoting.\n" +"'..' -> standard or extended quoting\n" +"null -> None\n" +"other -> returned as-is\n\n" +"C implementation.\n"; static PyObject *do_sql_ext(unsigned char *src, Py_ssize_t src_len) { diff --git a/python/skytools/_pyquoting.py b/python/skytools/_pyquoting.py index 1b143953..32d548ff 100644 --- a/python/skytools/_pyquoting.py +++ b/python/skytools/_pyquoting.py @@ -20,8 +20,9 @@ __all__ = [ def quote_literal(s): """Quote a literal value for SQL. - If string contains '\\', it is quoted and result is prefixed with E. - Input value of None results in string "null" without quotes. + If string contains '\\', extended E'' quoting is used, + otherwise standard quoting. Input value of None results + in string "null" without quotes. Python implementation. """ @@ -69,8 +70,6 @@ def quote_bytea_raw(s): else: _bytea_map[c] = c return "".join([_bytea_map[c] for c in s]) - # faster but does not match c code - #return s.replace("\\", "\\\\").replace("\0", "\\000") # # Database specific urlencode and urldecode. @@ -167,8 +166,11 @@ def _sub_unescape_sqlext(m): def unquote_literal(val, stdstr = False): """Unquotes SQL string. - Ordinary '' quoted string can be both standard and extended quoted. - E'' quoting is always taken as extended quoted. + + E'..' -> extended quoting. + '..' -> standard or extended quoting + null -> None + other -> returned as-is """ if val[0] == "'" and val[-1] == "'": if stdstr: |