Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug in core document.get #26280

Open
casesolved-co-uk opened this issue May 1, 2024 · 0 comments · May be fixed by #26281
Open

bug in core document.get #26280

casesolved-co-uk opened this issue May 1, 2024 · 0 comments · May be fixed by #26281
Labels

Comments

@casesolved-co-uk
Copy link
Contributor

casesolved-co-uk commented May 1, 2024

There appears to be a huge bug in the document core get() function.

Practically everywhere in the code (frappe and ERPNext) the assumption is made that doc.get() has the same definition as dict.get(). This is not true.

document.get(key, filters=None, limit=None, default=None)

dict.get(key[, default])

This fails for examples like:

doc.get("att1", 0.0)                   # returns None
doc.get("att2", {})                    # returns None
doc.get("att3", {"default": "hello"}   # returns an error if att3 is not a list (child table)

See the following PR that illustrates the issue with the Warnings printed in the test output:

#26279

https://github.com/frappe/frappe/blob/069612366197e4ed98d090d99cc068c8525d09ca/frappe/model/base_document.py#L215C2-L215C61

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant