File tree 1 file changed +14
-0
lines changed
google/cloud/sqlalchemy_spanner
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 17
17
from sqlalchemy import types , ForeignKeyConstraint
18
18
from sqlalchemy .engine .base import Engine
19
19
from sqlalchemy .engine .default import DefaultDialect
20
+ from sqlalchemy import util
20
21
from sqlalchemy .sql .compiler import (
21
22
selectable ,
22
23
DDLCompiler ,
@@ -103,6 +104,19 @@ def __init__(self, dialect):
103
104
dialect , initial_quote = "`" , final_quote = "`"
104
105
)
105
106
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
+
106
120
107
121
class SpannerSQLCompiler (SQLCompiler ):
108
122
"""Spanner SQL statements compiler."""
You can’t perform that action at this time.
0 commit comments