Merge pull request #15975 from resilient-tech/fix-limit-without-filter
fix: limit without filter
This commit is contained in:
commit
1df33cbfcf
2 changed files with 7 additions and 1 deletions
|
|
@ -153,6 +153,9 @@ class BaseDocument(object):
|
|||
value = []
|
||||
self.set(key, value)
|
||||
|
||||
if limit and isinstance(value, (list, tuple)) and len(value) > limit:
|
||||
value = value[:limit]
|
||||
|
||||
return value
|
||||
else:
|
||||
return self.__dict__
|
||||
|
|
|
|||
|
|
@ -264,7 +264,10 @@ class TestDocument(unittest.TestCase):
|
|||
|
||||
def test_limit_for_get(self):
|
||||
doc = frappe.get_doc("DocType", "DocType")
|
||||
# assuming DocType has more that 3 Data fields
|
||||
# assuming DocType has more than 3 Data fields
|
||||
self.assertEquals(len(doc.get("fields", limit=3)), 3)
|
||||
|
||||
# limit with filters
|
||||
self.assertEquals(len(doc.get("fields", filters={"fieldtype": "Data"}, limit=3)), 3)
|
||||
|
||||
def test_virtual_fields(self):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue