in smo/utils/templating.py [0:0]
def needs_quoting(key, for_types):
value = key
val_no_array = value
# check if the string is number or not
if isinstance(value, int):
return True
# certain types should not be quoted even though it contains a space. Evilness.
elif for_types and value[-2:] == u"[]":
val_no_array = value[:-2]
if for_types and val_no_array.lower() in [
u'bit varying',
u'"char"',
u'character varying',
u'double precision',
u'timestamp without time zone',
u'timestamp with time zone',
u'time without time zone',
u'time with time zone',
u'"trigger"',
u'"unknown"'
]:
return False
# If already quoted?, If yes then do not quote again
if for_types and val_no_array:
if val_no_array.startswith('"') \
or val_no_array.endswith('"'):
return False
if u'0' <= val_no_array[0] <= u'9':
return True
for c in val_no_array:
if (not (u'a' <= c <= u'z') and c != u'_' and
not (u'0' <= c <= u'9')):
return True
# check string is keywaord or not
category = scan_keyword_extra_lookup(value)
if category is None:
return False
# UNRESERVED_KEYWORD
if category == 0:
return False
# COL_NAME_KEYWORD
if for_types and category == 1:
return False
return True