mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
magic-removal: Fixed #1373 -- Factored out database-specific 'DROP CONSTRAINT' syntax, to get sqlreset/sqlclear working with MySQL. Thanks, njharman
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2732 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
c551eac5e4
commit
121c9c9692
@ -290,7 +290,7 @@ def get_sql_delete(app):
|
|||||||
output.append('%s %s %s %s;' % \
|
output.append('%s %s %s %s;' % \
|
||||||
(style.SQL_KEYWORD('ALTER TABLE'),
|
(style.SQL_KEYWORD('ALTER TABLE'),
|
||||||
style.SQL_TABLE(backend.quote_name(table)),
|
style.SQL_TABLE(backend.quote_name(table)),
|
||||||
style.SQL_KEYWORD('DROP CONSTRAINT'),
|
style.SQL_KEYWORD(backend.get_drop_foreignkey_sql()),
|
||||||
style.SQL_FIELD(backend.quote_name("%s_referencing_%s_%s" % (col, r_table, r_col)))))
|
style.SQL_FIELD(backend.quote_name("%s_referencing_%s_%s" % (col, r_table, r_col)))))
|
||||||
del references_to_delete[klass]
|
del references_to_delete[klass]
|
||||||
|
|
||||||
|
@ -121,6 +121,9 @@ def get_limit_offset_sql(limit, offset=None):
|
|||||||
def get_random_function_sql():
|
def get_random_function_sql():
|
||||||
return "RAND()"
|
return "RAND()"
|
||||||
|
|
||||||
|
def get_drop_foreignkey_sql():
|
||||||
|
return "DROP CONSTRAINT"
|
||||||
|
|
||||||
OPERATOR_MAPPING = {
|
OPERATOR_MAPPING = {
|
||||||
'exact': '= %s',
|
'exact': '= %s',
|
||||||
'iexact': 'LIKE %s',
|
'iexact': 'LIKE %s',
|
||||||
|
@ -33,4 +33,5 @@ get_date_extract_sql = complain
|
|||||||
get_date_trunc_sql = complain
|
get_date_trunc_sql = complain
|
||||||
get_limit_offset_sql = complain
|
get_limit_offset_sql = complain
|
||||||
get_random_function_sql = complain
|
get_random_function_sql = complain
|
||||||
|
get_drop_foreignkey_sql = complain
|
||||||
OPERATOR_MAPPING = {}
|
OPERATOR_MAPPING = {}
|
||||||
|
@ -146,6 +146,9 @@ def get_limit_offset_sql(limit, offset=None):
|
|||||||
def get_random_function_sql():
|
def get_random_function_sql():
|
||||||
return "RAND()"
|
return "RAND()"
|
||||||
|
|
||||||
|
def get_drop_foreignkey_sql():
|
||||||
|
return "DROP FOREIGN KEY"
|
||||||
|
|
||||||
OPERATOR_MAPPING = {
|
OPERATOR_MAPPING = {
|
||||||
'exact': '= %s',
|
'exact': '= %s',
|
||||||
'iexact': 'LIKE %s',
|
'iexact': 'LIKE %s',
|
||||||
|
@ -98,6 +98,9 @@ def get_limit_offset_sql(limit, offset=None):
|
|||||||
def get_random_function_sql():
|
def get_random_function_sql():
|
||||||
return "RANDOM()"
|
return "RANDOM()"
|
||||||
|
|
||||||
|
def get_drop_foreignkey_sql():
|
||||||
|
return "DROP CONSTRAINT"
|
||||||
|
|
||||||
# Register these custom typecasts, because Django expects dates/times to be
|
# Register these custom typecasts, because Django expects dates/times to be
|
||||||
# in Python's native (standard-library) datetime/time format, whereas psycopg
|
# in Python's native (standard-library) datetime/time format, whereas psycopg
|
||||||
# use mx.DateTime by default.
|
# use mx.DateTime by default.
|
||||||
|
@ -116,6 +116,9 @@ def get_limit_offset_sql(limit, offset=None):
|
|||||||
def get_random_function_sql():
|
def get_random_function_sql():
|
||||||
return "RANDOM()"
|
return "RANDOM()"
|
||||||
|
|
||||||
|
def get_drop_foreignkey_sql():
|
||||||
|
return ""
|
||||||
|
|
||||||
def _sqlite_date_trunc(lookup_type, dt):
|
def _sqlite_date_trunc(lookup_type, dt):
|
||||||
try:
|
try:
|
||||||
dt = util.typecast_timestamp(dt)
|
dt = util.typecast_timestamp(dt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user