diff --git a/django/core/db/backends/ado_mssql.py b/django/core/db/backends/ado_mssql.py index a673c4812e..480de3b074 100644 --- a/django/core/db/backends/ado_mssql.py +++ b/django/core/db/backends/ado_mssql.py @@ -111,8 +111,9 @@ def get_relations(cursor, table_name): raise NotImplementedError def quote_name(name): - # TODO: Figure out how MS-SQL quotes database identifiers. - return name + if name.startswith('[') and name.endswith(']'): + return name # Quoting once is enough. + return '[%s]' % name OPERATOR_MAPPING = { 'exact': '=',