Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refactored get_pk_default_value() to DatabaseOperations.pk_default_va…

…lue(). Refs #5106

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5961 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit aaf87602272c768d4d50d5e9a27f06f4b19164dd 1 parent e4b7e36
Adrian Holovaty authored August 19, 2007
7  django/db/backends/__init__.py
@@ -126,3 +126,10 @@ def max_name_length(self):
126 126
         is no limit.
127 127
         """
128 128
         return None
  129
+
  130
+    def pk_default_value(self):
  131
+        """
  132
+        Returns the value to use during an INSERT statement to specify that
  133
+        the field should use its default value.
  134
+        """
  135
+        return 'DEFAULT'
3  django/db/backends/ado_mssql/base.py
@@ -103,9 +103,6 @@ def quote_name(name):
103 103
 def get_random_function_sql():
104 104
     return "RAND()"
105 105
 
106  
-def get_pk_default_value():
107  
-    return "DEFAULT"
108  
-
109 106
 def get_start_transaction_sql():
110 107
     return "BEGIN;"
111 108
 
1  django/db/backends/dummy/base.py
@@ -44,7 +44,6 @@ def close(self):
44 44
 dictfetchmany = complain
45 45
 dictfetchall = complain
46 46
 get_random_function_sql = complain
47  
-get_pk_default_value = complain
48 47
 get_start_transaction_sql = complain
49 48
 get_sql_flush = complain
50 49
 get_sql_sequence_reset = complain
3  django/db/backends/mysql/base.py
@@ -165,9 +165,6 @@ def quote_name(name):
165 165
 def get_random_function_sql():
166 166
     return "RAND()"
167 167
 
168  
-def get_pk_default_value():
169  
-    return "DEFAULT"
170  
-
171 168
 def get_start_transaction_sql():
172 169
     return "BEGIN;"
173 170
 
3  django/db/backends/mysql_old/base.py
@@ -184,9 +184,6 @@ def quote_name(name):
184 184
 def get_random_function_sql():
185 185
     return "RAND()"
186 186
 
187  
-def get_pk_default_value():
188  
-    return "DEFAULT"
189  
-
190 187
 def get_start_transaction_sql():
191 188
     return "BEGIN;"
192 189
 
3  django/db/backends/oracle/base.py
@@ -189,9 +189,6 @@ def get_field_cast_sql(db_type):
189 189
 def get_random_function_sql():
190 190
     return "DBMS_RANDOM.RANDOM"
191 191
 
192  
-def get_pk_default_value():
193  
-    return "DEFAULT"
194  
-
195 192
 def get_start_transaction_sql():
196 193
     return None
197 194
 
3  django/db/backends/postgresql/base.py
@@ -134,9 +134,6 @@ def dictfetchall(cursor):
134 134
 def get_random_function_sql():
135 135
     return "RANDOM()"
136 136
 
137  
-def get_pk_default_value():
138  
-    return "DEFAULT"
139  
-
140 137
 def get_start_transaction_sql():
141 138
     return "BEGIN;"
142 139
 
3  django/db/backends/postgresql_psycopg2/base.py
@@ -88,9 +88,6 @@ def quote_name(name):
88 88
 def get_random_function_sql():
89 89
     return "RANDOM()"
90 90
 
91  
-def get_pk_default_value():
92  
-    return "DEFAULT"
93  
-
94 91
 def get_start_transaction_sql():
95 92
     return "BEGIN;"
96 93
 
6  django/db/backends/sqlite3/base.py
@@ -48,6 +48,9 @@ def date_trunc_sql(self, lookup_type, field_name):
48 48
     def drop_foreignkey_sql(self):
49 49
         return ""
50 50
 
  51
+    def pk_default_value(self):
  52
+        return 'NULL'
  53
+
51 54
 class DatabaseWrapper(BaseDatabaseWrapper):
52 55
     ops = DatabaseOperations()
53 56
 
@@ -118,9 +121,6 @@ def _sqlite_extract(lookup_type, dt):
118 121
 def get_random_function_sql():
119 122
     return "RANDOM()"
120 123
 
121  
-def get_pk_default_value():
122  
-    return "NULL"
123  
-
124 124
 def get_start_transaction_sql():
125 125
     return "BEGIN;"
126 126
 
2  django/db/models/base.py
@@ -252,7 +252,7 @@ def save(self, raw=False):
252 252
                 cursor.execute("INSERT INTO %s (%s) VALUES (%s)" %
253 253
                     (backend.quote_name(self._meta.db_table),
254 254
                      backend.quote_name(self._meta.pk.column),
255  
-                     backend.get_pk_default_value()))
  255
+                     connection.ops.pk_default_value()))
256 256
             if self._meta.has_auto_field and not pk_set:
257 257
                 setattr(self, self._meta.pk.attname, connection.ops.last_insert_id(cursor, self._meta.db_table, self._meta.pk.column))
258 258
         transaction.commit_unless_managed()

0 notes on commit aaf8760

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