CHANGES
=======
+0.4.0beta7
+----------
+
+- The IdentifierPreprarer's _requires_quotes test is now regex based. Any
+ out-of-tree dialects that provide custom sets of legal_characters or
+ illegal_initial_characters will need to move to regexes or override
+ _requires_quotes.
+
0.4.0beta6
----------
'then', 'to', 'trailing', 'true', 'union', 'unique', 'user',
'using', 'verbose', 'when', 'where'])
-LEGAL_CHARACTERS = util.Set(string.ascii_lowercase +
- string.ascii_uppercase +
- string.digits + '_$')
-ILLEGAL_INITIAL_CHARACTERS = util.Set(string.digits + '$')
+LEGAL_CHARACTERS = re.compile(r'^[A-Z0-9_$]+$', re.I)
+ILLEGAL_INITIAL_CHARACTERS = re.compile(r'[0-9$]')
BIND_PARAMS = re.compile(r'(?<![:\w\$\x5c]):([\w\$]+)(?![:\w\$])', re.UNICODE)
BIND_PARAMS_ESC = re.compile(r'\x5c(:[\w\$]+)(?![:\w\$])', re.UNICODE)
def _requires_quotes(self, value):
"""Return True if the given identifier requires quoting."""
- return \
- value in self.reserved_words \
- or (value[0] in self.illegal_initial_characters) \
- or bool(len([x for x in unicode(value) if x not in self.legal_characters])) \
- or (value.lower() != value)
+ lc_value = value.lower()
+ return (lc_value in self.reserved_words
+ or self.illegal_initial_characters.match(value[0])
+ or not self.legal_characters.match(unicode(value))
+ or (lc_value != value))
def __generic_obj_format(self, obj, ident):
if getattr(obj, 'quote', False):
ticks = fullobject(Animal.select(Animal.c.Species=='Tick'))
@testing.supported('postgres')
- @profiling.profiled('expressions', call_range=(13210, 13230), always=True)
+ @profiling.profiled('expressions', call_range=(12595, 12605), always=True)
def test_4_expressions(self):
Zoo = metadata.tables['Zoo']
Animal = metadata.tables['Animal']
assert len(fulltable(Animal.select(func.date_part('day', Animal.c.LastEscape) == 21))) == 1
@testing.supported('postgres')
- @profiling.profiled('aggregates', call_range=(1260, 1270), always=True)
+ @profiling.profiled('aggregates', call_range=(1220, 1230), always=True)
def test_5_aggregates(self):
Animal = metadata.tables['Animal']
Zoo = metadata.tables['Zoo']
assert SDZ['Founded'] == datetime.date(1935, 9, 13)
@testing.supported('postgres')
- @profiling.profiled('multiview', call_range=(3150, 3160), always=True)
+ @profiling.profiled('multiview', call_range=(3090, 3100), always=True)
def test_7_multiview(self):
Zoo = metadata.tables['Zoo']
Animal = metadata.tables['Animal']