From 17d644c8e257c2ea5cc738fb7a9c47989e29bf09 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 3 Dec 2025 18:06:53 -0500 Subject: Added DatabaseFeatures.prohibits_dollar_signs_in_column_aliases. This is also applicable on CockroachDB. --- django/db/models/sql/compiler.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'django/db/models/sql') diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 20f06ad168..9068d87a89 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -553,6 +553,14 @@ class SQLCompiler: for table names. This avoids problems with some SQL dialects that treat quoted strings specially (e.g. PostgreSQL). """ + if ( + self.connection.features.prohibits_dollar_signs_in_column_aliases + and "$" in name + ): + raise ValueError( + "Dollar signs are not permitted in column aliases on " + f"{self.connection.display_name}." + ) if name in self.quote_cache: return self.quote_cache[name] if ( -- cgit v1.3