-
-
Notifications
You must be signed in to change notification settings - Fork 18
enable sorting for all table category #1620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -90,19 +90,34 @@ export class FindTableCategoriesWithTablesUseCase | |||||
| const foundTableCategories = | ||||||
| await this._dbContext.tableCategoriesRepository.findTableCategoriesForConnection(connectionId); | ||||||
|
|
||||||
| // const sortedTables = tablesRO.sort((tableRO1, tableRO2) => { | ||||||
| // const name1 = tableRO1.display_name || tableRO1.table; | ||||||
| // const name2 = tableRO2.display_name || tableRO2.table; | ||||||
| // return name1.localeCompare(name2); | ||||||
| // }); | ||||||
| const storedAllTablesCategory = foundTableCategories.find((category) => category.category_id === 'all-tables-kitten'); | ||||||
| const otherCategories = foundTableCategories.filter((category) => category.category_id !== 'all-tables-kitten'); | ||||||
|
|
||||||
| let allTablesOrdered: Array<FoundTableDs>; | ||||||
| if (storedAllTablesCategory) { | ||||||
| allTablesOrdered = storedAllTablesCategory.tables | ||||||
| .map((tableName) => tablesRO.find((tableRO) => tableRO.table === tableName)) | ||||||
| .filter(Boolean); | ||||||
|
||||||
| .filter(Boolean); | |
| .filter((table): table is FoundTableDs => table !== undefined); |
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic handles adding new tables but does not handle removing deleted tables from the stored order. If a table is deleted from the database but still exists in storedAllTablesCategory.tables, it will be filtered out by filter(Boolean) in line 100, but the database will not be updated to reflect this change. This can lead to the stored order containing references to non-existent tables that accumulate over time. Consider updating the stored order in the database when tables are removed, similar to how it's done when new tables are added.
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The identifier 'all-tables-kitten' is an unusual naming choice for a system-level constant. Consider using a more conventional identifier like 'all-tables', 'all', or '_all_tables' that better reflects its special system status. The '-kitten' suffix appears arbitrary and may confuse developers unfamiliar with the codebase context.
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic string 'all-tables-kitten' is duplicated across multiple files (in this file at lines 93, 94, 115, and in create-or-update-table-categories.use.case.ts at lines 26, 27). Consider extracting this to a shared constant to ensure consistency and make future changes easier. For example, define it as a constant like ALL_TABLES_CATEGORY_ID in a shared constants file.
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the API contract for the v2 endpoint where category_id was previously null for the "All tables" category and is now 'all-tables-kitten'. This is a breaking change for any API consumers expecting null. Consider whether this should be versioned as v3 or if there's documentation/migration guide needed for existing API consumers.
| category_id: 'all-tables-kitten', | |
| category_id: null, |
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The category_name is hardcoded to 'All tables' regardless of what name is stored in the database for the all-tables-kitten category. This means if a user creates an all-tables-kitten category with a different name, it will be silently changed to 'All tables' in the response. Consider whether this behavior should validate and enforce the name during creation, or document this override behavior clearly.
| category_name: 'All tables', | |
| category_name: storedAllTablesCategory?.category_name ?? 'All tables', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The all-tables-kitten category bypasses validation (line 34 validates only filteredCategories). This means invalid table names could be stored in all-tables-kitten without validation. While the find use case filters out non-existent tables at runtime, consider whether basic validation (non-empty category_name, tables as array) should still apply to all-tables-kitten for data integrity.