Skip to content

Commit 5e365fe

Browse files
committed
feat: enhance dbFieldNames retrieval in FormulaFieldCore and FieldCore classes
1 parent b6b64f9 commit 5e365fe

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

apps/nestjs-backend/src/features/calculation/reference.service.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -842,9 +842,10 @@ export class ReferenceService {
842842
const value = this.calculateComputeField(field, fieldMap, recordItem, userMap);
843843

844844
const oldValue = record.fields[field.id];
845-
if (isEqual(oldValue, value)) {
846-
return;
847-
}
845+
846+
// if (isEqual(oldValue, value)) {
847+
// return;
848+
// }
848849

849850
return {
850851
tableId,
@@ -977,7 +978,7 @@ export class ReferenceService {
977978
// deduplication is needed
978979
const recordIds = Array.from(recordIdsByTableName[dbTableName]);
979980
const dbFieldNames = dbTableName2fields[dbTableName]
980-
.map((f) => f.dbFieldName)
981+
.flatMap((f) => f.dbFieldNames)
981982
.concat([...preservedDbFieldNames]);
982983
const nativeQuery = this.knex(dbTableName)
983984
.select(dbFieldNames)

packages/core/src/models/field/derivate/formula.field.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ const formulaFieldCellValueSchema = z.any();
3535
export type IFormulaCellValue = z.infer<typeof formulaFieldCellValueSchema>;
3636

3737
export class FormulaFieldCore extends FormulaAbstractCore {
38+
override get dbFieldNames() {
39+
return this.options.dbGenerated
40+
? [this.dbFieldName, this.getGeneratedColumnName()]
41+
: [this.dbFieldName];
42+
}
43+
3844
static defaultOptions(cellValueType: CellValueType): IFormulaFieldOptions {
3945
return {
4046
expression: '',

packages/core/src/models/field/field.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export abstract class FieldCore implements IFieldVo {
1818

1919
dbFieldName!: string;
2020

21+
get dbFieldNames() {
22+
return [this.dbFieldName];
23+
}
24+
2125
aiConfig?: IFieldVo['aiConfig'];
2226

2327
abstract type: FieldType;

0 commit comments

Comments
 (0)