Skip to content

Commit 5e00036

Browse files
author
Ilya Gurov
authored
refactor: erase strip_backticks() helper (#504)
1 parent 2bae03f commit 5e00036

2 files changed

Lines changed: 1 addition & 21 deletions

File tree

packages/django-google-spanner/google/cloud/spanner_dbapi/parse_utils.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,6 @@ def classify_stmt(sql):
6868
)
6969

7070

71-
def strip_backticks(name):
72-
"""
73-
Strip backticks off of quoted names For example, '`no`' (a Spanner reserved
74-
word) becomes 'no'.
75-
"""
76-
has_quotes = name.startswith("`") and name.endswith("`")
77-
return name[1:-1] if has_quotes else name
78-
79-
8071
def parse_insert(insert_sql, params):
8172
"""
8273
Parse an INSERT statement an generate a list of tuples of the form:
@@ -169,10 +160,7 @@ def parse_insert(insert_sql, params):
169160
if values.homogenous():
170161
# Case c)
171162

172-
columns = [
173-
strip_backticks(mi.strip())
174-
for mi in match.group("columns").split(",")
175-
]
163+
columns = [mi.strip(" `") for mi in match.group("columns").split(",")]
176164
sql_params_list = []
177165
insert_sql_preamble = "INSERT INTO %s (%s) VALUES %s" % (
178166
match.group("table_name"),

packages/django-google-spanner/tests/spanner_dbapi/test_parse_utils.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
parse_insert,
2323
rows_for_insert_or_update,
2424
sql_pyformat_args_to_spanner,
25-
strip_backticks,
2625
)
2726
from google.cloud.spanner_dbapi.utils import backtick_unicode
2827

@@ -491,13 +490,6 @@ def test_escape_name(self):
491490
got = escape_name(name)
492491
self.assertEqual(got, want)
493492

494-
def test_strip_backticks(self):
495-
cases = [("foo", "foo"), ("`foo`", "foo")]
496-
for name, want in cases:
497-
with self.subTest(name=name):
498-
got = strip_backticks(name)
499-
self.assertEqual(got, want)
500-
501493
def test_backtick_unicode(self):
502494
cases = [
503495
("SELECT (1) as foo WHERE 1=1", "SELECT (1) as foo WHERE 1=1"),

0 commit comments

Comments
 (0)