Skip to content

fix: infer table columns from documents for schema-less collections - #63

Merged
KushagraJaiswar02 merged 1 commit into
geturbackend:mainfrom
KushagraJaiswar02:pr/dynamic-column-inference
Mar 30, 2026
Merged

fix: infer table columns from documents for schema-less collections#63
KushagraJaiswar02 merged 1 commit into
geturbackend:mainfrom
KushagraJaiswar02:pr/dynamic-column-inference

Conversation

@KushagraJaiswar02

@KushagraJaiswar02 KushagraJaiswar02 commented Mar 29, 2026

Copy link
Copy Markdown
Collaborator

Collections with model: [] showed blank table views even when documents existed. Column definitions are now derived from the first document keys when model is empty. View toggles visible for any collection with documents. Boolean values render as true/false instead of blank.

🚀 Pull Request Description

Fixes # (issue number)

🛠️ Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 UI/UX improvement (Frontend only)
  • ⚙️ Refactor / Chore

🧪 Testing & Validation

Backend Verification:

  • I have run npm test in the backend/ directory and all tests passed.
  • I have verified the API endpoints using Postman/Thunder Client.
  • New unit tests have been added (if applicable).

Frontend Verification:

  • I have run npm run lint in the frontend/ directory.
  • Verified the UI changes on different screen sizes (Responsive).
  • Checked for any console errors in the browser dev tools.

📸 Screenshots / Recordings (Optional)

✅ Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generate no new warnings or errors.
  • I have updated the documentation (README/Docs) accordingly.

Built with ❤️ for urBackend.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved handling of empty or null values in data tables with clearer visual formatting
    • Table columns now dynamically generated from schema or actual data with intelligent type inference
    • View mode toggle now conditionally displays only when relevant data or schema is available

Collections with model: [] showed blank table views even when
documents existed. Column definitions are now derived from the
first document keys when model is empty. View toggles visible
for any collection with documents. Boolean values render as
true/false instead of blank.
@vercel

vercel Bot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

@KushagraJaiswar02 is attempting to deploy a commit to the Yash Pouranik's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Two components in the web-dashboard receive updates to improve robustness and conditional rendering. CollectionTable.jsx now defensively handles missing active collection state and infers column types from data when model definitions unavailable. Database.jsx conditionally displays the view-mode toggle only when schema fields or data exist.

Changes

Cohort / File(s) Summary
CollectionTable Display Updates
apps/web-dashboard/src/components/CollectionTable.jsx, apps/web-dashboard/src/pages/Database.jsx
CollectionTable now defensively handles missing activeCollection, adds dynamic column derivation with type inference from data, adjusts null/undefined rendering to show muted em-dashes, and includes data in useMemo dependencies. Database.jsx conditionally renders view-mode toggle only when schema fields exist or data is non-empty.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 Hop through the tables, so sturdy and keen,
Missing collections? No crashes foreseen!
Column types inferred from data so fine,
Toggle displays when the schemas align—
Defensive and thoughtful, our code's now pristine! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and accurately summarizes the main change: inferring table columns from documents when collections lack a predefined schema.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the CollectionTable component by allowing it to infer column definitions directly from the data when a collection model is unavailable. It also refines cell rendering to handle null or undefined values more gracefully and ensures the view toggle in the Database page is only displayed when relevant data exists. Review feedback highlights a potential runtime error when accessing the first data element for column inference and suggests moving static helper functions outside the useMemo hook to improve performance and code organization.

Comment thread apps/web-dashboard/src/components/CollectionTable.jsx
Comment thread apps/web-dashboard/src/components/CollectionTable.jsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/web-dashboard/src/components/CollectionTable.jsx (1)

91-103: Consider lifting inferred fields out of CollectionTable.

Right now only the table knows about these derived keys. apps/web-dashboard/src/pages/Database.jsx still builds the sort/filter selectors from activeCollection?.model at Lines 481-483 and 516-518, so schema-less collections can show columns that the query UI cannot target.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web-dashboard/src/components/CollectionTable.jsx` around lines 91 - 103,
The table-only inference of schema (the baseColumns logic in CollectionTable
that uses inferType) causes the query UI to miss derived fields; extract that
inference into a shared helper (e.g., inferModelFromData(data, SYSTEM_FIELDS)
that returns [{key,type},...]) and replace the inline mapping in CollectionTable
(baseColumns) to call this helper, then update the query UI code that builds
selectors (the places referencing activeCollection?.model) to fall back to
inferModelFromData(data, SYSTEM_FIELDS) when activeCollection.model is empty so
both components use the same derived model.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/web-dashboard/src/components/CollectionTable.jsx`:
- Around line 91-103: baseColumns currently infers schema-less columns from only
data[0], which loses keys present in later rows; update the logic that builds
the fallback columns (the ternary branch that uses Object.entries(data[0])) to
iterate over all rows in data, collect the union of keys excluding
SYSTEM_FIELDS, then map those keys to column objects using inferType (prefer the
first non-undefined/non-null value encountered for type inference). Keep the
existing activeCollection.model branch unchanged, ensure deterministic ordering
(e.g., sort keys) so columns don't jump when pagination/sorting changes, and
reference baseColumns, SYSTEM_FIELDS, inferType and data when making the change.

---

Nitpick comments:
In `@apps/web-dashboard/src/components/CollectionTable.jsx`:
- Around line 91-103: The table-only inference of schema (the baseColumns logic
in CollectionTable that uses inferType) causes the query UI to miss derived
fields; extract that inference into a shared helper (e.g.,
inferModelFromData(data, SYSTEM_FIELDS) that returns [{key,type},...]) and
replace the inline mapping in CollectionTable (baseColumns) to call this helper,
then update the query UI code that builds selectors (the places referencing
activeCollection?.model) to fall back to inferModelFromData(data, SYSTEM_FIELDS)
when activeCollection.model is empty so both components use the same derived
model.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d499e955-0fde-4ff5-bd5d-497b23061df8

📥 Commits

Reviewing files that changed from the base of the PR and between b37fc82 and ebbc3c9.

📒 Files selected for processing (2)
  • apps/web-dashboard/src/components/CollectionTable.jsx
  • apps/web-dashboard/src/pages/Database.jsx

Comment thread apps/web-dashboard/src/components/CollectionTable.jsx
@vercel

vercel Bot commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ur-backend-web-dashboard Ready Ready Preview, Comment Mar 30, 2026 4:43am

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes blank/limited table rendering in the web dashboard for schema-less collections (model: []) by deriving table columns from document data and improving display behavior when documents exist.

Changes:

  • Show view-mode toggles when either a schema exists or documents exist.
  • Infer table columns from the first document’s keys when activeCollection.model is empty.
  • Improve cell rendering for null/undefined and boolean values.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
apps/web-dashboard/src/pages/Database.jsx Conditionally renders the view toggle based on presence of schema fields or documents.
apps/web-dashboard/src/components/CollectionTable.jsx Adds schema-less column inference and improves cell rendering for booleans and null/undefined values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/web-dashboard/src/components/CollectionTable.jsx
Comment thread apps/web-dashboard/src/components/CollectionTable.jsx

@yash-pouranik yash-pouranik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix suggested changes, and will merge

@KushagraJaiswar02
KushagraJaiswar02 merged commit f8c293e into geturbackend:main Mar 30, 2026
11 checks passed
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.

3 participants