Skip to content

fix: JsonField now correctly renders falsy values in list view (#734)#765

Open
SHYXIN wants to merge 2 commits into
jowilf:mainfrom
SHYXIN:fix/jsonfield-falsy-values
Open

fix: JsonField now correctly renders falsy values in list view (#734)#765
SHYXIN wants to merge 2 commits into
jowilf:mainfrom
SHYXIN:fix/jsonfield-falsy-values

Conversation

@SHYXIN

@SHYXIN SHYXIN commented May 17, 2026

Copy link
Copy Markdown
Contributor

Summary

The json render function used if (data) which incorrectly treated falsy values (0, false, "", [], {}) as null, displaying them as -null- in the list view.

Changes

  • starlette_admin/statics/js/render.js:67 — Changed if (data) to if (data != null) so only actual null/undefined displays as -null-
  • tests/test_views.py — Added test_json_field_falsy_values to verify API correctly serializes falsy JSON values

Testing

  • New test passes: test_json_field_falsy_values
  • All 15 views tests pass

SHYXIN and others added 2 commits May 17, 2026 15:05
…f#734)

The json render function in render.js used `if (data)` which incorrectly
treated falsy values (0, false, "", [], {}) as null, displaying them as
"-null-". Changed to `if (data != null)` so only actual null/undefined
values display as "-null-".

Added test to verify API correctly serializes falsy JSON values.
@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (0f684fe) to head (d2433a6).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #765   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           86        86           
  Lines         6848      6870   +22     
=========================================
+ Hits          6848      6870   +22     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant