storage: do not fail __repr__ for criterias without value (#57914)
This commit is contained in:
parent
69640091e8
commit
713a6ccc82
|
@ -482,6 +482,9 @@ def test_criteria_repr():
|
|||
assert 'foo' in repr(criteria)
|
||||
assert 'bar' in repr(criteria)
|
||||
|
||||
criteria = wcs.qommon.storage.Null('foo')
|
||||
assert 'Null' in repr(criteria)
|
||||
|
||||
|
||||
def test_related_field_repr():
|
||||
from wcs.backoffice.management import RelatedField
|
||||
|
|
|
@ -158,7 +158,11 @@ class Criteria:
|
|||
return lambda x: self.op(getattr(x, self.attribute, None) or self.typed_none, self.value)
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s (attribute: %r, value: %r)>' % (self.__class__.__name__, self.attribute, self.value)
|
||||
return '<%s (attribute: %r%s)>' % (
|
||||
self.__class__.__name__,
|
||||
self.attribute,
|
||||
', value: %r' % self.value if hasattr(self, 'value') else '',
|
||||
)
|
||||
|
||||
|
||||
class Less(Criteria):
|
||||
|
|
Loading…
Reference in New Issue