Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
@adrianholovaty adrianholovaty authored
View
7 django/db/backends/__init__.py
@@ -126,3 +126,10 @@ def max_name_length(self):
is no limit.
"""
return None
+
+ def pk_default_value(self):
+ """
+ Returns the value to use during an INSERT statement to specify that
+ the field should use its default value.
+ """
+ return 'DEFAULT'
View
3  django/db/backends/ado_mssql/base.py
@@ -103,9 +103,6 @@ def quote_name(name):
def get_random_function_sql():
return "RAND()"
-def get_pk_default_value():
- return "DEFAULT"
-
def get_start_transaction_sql():
return "BEGIN;"
View
1  django/db/backends/dummy/base.py
@@ -44,7 +44,6 @@ def close(self):
dictfetchmany = complain
dictfetchall = complain
get_random_function_sql = complain
-get_pk_default_value = complain
get_start_transaction_sql = complain
get_sql_flush = complain
get_sql_sequence_reset = complain
View
3  django/db/backends/mysql/base.py
@@ -165,9 +165,6 @@ def quote_name(name):
def get_random_function_sql():
return "RAND()"
-def get_pk_default_value():
- return "DEFAULT"
-
def get_start_transaction_sql():
return "BEGIN;"
View
3  django/db/backends/mysql_old/base.py
@@ -184,9 +184,6 @@ def quote_name(name):
def get_random_function_sql():
return "RAND()"
-def get_pk_default_value():
- return "DEFAULT"
-
def get_start_transaction_sql():
return "BEGIN;"
View
3  django/db/backends/oracle/base.py
@@ -189,9 +189,6 @@ def get_field_cast_sql(db_type):
def get_random_function_sql():
return "DBMS_RANDOM.RANDOM"
-def get_pk_default_value():
- return "DEFAULT"
-
def get_start_transaction_sql():
return None
View
3  django/db/backends/postgresql/base.py
@@ -134,9 +134,6 @@ def dictfetchall(cursor):
def get_random_function_sql():
return "RANDOM()"
-def get_pk_default_value():
- return "DEFAULT"
-
def get_start_transaction_sql():
return "BEGIN;"
View
3  django/db/backends/postgresql_psycopg2/base.py
@@ -88,9 +88,6 @@ def quote_name(name):
def get_random_function_sql():
return "RANDOM()"
-def get_pk_default_value():
- return "DEFAULT"
-
def get_start_transaction_sql():
return "BEGIN;"
View
6 django/db/backends/sqlite3/base.py
@@ -48,6 +48,9 @@ def date_trunc_sql(self, lookup_type, field_name):
def drop_foreignkey_sql(self):
return ""
+ def pk_default_value(self):
+ return 'NULL'
+
class DatabaseWrapper(BaseDatabaseWrapper):
ops = DatabaseOperations()
@@ -118,9 +121,6 @@ def _sqlite_extract(lookup_type, dt):
def get_random_function_sql():
return "RANDOM()"
-def get_pk_default_value():
- return "NULL"
-
def get_start_transaction_sql():
return "BEGIN;"
View
2  django/db/models/base.py
@@ -252,7 +252,7 @@ def save(self, raw=False):
cursor.execute("INSERT INTO %s (%s) VALUES (%s)" %
(backend.quote_name(self._meta.db_table),
backend.quote_name(self._meta.pk.column),
- backend.get_pk_default_value()))
+ connection.ops.pk_default_value()))
if self._meta.has_auto_field and not pk_set:
setattr(self, self._meta.pk.attname, connection.ops.last_insert_id(cursor, self._meta.db_table, self._meta.pk.column))
transaction.commit_unless_managed()
Please sign in to comment.
Something went wrong with that request. Please try again.