Refactored get_start_transaction_sql() to DatabaseOperations.start_transaction_sql(). Refs #5106
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5965 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
147e99a08a
commit
13061bf20b
|
@ -34,9 +34,9 @@ class BaseCommand(object):
|
|||
if output:
|
||||
if self.output_transaction:
|
||||
# This needs to be imported here, because it relies on settings.
|
||||
from django.db import backend
|
||||
if backend.get_start_transaction_sql():
|
||||
print self.style.SQL_KEYWORD(backend.get_start_transaction_sql())
|
||||
from django.db import connection
|
||||
if connection.ops.start_transaction_sql():
|
||||
print self.style.SQL_KEYWORD(connection.ops.start_transaction_sql())
|
||||
print output
|
||||
if self.output_transaction:
|
||||
print self.style.SQL_KEYWORD("COMMIT;")
|
||||
|
|
|
@ -160,3 +160,9 @@ class BaseDatabaseOperations(object):
|
|||
color_style() or no_style() in django.core.management.color.
|
||||
"""
|
||||
return [] # No sequence reset required by default.
|
||||
|
||||
def start_transaction_sql(self):
|
||||
"""
|
||||
Returns the SQL statement required to start a transaction.
|
||||
"""
|
||||
return "BEGIN;"
|
||||
|
|
|
@ -103,9 +103,6 @@ dictfetchone = util.dictfetchone
|
|||
dictfetchmany = util.dictfetchmany
|
||||
dictfetchall = util.dictfetchall
|
||||
|
||||
def get_start_transaction_sql():
|
||||
return "BEGIN;"
|
||||
|
||||
def get_tablespace_sql(tablespace, inline=False):
|
||||
return "ON %s" % quote_name(tablespace)
|
||||
|
||||
|
|
|
@ -43,6 +43,5 @@ quote_name = complain
|
|||
dictfetchone = complain
|
||||
dictfetchmany = complain
|
||||
dictfetchall = complain
|
||||
get_start_transaction_sql = complain
|
||||
|
||||
OPERATOR_MAPPING = {}
|
||||
|
|
|
@ -188,9 +188,6 @@ dictfetchone = util.dictfetchone
|
|||
dictfetchmany = util.dictfetchmany
|
||||
dictfetchall = util.dictfetchall
|
||||
|
||||
def get_start_transaction_sql():
|
||||
return "BEGIN;"
|
||||
|
||||
OPERATOR_MAPPING = {
|
||||
'exact': '= %s',
|
||||
'iexact': 'LIKE %s',
|
||||
|
|
|
@ -207,9 +207,6 @@ dictfetchone = util.dictfetchone
|
|||
dictfetchmany = util.dictfetchmany
|
||||
dictfetchall = util.dictfetchall
|
||||
|
||||
def get_start_transaction_sql():
|
||||
return "BEGIN;"
|
||||
|
||||
OPERATOR_MAPPING = {
|
||||
'exact': '= %s',
|
||||
'iexact': 'LIKE %s',
|
||||
|
|
|
@ -112,6 +112,9 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|||
'table':f.m2m_db_table()})
|
||||
return output
|
||||
|
||||
def start_transaction_sql(self):
|
||||
return ''
|
||||
|
||||
class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
ops = DatabaseOperations()
|
||||
|
||||
|
@ -228,9 +231,6 @@ def get_field_cast_sql(db_type):
|
|||
else:
|
||||
return "%s%s"
|
||||
|
||||
def get_start_transaction_sql():
|
||||
return None
|
||||
|
||||
def get_tablespace_sql(tablespace, inline=False):
|
||||
return "%sTABLESPACE %s" % ((inline and "USING INDEX " or ""), quote_name(tablespace))
|
||||
|
||||
|
|
|
@ -211,9 +211,6 @@ def dictfetchall(cursor):
|
|||
"Returns all rows from a cursor as a dict"
|
||||
return cursor.dictfetchall()
|
||||
|
||||
def get_start_transaction_sql():
|
||||
return "BEGIN;"
|
||||
|
||||
def typecast_string(s):
|
||||
"""
|
||||
Cast all returned strings to unicode strings.
|
||||
|
|
|
@ -165,9 +165,6 @@ dictfetchone = util.dictfetchone
|
|||
dictfetchmany = util.dictfetchmany
|
||||
dictfetchall = util.dictfetchall
|
||||
|
||||
def get_start_transaction_sql():
|
||||
return "BEGIN;"
|
||||
|
||||
OPERATOR_MAPPING = {
|
||||
'exact': '= %s',
|
||||
'iexact': 'ILIKE %s',
|
||||
|
|
|
@ -131,9 +131,6 @@ def _sqlite_extract(lookup_type, dt):
|
|||
return None
|
||||
return str(getattr(dt, lookup_type))
|
||||
|
||||
def get_start_transaction_sql():
|
||||
return "BEGIN;"
|
||||
|
||||
def _sqlite_date_trunc(lookup_type, dt):
|
||||
try:
|
||||
dt = util.typecast_timestamp(dt)
|
||||
|
|
Loading…
Reference in New Issue