Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refactored get_start_transaction_sql() to DatabaseOperations.start_tr…

…ansaction_sql(). Refs #5106

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5965 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 13061bf20bc467c5655c2dfa280dc226a00effcd 1 parent 147e99a
Adrian Holovaty authored August 20, 2007
6  django/core/management/base.py
@@ -34,9 +34,9 @@ def execute(self, *args, **options):
34 34
             if output:
35 35
                 if self.output_transaction:
36 36
                     # This needs to be imported here, because it relies on settings.
37  
-                    from django.db import backend
38  
-                    if backend.get_start_transaction_sql():
39  
-                        print self.style.SQL_KEYWORD(backend.get_start_transaction_sql())
  37
+                    from django.db import connection
  38
+                    if connection.ops.start_transaction_sql():
  39
+                        print self.style.SQL_KEYWORD(connection.ops.start_transaction_sql())
40 40
                 print output
41 41
                 if self.output_transaction:
42 42
                     print self.style.SQL_KEYWORD("COMMIT;")
6  django/db/backends/__init__.py
@@ -160,3 +160,9 @@ def sequence_reset_sql(self, style, model_list):
160 160
         color_style() or no_style() in django.core.management.color.
161 161
         """
162 162
         return [] # No sequence reset required by default.
  163
+
  164
+    def start_transaction_sql(self):
  165
+        """
  166
+        Returns the SQL statement required to start a transaction.
  167
+        """
  168
+        return "BEGIN;"
3  django/db/backends/ado_mssql/base.py
@@ -103,9 +103,6 @@ def quote_name(name):
103 103
 dictfetchmany = util.dictfetchmany
104 104
 dictfetchall  = util.dictfetchall
105 105
 
106  
-def get_start_transaction_sql():
107  
-    return "BEGIN;"
108  
-
109 106
 def get_tablespace_sql(tablespace, inline=False):
110 107
     return "ON %s" % quote_name(tablespace)
111 108
 
1  django/db/backends/dummy/base.py
@@ -43,6 +43,5 @@ def close(self):
43 43
 dictfetchone = complain
44 44
 dictfetchmany = complain
45 45
 dictfetchall = complain
46  
-get_start_transaction_sql = complain
47 46
 
48 47
 OPERATOR_MAPPING = {}
3  django/db/backends/mysql/base.py
@@ -188,9 +188,6 @@ def quote_name(name):
188 188
 dictfetchmany = util.dictfetchmany
189 189
 dictfetchall  = util.dictfetchall
190 190
 
191  
-def get_start_transaction_sql():
192  
-    return "BEGIN;"
193  
-
194 191
 OPERATOR_MAPPING = {
195 192
     'exact': '= %s',
196 193
     'iexact': 'LIKE %s',
3  django/db/backends/mysql_old/base.py
@@ -207,9 +207,6 @@ def quote_name(name):
207 207
 dictfetchmany = util.dictfetchmany
208 208
 dictfetchall  = util.dictfetchall
209 209
 
210  
-def get_start_transaction_sql():
211  
-    return "BEGIN;"
212  
-
213 210
 OPERATOR_MAPPING = {
214 211
     'exact': '= %s',
215 212
     'iexact': 'LIKE %s',
6  django/db/backends/oracle/base.py
@@ -112,6 +112,9 @@ def sequence_reset_sql(self, style, model_list):
112 112
                                        'table':f.m2m_db_table()})
113 113
         return output
114 114
 
  115
+    def start_transaction_sql(self):
  116
+        return ''
  117
+
115 118
 class DatabaseWrapper(BaseDatabaseWrapper):
116 119
     ops = DatabaseOperations()
117 120
 
@@ -228,9 +231,6 @@ def get_field_cast_sql(db_type):
228 231
     else:
229 232
         return "%s%s"
230 233
 
231  
-def get_start_transaction_sql():
232  
-    return None
233  
-
234 234
 def get_tablespace_sql(tablespace, inline=False):
235 235
     return "%sTABLESPACE %s" % ((inline and "USING INDEX " or ""), quote_name(tablespace))
236 236
 
3  django/db/backends/postgresql/base.py
@@ -211,9 +211,6 @@ def dictfetchall(cursor):
211 211
     "Returns all rows from a cursor as a dict"
212 212
     return cursor.dictfetchall()
213 213
 
214  
-def get_start_transaction_sql():
215  
-    return "BEGIN;"
216  
-
217 214
 def typecast_string(s):
218 215
     """
219 216
     Cast all returned strings to unicode strings.
3  django/db/backends/postgresql_psycopg2/base.py
@@ -165,9 +165,6 @@ def quote_name(name):
165 165
 dictfetchmany = util.dictfetchmany
166 166
 dictfetchall = util.dictfetchall
167 167
 
168  
-def get_start_transaction_sql():
169  
-    return "BEGIN;"
170  
-
171 168
 OPERATOR_MAPPING = {
172 169
     'exact': '= %s',
173 170
     'iexact': 'ILIKE %s',
3  django/db/backends/sqlite3/base.py
@@ -131,9 +131,6 @@ def _sqlite_extract(lookup_type, dt):
131 131
         return None
132 132
     return str(getattr(dt, lookup_type))
133 133
 
134  
-def get_start_transaction_sql():
135  
-    return "BEGIN;"
136  
-
137 134
 def _sqlite_date_trunc(lookup_type, dt):
138 135
     try:
139 136
         dt = util.typecast_timestamp(dt)

0 notes on commit 13061bf

Please sign in to comment.
Something went wrong with that request. Please try again.