diff options
| author | Simon Charette <charette.s@gmail.com> | 2026-03-15 23:31:18 -0400 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-03-19 12:24:17 -0400 |
| commit | 1786cd881ff4ad9458d56180ae555d92c14e5af8 (patch) | |
| tree | 6eb2661f3648b6645336cd6e5eb66989f9d2c6b1 /tests/queries/test_sqlcompiler.py | |
| parent | 5146449a38222dc74f8f1ba88a7a7ef681e93101 (diff) | |
Refs #36795 -- Deprecated SQLCompiler.quote_name_unless_alias().
It has been superseded with .quote_name(), which ensures aliases are
always quoted.
Diffstat (limited to 'tests/queries/test_sqlcompiler.py')
| -rw-r--r-- | tests/queries/test_sqlcompiler.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/queries/test_sqlcompiler.py b/tests/queries/test_sqlcompiler.py index 0f6f2fc10b..5a456811a1 100644 --- a/tests/queries/test_sqlcompiler.py +++ b/tests/queries/test_sqlcompiler.py @@ -4,6 +4,7 @@ from django.db import DEFAULT_DB_ALIAS, DatabaseError, connection from django.db.models.sql import Query from django.db.models.sql.compiler import SQLCompiler from django.test import TestCase +from django.utils.deprecation import RemovedInDjango70Warning from .models import Item @@ -39,3 +40,19 @@ class SQLCompilerTest(TestCase): self.assertIs(exc, execute_err) self.assertIsNone(exc.__cause__) self.assertTrue(exc.__suppress_context__) + + # RemovedInDjango70Warning: When the deprecation ends, remove this + # test. + def test_quote_name_unless_alias_deprecation(self): + query = Query(Item) + compiler = SQLCompiler(query, connection, None) + msg = ( + "SQLCompiler.quote_name_unless_alias() is deprecated. " + "Use .quote_name() instead." + ) + with self.assertWarnsMessage(RemovedInDjango70Warning, msg) as ctx: + self.assertEqual( + compiler.quote_name_unless_alias("name"), + compiler.quote_name("name"), + ) + self.assertEqual(ctx.filename, __file__) |
