Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved db.quote_name from a model-level function to a method of Databa…

…seWrapper for all database backends, so quote_name will be accessible in a 'from django.core.db import db' context

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1213 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 3273c981f8d370ce6ccc6cbd8a20fea4f9d64de0 1 parent 29bdbc3
@adrianholovaty adrianholovaty authored
View
1  django/core/db/__init__.py
@@ -36,7 +36,6 @@
get_random_function_sql = dbmod.get_random_function_sql
get_table_list = dbmod.get_table_list
get_relations = dbmod.get_relations
-quote_name = dbmod.quote_name
OPERATOR_MAPPING = dbmod.OPERATOR_MAPPING
DATA_TYPES = dbmod.DATA_TYPES
DATA_TYPES_REVERSE = dbmod.DATA_TYPES_REVERSE
View
10 django/core/db/backends/ado_mssql.py
@@ -77,6 +77,11 @@ def close(self):
self.connection.close()
self.connection = None
+ def quote_name(self, name):
+ if name.startswith('[') and name.endswith(']'):
+ return name # Quoting once is enough.
+ return '[%s]' % name
+
def get_last_insert_id(cursor, table_name, pk_name):
cursor.execute("SELECT %s FROM %s WHERE %s = @@IDENTITY" % (pk_name, table_name, pk_name))
return cursor.fetchone()[0]
@@ -110,11 +115,6 @@ def get_table_list(cursor):
def get_relations(cursor, table_name):
raise NotImplementedError
-def quote_name(name):
- if name.startswith('[') and name.endswith(']'):
- return name # Quoting once is enough.
- return '[%s]' % name
-
OPERATOR_MAPPING = {
'exact': '=',
'iexact': 'LIKE',
View
10 django/core/db/backends/mysql.py
@@ -84,6 +84,11 @@ def close(self):
self.connection.close()
self.connection = None
+ def quote_name(self, name):
+ if name.startswith("`") and name.endswith("`"):
+ return name # Quoting once is enough.
+ return "`%s`" % name
+
def get_last_insert_id(cursor, table_name, pk_name):
cursor.execute("SELECT LAST_INSERT_ID()")
return cursor.fetchone()[0]
@@ -122,11 +127,6 @@ def get_table_list(cursor):
def get_relations(cursor, table_name):
raise NotImplementedError
-def quote_name(name):
- if name.startswith("`") and name.endswith("`"):
- return name # Quoting once is enough.
- return "`%s`" % name
-
OPERATOR_MAPPING = {
'exact': '=',
'iexact': 'LIKE',
View
10 django/core/db/backends/postgresql.py
@@ -49,6 +49,11 @@ def close(self):
self.connection.close()
self.connection = None
+ def quote_name(self, name):
+ if name.startswith('"') and name.endswith('"'):
+ return name # Quoting once is enough.
+ return '"%s"' % name
+
def dictfetchone(cursor):
"Returns a row from the cursor as a dict"
return cursor.dictfetchone()
@@ -116,11 +121,6 @@ def get_relations(cursor, table_name):
continue
return relations
-def quote_name(name):
- if name.startswith('"') and name.endswith('"'):
- return name # Quoting once is enough.
- return '"%s"' % name
-
# Register these custom typecasts, because Django expects dates/times to be
# in Python's native (standard-library) datetime/time format, whereas psycopg
# use mx.DateTime by default.
View
10 django/core/db/backends/sqlite3.py
@@ -55,6 +55,11 @@ def close(self):
self.connection.close()
self.connection = None
+ def quote_name(self, name):
+ if name.startswith('"') and name.endswith('"'):
+ return name # Quoting once is enough.
+ return '"%s"' % name
+
class SQLiteCursorWrapper(Database.Cursor):
"""
Django uses "format" style placeholders, but pysqlite2 uses "qmark" style.
@@ -124,11 +129,6 @@ def get_table_list(cursor):
def get_relations(cursor, table_name):
raise NotImplementedError
-def quote_name(name):
- if name.startswith('"') and name.endswith('"'):
- return name # Quoting once is enough.
- return '"%s"' % name
-
# Operators and fields ########################################################
OPERATOR_MAPPING = {
Please sign in to comment.
Something went wrong with that request. Please try again.