summaryrefslogtreecommitdiff
path: root/django/db/models/sql/where.py
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2021-09-20 23:38:47 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-07-27 10:06:24 +0200
commited9eca8457e1673d09adfc65392a214027053109 (patch)
tree6f58c74d703b9d91ccb843f86c3565236c02abd4 /django/db/models/sql/where.py
parentddf0002bb760e5f1df664a81bd2a554c522f2c0f (diff)
Refs #32948 -- Simplified WhereNode and Node.__deepcopy__()/add().
We can use copy() in Node.add() instead of create() as we don't need the children to be cloned via [:] subscript in __init__().
Diffstat (limited to 'django/db/models/sql/where.py')
-rw-r--r--django/db/models/sql/where.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index d3e08cc65e..4b758e7adc 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -67,12 +67,12 @@ class WhereNode(tree.Node):
else:
where_parts.append(c)
having_node = (
- self.__class__(having_parts, self.connector, self.negated)
+ self.create(having_parts, self.connector, self.negated)
if having_parts
else None
)
where_node = (
- self.__class__(where_parts, self.connector, self.negated)
+ self.create(where_parts, self.connector, self.negated)
if where_parts
else None
)
@@ -171,16 +171,11 @@ class WhereNode(tree.Node):
self.children[pos] = child.relabeled_clone(change_map)
def clone(self):
- clone = self.__class__.create(
- children=None,
- connector=self.connector,
- negated=self.negated,
- )
+ clone = self.create(connector=self.connector, negated=self.negated)
for child in self.children:
if hasattr(child, "clone"):
- clone.children.append(child.clone())
- else:
- clone.children.append(child)
+ child = child.clone()
+ clone.children.append(child)
return clone
def relabeled_clone(self, change_map):