Skip to content
Merged
Show file tree
Hide file tree
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 @@ -52,6 +52,7 @@ export class TableCategoriesController {
@MasterPassword() masterPwd: string,
@Body() requestBody: CreateTableCategoryDto[],
): Promise<Array<FoundTableCategoryRo>> {

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 empty line appears to be unintentional whitespace. Consider removing it to maintain consistent code formatting.

Suggested change

Copilot uses AI. Check for mistakes.
const inputData: CreateOrUpdateTableCategoriesDS = {
connectionId,
master_password: masterPwd,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ export class CreateOrUpdateTableCategoriesUseCase

protected async implementation(inputData: CreateOrUpdateTableCategoriesDS): Promise<Array<FoundTableCategoryRo>> {
const { connectionId, master_password, table_categories } = inputData;

const allTablesCategory = table_categories.find((category) => category.category_id === null);
const filteredCategories = table_categories.filter((category) => category.category_id !== null);
Comment on lines +26 to +27

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.

The code attempts to handle categories with category_id: null to support the "All Tables" category, but the CreateTableCategoryDto validation at the controller level requires category_id to be a non-empty string (with @IsString() and @IsNotEmpty() decorators). This means requests with category_id: null will be rejected by the validation pipe before reaching this use case. To fix this, update the CreateTableCategoryDto to make category_id optional and nullable by adding @IsOptional() and removing or conditionally applying the @IsNotEmpty() decorator, or alternatively use @ValidateIf to skip validation when category_id is null.

Copilot uses AI. Check for mistakes.

const foundConnection = await this._dbContext.connectionRepository.findAndDecryptConnection(
connectionId,
master_password,
);

await validateTableCategories(table_categories, foundConnection);
await validateTableCategories(filteredCategories, foundConnection);

const foundTableCategories =
await this._dbContext.tableCategoriesRepository.findTableCategoriesForConnection(connectionId);
Expand All @@ -45,7 +49,7 @@ export class CreateOrUpdateTableCategoriesUseCase
connectionProperties = await this._dbContext.connectionPropertiesRepository.save(newConnectionProperties);
}

const createdCategories = table_categories.map((category) => {
const createdCategories = filteredCategories.map((category) => {
const newCategory = this._dbContext.tableCategoriesRepository.create({
category_name: category.category_name,
tables: category.tables,
Expand All @@ -56,6 +60,17 @@ export class CreateOrUpdateTableCategoriesUseCase
return newCategory;
});
const savedCategories = await this._dbContext.tableCategoriesRepository.save(createdCategories);
return savedCategories.map((category) => buildFoundTableCategoryRo(category));
const result = savedCategories.map((category) => buildFoundTableCategoryRo(category));

if (allTablesCategory) {
result.unshift({
category_id: null,
category_name: allTablesCategory.category_name,
category_color: allTablesCategory.category_color,
tables: allTablesCategory.tables,
});
}

return result;
}
}
Loading