Skip to content

Commit ec38b40

Browse files
author
Ilya Gurov
authored
fix: don't escape collation name (#60)
1 parent a27fb43 commit ec38b40

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from sqlalchemy import types, ForeignKeyConstraint
1818
from sqlalchemy.engine.base import Engine
1919
from sqlalchemy.engine.default import DefaultDialect
20+
from sqlalchemy import util
2021
from sqlalchemy.sql.compiler import (
2122
selectable,
2223
DDLCompiler,
@@ -103,6 +104,19 @@ def __init__(self, dialect):
103104
dialect, initial_quote="`", final_quote="`"
104105
)
105106

107+
def _requires_quotes(self, value):
108+
"""Return True if the given identifier requires quoting."""
109+
lc_value = value.lower()
110+
if lc_value == '"unicode"': # don't escape default Spanner colation
111+
return False
112+
113+
return (
114+
lc_value in self.reserved_words
115+
or value[0] in self.illegal_initial_characters
116+
or not self.legal_characters.match(util.text_type(value))
117+
or (lc_value != value)
118+
)
119+
106120

107121
class SpannerSQLCompiler(SQLCompiler):
108122
"""Spanner SQL statements compiler."""

0 commit comments

Comments
 (0)