mirror of
https://github.com/django/django.git
synced 2024-11-21 19:09:18 +01:00
Refs #16055 -- Adjusted deprecation warning stacklevel in get_joining_columns()/get_reverse_joining_columns().
This commit is contained in:
parent
5e81a4e790
commit
8ee17037ae
@ -781,6 +781,7 @@ class ForeignObject(RelatedField):
|
||||
"ForeignObject.get_joining_columns() is deprecated. Use "
|
||||
"get_joining_fields() instead.",
|
||||
RemovedInDjango60Warning,
|
||||
stacklevel=2,
|
||||
)
|
||||
source = self.reverse_related_fields if reverse_join else self.related_fields
|
||||
return tuple(
|
||||
@ -792,6 +793,7 @@ class ForeignObject(RelatedField):
|
||||
"ForeignObject.get_reverse_joining_columns() is deprecated. Use "
|
||||
"get_reverse_joining_fields() instead.",
|
||||
RemovedInDjango60Warning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.get_joining_columns(reverse_join=True)
|
||||
|
||||
|
@ -197,6 +197,7 @@ class ForeignObjectRel(FieldCacheMixin):
|
||||
"ForeignObjectRel.get_joining_columns() is deprecated. Use "
|
||||
"get_joining_fields() instead.",
|
||||
RemovedInDjango60Warning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.field.get_reverse_joining_columns()
|
||||
|
||||
|
@ -703,24 +703,27 @@ class GetJoiningDeprecationTests(TestCase):
|
||||
"ForeignObject.get_joining_columns() is deprecated. Use "
|
||||
"get_joining_fields() instead."
|
||||
)
|
||||
with self.assertWarnsMessage(RemovedInDjango60Warning, msg):
|
||||
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
|
||||
Membership.person.field.get_joining_columns()
|
||||
self.assertEqual(ctx.filename, __file__)
|
||||
|
||||
def test_foreign_object_get_reverse_joining_columns_warning(self):
|
||||
msg = (
|
||||
"ForeignObject.get_reverse_joining_columns() is deprecated. Use "
|
||||
"get_reverse_joining_fields() instead."
|
||||
)
|
||||
with self.assertWarnsMessage(RemovedInDjango60Warning, msg):
|
||||
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
|
||||
Membership.person.field.get_reverse_joining_columns()
|
||||
self.assertEqual(ctx.filename, __file__)
|
||||
|
||||
def test_foreign_object_rel_get_joining_columns_warning(self):
|
||||
msg = (
|
||||
"ForeignObjectRel.get_joining_columns() is deprecated. Use "
|
||||
"get_joining_fields() instead."
|
||||
)
|
||||
with self.assertWarnsMessage(RemovedInDjango60Warning, msg):
|
||||
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
|
||||
Membership.person.field.remote_field.get_joining_columns()
|
||||
self.assertEqual(ctx.filename, __file__)
|
||||
|
||||
def test_join_get_joining_columns_warning(self):
|
||||
class CustomForeignKey(models.ForeignKey):
|
||||
|
Loading…
Reference in New Issue
Block a user