5151 re .DOTALL ,
5252)
5353
54+ RE_PYFORMAT = re .compile (r"(%s|%\([^\(\)]+\)s)+" , re .DOTALL )
55+
5456
5557def classify_stmt (query ):
5658 """Determine SQL query type.
@@ -75,15 +77,6 @@ def classify_stmt(query):
7577 return STMT_UPDATING
7678
7779
78- def strip_backticks (name ):
79- """
80- Strip backticks off of quoted names For example, '`no`' (a Spanner reserved
81- word) becomes 'no'.
82- """
83- has_quotes = name .startswith ("`" ) and name .endswith ("`" )
84- return name [1 :- 1 ] if has_quotes else name
85-
86-
8780def parse_insert (insert_sql , params ):
8881 """
8982 Parse an INSERT statement an generate a list of tuples of the form:
@@ -309,9 +302,6 @@ def rows_for_insert_or_update(columns, params, pyformat_args=None):
309302 return strides
310303
311304
312- re_PYFORMAT = re .compile (r"(%s|%\([^\(\)]+\)s)+" , re .DOTALL )
313-
314-
315305def sql_pyformat_args_to_spanner (sql , params ):
316306 """
317307 Transform pyformat set SQL to named arguments for Cloud Spanner.
@@ -334,7 +324,7 @@ def sql_pyformat_args_to_spanner(sql, params):
334324 if not params :
335325 return sanitize_literals_for_upload (sql ), params
336326
337- found_pyformat_placeholders = re_PYFORMAT .findall (sql )
327+ found_pyformat_placeholders = RE_PYFORMAT .findall (sql )
338328 params_is_dict = isinstance (params , dict )
339329
340330 if params_is_dict :
@@ -350,9 +340,6 @@ def sql_pyformat_args_to_spanner(sql, params):
350340 % (n_matches , found_pyformat_placeholders , n_params , params )
351341 )
352342
353- if len (params ) == 0 :
354- return sanitize_literals_for_upload (sql ), params
355-
356343 named_args = {}
357344 # We've now got for example:
358345 # Case a) Params is a non-dict
0 commit comments