diff options
| author | David Wobrock <david.wobrock@gmail.com> | 2023-12-21 23:20:36 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-12-23 17:35:13 +0100 |
| commit | 14917c9ae272f47d23401100faa6cefa8e1728bf (patch) | |
| tree | 6dbc8cde8c3877fda1da0c1e62b771ac926de125 /django/db/models/sql/query.py | |
| parent | 623597c786e89daae15a52dccfcdded7f808da9f (diff) | |
Fixed #35050 -- Fixed prefixing field names in FilteredRelation().
Thanks Mark Zorn for the report.
Regression in 59f475470494ce5b8cbff816b1e5dafcbd10a3a3.
Diffstat (limited to 'django/db/models/sql/query.py')
| -rw-r--r-- | django/db/models/sql/query.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 7166b8cb5d..a79d66eb21 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -94,14 +94,16 @@ def get_child_with_renamed_prefix(prefix, replacement, child): return rename_prefix_from_q(prefix, replacement, child) if isinstance(child, tuple): lhs, rhs = child - lhs = lhs.replace(prefix, replacement, 1) + if lhs.startswith(prefix + LOOKUP_SEP): + lhs = lhs.replace(prefix, replacement, 1) if not isinstance(rhs, F) and hasattr(rhs, "resolve_expression"): rhs = get_child_with_renamed_prefix(prefix, replacement, rhs) return lhs, rhs if isinstance(child, F): child = child.copy() - child.name = child.name.replace(prefix, replacement, 1) + if child.name.startswith(prefix + LOOKUP_SEP): + child.name = child.name.replace(prefix, replacement, 1) elif hasattr(child, "resolve_expression"): child = child.copy() child.set_source_expressions( |
