|
|
@ -36,7 +36,7 @@ class UnclosedQuoteError(SQLParseError):
|
|
|
|
# allowed to specifiy that identifier. For example, a database column can be
|
|
|
|
# allowed to specifiy that identifier. For example, a database column can be
|
|
|
|
# specified by up to 4 levels: database.schema.table.column
|
|
|
|
# specified by up to 4 levels: database.schema.table.column
|
|
|
|
_PG_IDENTIFIER_TO_DOT_LEVEL = dict(database=1, schema=2, table=3, column=4, role=1)
|
|
|
|
_PG_IDENTIFIER_TO_DOT_LEVEL = dict(database=1, schema=2, table=3, column=4, role=1)
|
|
|
|
_MYSQL_IDENTIFIER_TO_DOT_LEVEL = dict(database=1, table=2, column=3, role=1)
|
|
|
|
_MYSQL_IDENTIFIER_TO_DOT_LEVEL = dict(database=1, table=2, column=3, role=1, vars=1)
|
|
|
|
|
|
|
|
|
|
|
|
def _find_end_quote(identifier, quote_char='"'):
|
|
|
|
def _find_end_quote(identifier, quote_char='"'):
|
|
|
|
accumulate = 0
|
|
|
|
accumulate = 0
|
|
|
@ -116,5 +116,5 @@ def pg_quote_identifier(identifier, id_type):
|
|
|
|
def mysql_quote_identifier(identifier, id_type):
|
|
|
|
def mysql_quote_identifier(identifier, id_type):
|
|
|
|
identifier_fragments = _identifier_parse(identifier, quote_char='`')
|
|
|
|
identifier_fragments = _identifier_parse(identifier, quote_char='`')
|
|
|
|
if len(identifier_fragments) > _MYSQL_IDENTIFIER_TO_DOT_LEVEL[id_type]:
|
|
|
|
if len(identifier_fragments) > _MYSQL_IDENTIFIER_TO_DOT_LEVEL[id_type]:
|
|
|
|
raise SQLParseError('MySQL does not support %s with more than %i dots' % (id_type, _IDENTIFIER_TO_DOT_LEVEL[id_type]))
|
|
|
|
raise SQLParseError('MySQL does not support %s with more than %i dots' % (id_type, _MYSQL_IDENTIFIER_TO_DOT_LEVEL[id_type]))
|
|
|
|
return '.'.join(identifier_fragments)
|
|
|
|
return '.'.join(identifier_fragments)
|
|
|
|