Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #12633 -- Modified some old m2m attribute use in deprecated m2m…

… table creation methods. Also added PendingDeprecation warnings to those methods. Thanks to Alex for the suggestion, and Ramiro for the report and fix.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12262 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b3e1162ca507c87ecea70d8100d24f431a8433ae 1 parent e2d094b
@freakboy3742 freakboy3742 authored
Showing with 26 additions and 2 deletions.
  1. +26 −2 django/db/backends/creation.py
View
28 django/db/backends/creation.py
@@ -145,6 +145,12 @@ def sql_for_pending_references(self, model, style, pending_references):
def sql_for_many_to_many(self, model, style):
"Return the CREATE TABLE statments for all the many-to-many tables defined on a model"
+ import warnings
+ warnings.warn(
+ 'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
+ PendingDeprecationWarning
+ )
+
output = []
for f in model._meta.local_many_to_many:
if model._meta.managed or f.rel.to._meta.managed:
@@ -153,11 +159,17 @@ def sql_for_many_to_many(self, model, style):
def sql_for_many_to_many_field(self, model, f, style):
"Return the CREATE TABLE statements for a single m2m field"
+ import warnings
+ warnings.warn(
+ 'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
+ PendingDeprecationWarning
+ )
+
from django.db import models
from django.db.backends.util import truncate_name
output = []
- if f.creates_table:
+ if f.auto_created:
opts = model._meta
qn = self.connection.ops.quote_name
tablespace = f.db_tablespace or opts.db_tablespace
@@ -210,6 +222,12 @@ def sql_for_many_to_many_field(self, model, f, style):
def sql_for_inline_many_to_many_references(self, model, field, style):
"Create the references to other tables required by a many-to-many table"
+ import warnings
+ warnings.warn(
+ 'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
+ PendingDeprecationWarning
+ )
+
from django.db import models
opts = model._meta
qn = self.connection.ops.quote_name
@@ -306,9 +324,15 @@ def sql_remove_table_constraints(self, model, references_to_delete, style):
def sql_destroy_many_to_many(self, model, f, style):
"Returns the DROP TABLE statements for a single m2m field"
+ import warnings
+ warnings.warn(
+ 'Database creation API for m2m tables has been deprecated. M2M models are now automatically generated',
+ PendingDeprecationWarning
+ )
+
qn = self.connection.ops.quote_name
output = []
- if f.creates_table:
+ if f.auto_created:
output.append("%s %s;" % (style.SQL_KEYWORD('DROP TABLE'),
style.SQL_TABLE(qn(f.m2m_db_table()))))
ds = self.connection.ops.drop_sequence_sql("%s_%s" % (model._meta.db_table, f.column))
Please sign in to comment.
Something went wrong with that request. Please try again.