Skip to content

feat: add uncached option to data structures and update use cases for cache invalidation#1775

Merged
Artuomka merged 1 commit into
mainfrom
backend_unchashed_table_endpoints
May 15, 2026
Merged

feat: add uncached option to data structures and update use cases for cache invalidation#1775
Artuomka merged 1 commit into
mainfrom
backend_unchashed_table_endpoints

Conversation

@Artuomka
Copy link
Copy Markdown
Collaborator

@Artuomka Artuomka commented May 15, 2026

Summary by CodeRabbit

  • New Features

    • Added _uncached query parameter support for row operations (delete, update, fetch by primary key, and find all rows) to provide control over metadata cache behavior.
  • Chores

    • Migrated cache control parameter naming convention for consistency across API endpoints.

Review Change Stack

Copilot AI review requested due to automatic review settings May 15, 2026 08:02
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

📝 Walkthrough

Walkthrough

This PR adds an optional uncached flag to table operation data structures and propagates it through the API layer to selectively bypass metadata caching. Query parameters are migrated from uncached to _uncached (underscore prefix convention), and use cases now invoke dao.invalidateMetadataCache() when the flag is set.

Changes

Uncached Metadata Cache Flag

Layer / File(s) Summary
Data structure contracts with uncached field
backend/src/entities/table/application/data-structures/delete-row-from-table.ds.ts, backend/src/entities/table/application/data-structures/get-row-by-primary-key.ds.ts, backend/src/entities/table/application/data-structures/update-row-in-table.ds.ts
Adds optional uncached?: boolean field to DeleteRowFromTableDs, GetRowByPrimaryKeyDs, and UpdateRowInTableDs.
Controller query parameter handling and cache invalidation helpers
backend/src/entities/table/table.controller.ts
Migrates cache-invalidation flag from uncached to _uncached query parameter, adds stripReservedQueryParams() helper to exclude reserved params from primary-key derivation, updates getPrimaryKeys() to accept uncached flag and call dao.invalidateMetadataCache(). Updates findAllRowsWithBodyFilter, updateRowInTable, deleteRowInTable, and getRowByPrimaryKey endpoints to accept and propagate the _uncached parameter.
Use case cache invalidation on uncached flag
backend/src/entities/table/use-cases/delete-row-from-table.use.case.ts, backend/src/entities/table/use-cases/get-row-by-primary-key.use.case.ts, backend/src/entities/table/use-cases/update-row-in-table.use.case.ts
Each use case destructures the uncached flag from its input DTO and conditionally calls dao.invalidateMetadataCache() before executing row operations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • rocket-admin/rocketadmin#1771: Introduces the invalidateMetadataCache() method on DAOs/agents that this PR uses to selectively bypass cached metadata during table operations.

Suggested reviewers

  • gugu
  • lyubov-voloshko

Poem

🐰 A flag hops through the table paths,
With _uncached in query strings so true,
DAO caches bend to its commands,
Fresh metadata blooms in morning dew! 🌿

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main change: adding an uncached option to data structures and updating use cases to handle cache invalidation across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Check ✅ Passed PR implements uncached option with proper OWASP compliance. All endpoints have correct authorization guards, parameter collision is prevented via underscore prefix, and flag conversion is safe.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backend_unchashed_table_endpoints

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

@coderabbitai coderabbitai Bot requested review from gugu and lyubov-voloshko May 15, 2026 08:03
@Artuomka Artuomka enabled auto-merge May 15, 2026 08:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an opt-in _uncached query parameter to several table row endpoints, allowing API consumers to invalidate the DAO's metadata cache before reading or mutating rows. The flag is propagated from the controller through new optional uncached fields on the use case data structures, and the controller strips the reserved query param so it isn't mistaken for a primary-key column value (the underscore prefix further reduces the chance of column-name collisions).

Changes:

  • Add uncached?: boolean to the GetRowByPrimaryKeyDs, UpdateRowInTableDs, and DeleteRowFromTableDs data structures, and invalidate the DAO metadata cache in the corresponding use cases when the flag is set.
  • In TableController, rename the query parameter to _uncached, document it via @ApiQuery, wire it through the getPrimaryKeys, update, delete, and get-by-primary-key flows, and invalidate the DAO cache in getPrimaryKeys when requested.
  • Introduce stripReservedQueryParams to remove _uncached from the query map before it is used for primary-key lookup or downstream filtering.

