From 75b58802ad97cecef72235118da452da3f42f4a2 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Sat, 19 Oct 2024 16:11:51 +0200 Subject: [PATCH] fix(docref): json serialization (#28182) --- .pre-commit-config.yaml | 5 ++--- frappe/utils/response.py | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0200eaa9c4..4706860885 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,19 +5,18 @@ fail_fast: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v5.0.0 hooks: - id: trailing-whitespace files: "frappe.*" exclude: ".*json$|.*txt$|.*csv|.*md|.*svg" - - id: check-yaml - id: no-commit-to-branch args: ['--branch', 'develop'] - id: check-merge-conflict - id: check-ast - id: check-json - id: check-toml - - id: check-yaml + # - id: check-yaml - id: debug-statements exclude: ^frappe/tests/classes/context_managers\.py$ diff --git a/frappe/utils/response.py b/frappe/utils/response.py index 32fbc85757..b07fd49fa1 100644 --- a/frappe/utils/response.py +++ b/frappe/utils/response.py @@ -221,6 +221,10 @@ def json_handler(obj): elif isinstance(obj, frappe.model.document.BaseDocument): return obj.as_dict(no_nulls=True) + + elif isinstance(obj, frappe.model.document.DocRef): # if not BaseDocument, but DocRef + return str(obj) + elif isinstance(obj, Iterable): return list(obj)