Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ export class FindTableCategoriesWithTablesUseCase
tables: tablesRO,
};
const foundTableCategoriesRO = foundTableCategories.map((category) => {
const tablesInCategory = tablesRO.filter((tableRO) => {
return category.tables.includes(tableRO.table);
});
const tablesInCategory = category.tables

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

This changes behavior when category.tables contains duplicates: the previous filter(...includes...) could only include each tablesRO entry once, but the new map(...find...) will repeat duplicates, returning the same table multiple times in the response. Consider de-duplicating category.tables (while preserving order) and/or enforcing uniqueness in table-category validation so API responses stay consistent.

Suggested change
const tablesInCategory = category.tables
const uniqueTableNames = Array.from(new Set(category.tables));
const tablesInCategory = uniqueTableNames

Copilot uses AI. Check for mistakes.
.map((tableName) => tablesRO.find((tableRO) => tableRO.table === tableName))
.filter(Boolean);
Comment on lines +106 to +108

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

category.tables.map(...tablesRO.find(...)) performs a linear search in tablesRO for every table name (O(categoryTables * tablesRO)). For connections with many tables/categories this can add noticeable overhead; consider building a lookup map (e.g., name -> tableRO) once and then doing O(1) lookups while preserving the category.tables order.

Copilot uses AI. Check for mistakes.
Comment on lines +106 to +108

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

This logic is intended to preserve the DB-stored ordering of category.tables, but there’s no test asserting the returned table order within a category. Please add/update coverage (likely in the existing /table-categories/v2/:connectionId e2e test) to verify that when a category is saved with an explicit tables order, the response returns tables in that same order.

Copilot uses AI. Check for mistakes.
return {
category_id: category.category_id,
category_color: category.category_color,
Expand Down
Loading