Reviewed changes

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

Show a summary per file
File Description
backend/src/entities/table/application/data-structures/get-row-by-primary-key.ds.ts Adds optional uncached flag to the DS.
backend/src/entities/table/application/data-structures/update-row-in-table.ds.ts Adds optional uncached flag to the DS.
backend/src/entities/table/application/data-structures/delete-row-from-table.ds.ts Adds optional uncached flag to the DS.
backend/src/entities/table/use-cases/get-row-by-primary-key.use.case.ts Invalidates DAO metadata cache when uncached is set.
backend/src/entities/table/use-cases/update-row-in-table.use.case.ts Invalidates DAO metadata cache when uncached is set.
backend/src/entities/table/use-cases/delete-row-from-table.use.case.ts Invalidates DAO metadata cache when uncached is set.
backend/src/entities/table/table.controller.ts Renames query param to _uncached, strips it from query maps, and threads the flag into use cases and getPrimaryKeys.

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
backend/src/entities/table/application/data-structures/delete-row-from-table.ds.ts (1)

10-16: Consider extending uncached support to bulk operations.

The single-row DeleteRowFromTableDs now supports uncached, but DeleteRowsFromTableDs (used for bulk deletes) does not. Similarly, bulk update operations lack this flag. If users need fresh metadata during bulk operations, they currently have no mechanism to invalidate the cache.

Consider whether bulk delete/update endpoints should also accept the _uncached query parameter for consistency and to support cache invalidation in batch scenarios.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@backend/src/entities/table/application/data-structures/delete-row-from-table.ds.ts`
around lines 10 - 16, DeleteRowsFromTableDs currently lacks the uncached flag
used by single-row deletes, so bulk delete endpoints can't request fresh
metadata; add an optional boolean property named `_uncached?: boolean` (or
`uncached?: boolean` to match existing naming) to the DeleteRowsFromTableDs
class to mirror DeleteRowFromTableDs, update any related bulk-update DTO/classes
(e.g., the bulk update data-structure) to include the same optional flag, and
ensure request handling code reads this field to respect the `_uncached` query
param for cache invalidation during bulk operations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@backend/src/entities/table/application/data-structures/delete-row-from-table.ds.ts`:
- Around line 10-16: DeleteRowsFromTableDs currently lacks the uncached flag
used by single-row deletes, so bulk delete endpoints can't request fresh
metadata; add an optional boolean property named `_uncached?: boolean` (or
`uncached?: boolean` to match existing naming) to the DeleteRowsFromTableDs
class to mirror DeleteRowFromTableDs, update any related bulk-update DTO/classes
(e.g., the bulk update data-structure) to include the same optional flag, and
ensure request handling code reads this field to respect the `_uncached` query
param for cache invalidation during bulk operations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2e02d806-8d60-42c1-a2f2-dfb06501539b

📥 Commits

Reviewing files that changed from the base of the PR and between 8627817 and 8a24296.

📒 Files selected for processing (7)
  • backend/src/entities/table/application/data-structures/delete-row-from-table.ds.ts
  • backend/src/entities/table/application/data-structures/get-row-by-primary-key.ds.ts
  • backend/src/entities/table/application/data-structures/update-row-in-table.ds.ts
  • backend/src/entities/table/table.controller.ts
  • backend/src/entities/table/use-cases/delete-row-from-table.use.case.ts
  • backend/src/entities/table/use-cases/get-row-by-primary-key.use.case.ts
  • backend/src/entities/table/use-cases/update-row-in-table.use.case.ts

@Artuomka Artuomka disabled auto-merge May 15, 2026 08:21
@Artuomka Artuomka merged commit 8ca1841 into main May 15, 2026
12 of 18 checks passed
@Artuomka Artuomka deleted the backend_unchashed_table_endpoints branch May 15, 2026 08:21
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.

2 participants