Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

refactor: review comments

Pranav Cc0bd6a265286
diff --git a/packages/nocodb/src/services/columns.service.ts b/packages/nocodb/src/services/columns.service.ts
index 54a4d9958b..ac97739918 100644
--- a/packages/nocodb/src/services/columns.service.ts
+++ b/packages/nocodb/src/services/columns.service.ts
@@ -1971,16 +1971,15 @@ export class ColumnsService implements IColumnsService {
// Handle filter transformation if this is a column type change
if (column.uidt !== colBody.uidt) {
try {
- await this.filtersService.transformFiltersForColumnTypeChange(
- context,
- column.id,
- colBody.uidt as UITypes,
- column.uidt as UITypes,
+ await this.filtersService.transformFiltersForColumnTypeChange(context, {
+ columnId: column.id,
+ newColumnType: colBody.uidt as UITypes,
+ oldColumnType: column.uidt as UITypes,
sqlUi,
- );
+ });
} catch (error) {
// Log error but don't fail the column update
- console.error(
+ this.logger.error(
'Failed to transform filters for column type change:',
error.message,
);
diff --git a/packages/nocodb/src/services/filters.service.ts b/packages/nocodb/src/services/filters.service.ts
index 411fd9a793..7bb8cf235c 100644
--- a/packages/nocodb/src/services/filters.service.ts
+++ b/packages/nocodb/src/services/filters.service.ts
@@ -304,12 +304,16 @@ export class FiltersService {
*/
async transformFiltersForColumnTypeChange(
context: NcContext,
- columnId: string,
- newColumnType: UITypes,
- oldColumnType: UITypes,
- sqlUi: any,
+ params: {
+ columnId: string;
+ newColumnType: UITypes;
+ oldColumnType: UITypes;
+ sqlUi: any;
+ },
ncMeta = Noco.ncMeta,
): Promise<void> {
+ const { columnId, newColumnType, oldColumnType, sqlUi } = params;
+
// Get all filters that reference this column from all tables
const filtersToCheck = await this.getAllFiltersForColumn(
context,
@@ -459,16 +463,16 @@ export class FiltersService {
};
}
- // Check if operator is compatible with new type
- if (this.isOperatorCompatible(operator, newColumnType, oldColumnType)) {
- return { shouldRemove: false };
+ // Operator is not compatible, filter must be removed
+ if (!this.isOperatorCompatible(operator, newColumnType, oldColumnType)) {
+ return {
+ shouldRemove: true,
+ reason: `Operator ${operator} is not compatible with column type ${newColumnType}`,
+ };
}
- // Operator is not compatible, filter must be removed
- return {
- shouldRemove: true,
- reason: `Operator ${operator} is not compatible with column type ${newColumnType}`,
- };
+ // Operator is compatible, no removal needed
+ return { shouldRemove: false };
}
/**