fix(view): /api/rdb/view/delete drops the view instead of the table - #2380
Merged
openai0229 merged 4 commits intoAug 3, 2026
Merged
Conversation
…tterMind#2377) The /delete endpoint was documented as deleting a database view but called tableService.dropTable, which generates DROP TABLE against a same-named object — destroying a table instead of removing the view. Build a DbViewDeleteRequest (tableName -> viewName) and delegate to viewService.drop, mirroring the /drop endpoint. The TableDeleteRequest input contract is preserved so existing callers are unaffected. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: liuhy <liuhongyu@apache.org>
There was a problem hiding this comment.
Pull request overview
This PR fixes POST /api/rdb/view/delete so it drops a view (via viewService.drop) instead of incorrectly dropping a table (via tableService.dropTable), preventing destructive DROP TABLE behavior when deleting views.
Findings (blocking):
chat2db-community-server/chat2db-community-web/src/main/java/ai/chat2db/community/web/api/controller/DbViewController.java:116— The/deleteendpoint still lacks@RequestBodyforTableDeleteRequest, unlike/dropand other/deleteendpoints; JSON clients may fail to bind/validate the request.
Changes:
- Replace
tableService.dropTable(...)withviewService.drop(...)for/api/rdb/view/delete. - Map
TableDeleteRequest.tableNametoDbViewDeleteRequest.viewNameto preserve the existing input contract. - Add clarifying inline comments documenting why the mapping is required.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
openai0229
approved these changes
Aug 3, 2026
openai0229
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the view-deletion delegation and request-body binding after syncing with the latest main. DbViewControllerTest executes successfully and verifies all four mapped fields passed to viewService.drop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
POST /api/rdb/view/deletewas documented as deleting a database view but calledtableService.dropTable(param), which generatesDROP TABLEagainst a same-named object — destroying a table instead of removing the view. The sibling/dropendpoint correctly callsviewService.drop.Location
DbViewController.java:115-120Fix
Build a
DbViewDeleteRequestfrom theTableDeleteRequest(mappingtableName→viewName, since a view's object name is carried intableNameon this request type) and delegate toviewService.drop, mirroring the/dropendpoint. TheTableDeleteRequestinput contract is preserved so existing callers are unaffected.Verification
DbViewDeleteRequesthas an@AllArgsConstructorwith field orderdataSourceId, databaseName, schemaName, viewName; the controller already imports it.TableDeleteRequestextendsDataSourceBaseRequest, which providesdataSourceId/databaseName/schemaName, and addstableName.tableServicefield andDbTableQueryRequestimport remain in use bycolumnList, so no dead-code was introduced.Manual/runtime verification against a datasource with a same-named view and table is recommended before merge.
Fixes #2377
🤖 Generated with Claude Code