Repository: madlib
Updated Branches:
  refs/heads/master aa18c0a3b -> 0490ea779


Utilities: Use plpy.quote_ident if available


Project: http://git-wip-us.apache.org/repos/asf/madlib/repo
Commit: http://git-wip-us.apache.org/repos/asf/madlib/commit/0490ea77
Tree: http://git-wip-us.apache.org/repos/asf/madlib/tree/0490ea77
Diff: http://git-wip-us.apache.org/repos/asf/madlib/diff/0490ea77

Branch: refs/heads/master
Commit: 0490ea77911c33c941a59352ac5a3568f968b186
Parents: aa18c0a
Author: Rahul Iyer <[email protected]>
Authored: Mon Aug 13 15:45:31 2018 -0700
Committer: Rahul Iyer <[email protected]>
Committed: Mon Aug 13 15:45:31 2018 -0700

----------------------------------------------------------------------
 .../modules/utilities/validate_args.py_in       | 28 +++++++++++---------
 1 file changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/madlib/blob/0490ea77/src/ports/postgres/modules/utilities/validate_args.py_in
----------------------------------------------------------------------
diff --git a/src/ports/postgres/modules/utilities/validate_args.py_in 
b/src/ports/postgres/modules/utilities/validate_args.py_in
index f7f79e9..28e6aa4 100644
--- a/src/ports/postgres/modules/utilities/validate_args.py_in
+++ b/src/ports/postgres/modules/utilities/validate_args.py_in
@@ -72,19 +72,21 @@ def quote_ident(input_str):
     Returns:
         String
     """
-
-    def quote_not_needed(ch):
-        return (ch in string.ascii_lowercase or ch in string.digits or ch == 
'_')
-
-    if input_str:
-        input_str = input_str.strip()
-        if all(quote_not_needed(c) for c in input_str):
-            return input_str
-        else:
-            # if input_str has double quotes then each double quote
-            # is prependend with a double quote
-            # (the 1st double quote is used to escape the 2nd double quote)
-            return '"' + re.sub(r'"', r'""', input_str) + '"'
+    try:
+        return plpy.quote_ident(input_str)
+    except AttributeError:
+        def quote_not_needed(ch):
+            return (ch in string.ascii_lowercase or ch in string.digits or ch 
== '_')
+
+        if input_str:
+            input_str = input_str.strip()
+            if all(quote_not_needed(c) for c in input_str):
+                return input_str
+            else:
+                # if input_str has double quotes then each double quote
+                # is prependend with a double quote
+                # (the 1st double quote is used to escape the 2nd double quote)
+                return '"' + re.sub(r'"', r'""', input_str) + '"'
 # -------------------------------------------------------------------------
 
 

Reply via email to