Refactored get_pk_default_value() to DatabaseOperations.pk_default_value(). Refs #5106
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5961 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
e4b7e369dd
commit
aaf8760227
|
@ -126,3 +126,10 @@ class BaseDatabaseOperations(object):
|
|||
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'
|
||||
|
|
|
@ -103,9 +103,6 @@ dictfetchall = util.dictfetchall
|
|||
def get_random_function_sql():
|
||||
return "RAND()"
|
||||
|
||||
def get_pk_default_value():
|
||||
return "DEFAULT"
|
||||
|
||||
def get_start_transaction_sql():
|
||||
return "BEGIN;"
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ dictfetchone = complain
|
|||
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
|
||||
|
|
|
@ -165,9 +165,6 @@ dictfetchall = util.dictfetchall
|
|||
def get_random_function_sql():
|
||||
return "RAND()"
|
||||
|
||||
def get_pk_default_value():
|
||||
return "DEFAULT"
|
||||
|
||||
def get_start_transaction_sql():
|
||||
return "BEGIN;"
|
||||
|
||||
|
|
|
@ -184,9 +184,6 @@ dictfetchall = util.dictfetchall
|
|||
def get_random_function_sql():
|
||||
return "RAND()"
|
||||
|
||||
def get_pk_default_value():
|
||||
return "DEFAULT"
|
||||
|
||||
def get_start_transaction_sql():
|
||||
return "BEGIN;"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;"
|
||||
|
||||
|
|
|
@ -88,9 +88,6 @@ dictfetchall = util.dictfetchall
|
|||
def get_random_function_sql():
|
||||
return "RANDOM()"
|
||||
|
||||
def get_pk_default_value():
|
||||
return "DEFAULT"
|
||||
|
||||
def get_start_transaction_sql():
|
||||
return "BEGIN;"
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|||
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;"
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ class Model(object):
|
|||
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()
|
||||
|
|
Loading…
Reference in New Issue