mirror of
https://github.com/django/django.git
synced 2024-12-22 09:05:43 +00:00
parent
ee5147cfd7
commit
9ca1f6eff6
@ -1342,6 +1342,12 @@ class ColPairs(Expression):
|
||||
def __iter__(self):
|
||||
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):
|
||||
return [
|
||||
Col(self.alias, target, source)
|
||||
|
@ -47,6 +47,7 @@ from django.db.models import (
|
||||
)
|
||||
from django.db.models.expressions import (
|
||||
Col,
|
||||
ColPairs,
|
||||
Combinable,
|
||||
CombinedExpression,
|
||||
NegatedExpression,
|
||||
@ -2466,6 +2467,10 @@ class ReprTests(SimpleTestCase):
|
||||
"<When: WHEN <Q: (AND: ('age__gte', 18))> THEN Value('legal')>",
|
||||
)
|
||||
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("cost") + F("tax")), "<CombinedExpression: F(cost) + F(tax)>"
|
||||
|
Loading…
Reference in New Issue
Block a user