refactor(Table): restore dynamic data type check logic#8040
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRefactors the table’s dynamic data querying so that dynamic queries are only executed for dynamic item types and safely handles a nullable dynamic context when auto-querying. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
QueryDynamicItems, you now null out_rowsCacheeven whencontextis null and then do nothing else; consider returning early whencontextis null to avoid partially changing state in this scenario. - The condition in
QueryDatanow guards onOnQueryAsync == nullandTItembeingIDynamicObjectbut no longer checksDynamicContext != null; for readability and to keep the control flow explicit, consider includingDynamicContext != nullin the outerifrather than relying on the inner null-check.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `QueryDynamicItems`, you now null out `_rowsCache` even when `context` is null and then do nothing else; consider returning early when `context` is null to avoid partially changing state in this scenario.
- The condition in `QueryData` now guards on `OnQueryAsync == null` and `TItem` being `IDynamicObject` but no longer checks `DynamicContext != null`; for readability and to keep the control flow explicit, consider including `DynamicContext != null` in the outer `if` rather than relying on the inner null-check.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Table component’s “dynamic object” query path to better align with dynamic-type detection by introducing an IDynamicObject type check and making QueryDynamicItems tolerate a nullable dynamic context.
Changes:
- Update
QueryDatato use dynamic querying only whenOnQueryAsyncis not provided andTItemimplementsIDynamicObject. - Update
QueryDynamicItemsto accept a nullableIDynamicObjectContextand guard against null.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs | Makes QueryDynamicItems accept nullable context and wraps dynamic query logic in a null check. |
| src/BootstrapBlazor/Components/Table/Table.razor.Edit.cs | Changes the condition that selects the dynamic-query path in QueryData. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if (DynamicContext != null) | ||
|
|
||
| if (OnQueryAsync == null && typeof(TItem).IsAssignableTo(typeof(IDynamicObject))) |
| private void QueryDynamicItems(QueryPageOptions queryOption, IDynamicObjectContext? context, bool isAutoQuery = true) | ||
| { | ||
| if (isAutoQuery) | ||
| { | ||
| _rowsCache = null; | ||
| var items = context.GetItems(); | ||
| if (context.OnFilterCallback != null) | ||
| if (context != null) | ||
| { |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8040 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 766 766
Lines 34154 34157 +3
Branches 4696 4697 +1
=========================================
+ Hits 34154 34157 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #8039
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Restore dynamic table querying behavior by guarding dynamic queries with type checks and a nullable context.
Bug Fixes:
Enhancements: