diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2007-08-19 23:03:38 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2007-08-19 23:03:38 +0000 |
| commit | 8e84d35d38d429fb00a35fd4f770ade39d7772ec (patch) | |
| tree | c083bdfa7c3acccbadccb4784f62cf8c8e024ca2 /django/db | |
| parent | ed8e392f771b415fc5b5c95a770d6a3b4f59530a (diff) | |
Refactored get_deferrable_sql() to DatabaseOperations.deferrable_sql(). Refs #5106
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5955 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/backends/__init__.py | 7 | ||||
| -rw-r--r-- | django/db/backends/ado_mssql/base.py | 6 | ||||
| -rw-r--r-- | django/db/backends/dummy/base.py | 1 | ||||
| -rw-r--r-- | django/db/backends/mysql/base.py | 3 | ||||
| -rw-r--r-- | django/db/backends/mysql_old/base.py | 3 | ||||
| -rw-r--r-- | django/db/backends/oracle/base.py | 6 | ||||
| -rw-r--r-- | django/db/backends/postgresql/base.py | 6 | ||||
| -rw-r--r-- | django/db/backends/postgresql_psycopg2/base.py | 6 | ||||
| -rw-r--r-- | django/db/backends/sqlite3/base.py | 3 |
9 files changed, 19 insertions, 22 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index 41295a15b7..ea75dcf840 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -78,3 +78,10 @@ class BaseDatabaseOperations(object): method should return None if no casting is necessary. """ return None + + def deferrable_sql(self): + """ + Returns the SQL necessary to make a constraint "initially deferred" + during a CREATE TABLE statement. + """ + return '' diff --git a/django/db/backends/ado_mssql/base.py b/django/db/backends/ado_mssql/base.py index 9d72433208..f97822ebea 100644 --- a/django/db/backends/ado_mssql/base.py +++ b/django/db/backends/ado_mssql/base.py @@ -60,6 +60,9 @@ class DatabaseOperations(BaseDatabaseOperations): if lookup_type == 'day': return "Convert(datetime, Convert(varchar(12), %s))" % field_name + def deferrable_sql(self): + return " DEFERRABLE INITIALLY DEFERRED" + class DatabaseWrapper(BaseDatabaseWrapper): ops = DatabaseOperations() @@ -107,9 +110,6 @@ def get_limit_offset_sql(limit, offset=None): def get_random_function_sql(): return "RAND()" -def get_deferrable_sql(): - return " DEFERRABLE INITIALLY DEFERRED" - def get_fulltext_search_sql(field_name): raise NotImplementedError diff --git a/django/db/backends/dummy/base.py b/django/db/backends/dummy/base.py index 95650ffbf7..21a0bb6a5f 100644 --- a/django/db/backends/dummy/base.py +++ b/django/db/backends/dummy/base.py @@ -46,7 +46,6 @@ dictfetchall = complain get_last_insert_id = complain get_limit_offset_sql = complain get_random_function_sql = complain -get_deferrable_sql = complain get_fulltext_search_sql = complain get_drop_foreignkey_sql = complain get_pk_default_value = complain diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index 56976b77cc..d00829f502 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -161,9 +161,6 @@ def get_limit_offset_sql(limit, offset=None): def get_random_function_sql(): return "RAND()" -def get_deferrable_sql(): - return "" - def get_fulltext_search_sql(field_name): return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name diff --git a/django/db/backends/mysql_old/base.py b/django/db/backends/mysql_old/base.py index c7eea74b6d..a3dfcf0e76 100644 --- a/django/db/backends/mysql_old/base.py +++ b/django/db/backends/mysql_old/base.py @@ -180,9 +180,6 @@ def get_limit_offset_sql(limit, offset=None): def get_random_function_sql(): return "RAND()" -def get_deferrable_sql(): - return "" - def get_fulltext_search_sql(field_name): return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index 8847368cee..6198ee8030 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -54,6 +54,9 @@ class DatabaseOperations(BaseDatabaseOperations): def datetime_cast_sql(self): return "TO_TIMESTAMP(%s, 'YYYY-MM-DD HH24:MI:SS.FF')" + def deferrable_sql(self): + return " DEFERRABLE INITIALLY DEFERRED" + class DatabaseWrapper(BaseDatabaseWrapper): ops = DatabaseOperations() @@ -183,9 +186,6 @@ def get_limit_offset_sql(limit, offset=None): def get_random_function_sql(): return "DBMS_RANDOM.RANDOM" -def get_deferrable_sql(): - return " DEFERRABLE INITIALLY DEFERRED" - def get_fulltext_search_sql(field_name): raise NotImplementedError diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index 8c06bb494e..4fec530b5b 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -66,6 +66,9 @@ class DatabaseOperations(BaseDatabaseOperations): # http://www.postgresql.org/docs/8.0/static/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC return "DATE_TRUNC('%s', %s)" % (lookup_type, field_name) + def deferrable_sql(self): + return " DEFERRABLE INITIALLY DEFERRED" + class DatabaseWrapper(BaseDatabaseWrapper): ops = DatabaseOperations() @@ -137,9 +140,6 @@ def get_limit_offset_sql(limit, offset=None): def get_random_function_sql(): return "RANDOM()" -def get_deferrable_sql(): - return " DEFERRABLE INITIALLY DEFERRED" - def get_fulltext_search_sql(field_name): raise NotImplementedError diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py index 6a471a4f04..56cb53e3bc 100644 --- a/django/db/backends/postgresql_psycopg2/base.py +++ b/django/db/backends/postgresql_psycopg2/base.py @@ -28,6 +28,9 @@ class DatabaseOperations(BaseDatabaseOperations): # http://www.postgresql.org/docs/8.0/static/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC return "DATE_TRUNC('%s', %s)" % (lookup_type, field_name) + def deferrable_sql(self): + return " DEFERRABLE INITIALLY DEFERRED" + class DatabaseWrapper(BaseDatabaseWrapper): ops = DatabaseOperations() @@ -91,9 +94,6 @@ def get_limit_offset_sql(limit, offset=None): def get_random_function_sql(): return "RANDOM()" -def get_deferrable_sql(): - return " DEFERRABLE INITIALLY DEFERRED" - def get_fulltext_search_sql(field_name): raise NotImplementedError diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index 3e99ac72c7..88df473f52 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -124,9 +124,6 @@ def get_limit_offset_sql(limit, offset=None): def get_random_function_sql(): return "RANDOM()" -def get_deferrable_sql(): - return "" - def get_fulltext_search_sql(field_name): raise NotImplementedError |
