mirror of https://github.com/django/django.git
parent
ee5147cfd7
commit
9ca1f6eff6
|
@ -1342,6 +1342,12 @@ class ColPairs(Expression):
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return iter(self.get_cols())
|
return iter(self.get_cols())
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return (
|
||||||
|
f"{self.__class__.__name__}({self.alias!r}, {self.targets!r}, "
|
||||||
|
f"{self.sources!r}, {self.output_field!r})"
|
||||||
|
)
|
||||||
|
|
||||||
def get_cols(self):
|
def get_cols(self):
|
||||||
return [
|
return [
|
||||||
Col(self.alias, target, source)
|
Col(self.alias, target, source)
|
||||||
|
|
|
@ -47,6 +47,7 @@ from django.db.models import (
|
||||||
)
|
)
|
||||||
from django.db.models.expressions import (
|
from django.db.models.expressions import (
|
||||||
Col,
|
Col,
|
||||||
|
ColPairs,
|
||||||
Combinable,
|
Combinable,
|
||||||
CombinedExpression,
|
CombinedExpression,
|
||||||
NegatedExpression,
|
NegatedExpression,
|
||||||
|
@ -2466,6 +2467,10 @@ class ReprTests(SimpleTestCase):
|
||||||
"<When: WHEN <Q: (AND: ('age__gte', 18))> THEN Value('legal')>",
|
"<When: WHEN <Q: (AND: ('age__gte', 18))> THEN Value('legal')>",
|
||||||
)
|
)
|
||||||
self.assertEqual(repr(Col("alias", "field")), "Col(alias, field)")
|
self.assertEqual(repr(Col("alias", "field")), "Col(alias, field)")
|
||||||
|
self.assertEqual(
|
||||||
|
repr(ColPairs("alias", ["t1", "t2"], ["s1", "s2"], "f")),
|
||||||
|
"ColPairs('alias', ['t1', 't2'], ['s1', 's2'], 'f')",
|
||||||
|
)
|
||||||
self.assertEqual(repr(F("published")), "F(published)")
|
self.assertEqual(repr(F("published")), "F(published)")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
repr(F("cost") + F("tax")), "<CombinedExpression: F(cost) + F(tax)>"
|
repr(F("cost") + F("tax")), "<CombinedExpression: F(cost) + F(tax)>"
|
||||||
|
|
Loading…
Reference in New Issue