1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Refs #34547 -- Adjusted deprecation warning stacklevel in DatabaseOperations.field_cast_sql().

This commit is contained in:
Simon Charette 2024-08-09 12:57:58 -04:00 committed by nessita
parent c042fe3a74
commit a69f895d7d
2 changed files with 3 additions and 1 deletions

View File

@ -228,6 +228,7 @@ class BaseDatabaseOperations:
"DatabaseOperations.lookup_cast() instead." "DatabaseOperations.lookup_cast() instead."
), ),
RemovedInDjango60Warning, RemovedInDjango60Warning,
stacklevel=2,
) )
return "%s" return "%s"

View File

@ -239,8 +239,9 @@ class DeprecationTests(TestCase):
"DatabaseOperations.field_cast_sql() is deprecated use " "DatabaseOperations.field_cast_sql() is deprecated use "
"DatabaseOperations.lookup_cast() instead." "DatabaseOperations.lookup_cast() instead."
) )
with self.assertRaisesMessage(RemovedInDjango60Warning, msg): with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
base_ops.field_cast_sql("integer", "IntegerField") base_ops.field_cast_sql("integer", "IntegerField")
self.assertEqual(ctx.filename, __file__)
def test_field_cast_sql_usage_warning(self): def test_field_cast_sql_usage_warning(self):
compiler = Author.objects.all().query.get_compiler(connection.alias) compiler = Author.objects.all().query.get_compiler(connection.alias)