Fix composite field update v2 (#15290)
# Introduction Fixing composite field update by computing field column type for each of its properties instead of globally ## Coverage Added integration tests for each composite field on both successful `create` and `update` ```ts Test Suites: 17 passed, 17 total Tests: 104 passed, 104 total Snapshots: 14 passed, 14 total Time: 135.431 s, estimated 143 s ``` ## Conlusion Related to https://github.com/twentyhq/core-team-issues/issues/1753
This commit is contained in:
+11
-5
@@ -301,14 +301,14 @@ export class UpdateFieldActionHandlerService extends WorkspaceMigrationRunnerAct
|
||||
tableName,
|
||||
update,
|
||||
}: UpdateFieldPropertyUpdateHandlerArgs<'defaultValue'>) {
|
||||
const columnType = fieldMetadataTypeToColumnType(
|
||||
flatFieldMetadata.type,
|
||||
) as ColumnType;
|
||||
|
||||
if (isCompositeFieldMetadataType(flatFieldMetadata.type)) {
|
||||
const compositeType = getCompositeTypeOrThrow(flatFieldMetadata.type);
|
||||
|
||||
for (const property of compositeType.properties) {
|
||||
const columnType = fieldMetadataTypeToColumnType(
|
||||
property.type,
|
||||
) as ColumnType;
|
||||
|
||||
if (isMorphOrRelationFieldMetadataType(property.type)) {
|
||||
throw new WorkspaceMigrationRunnerException(
|
||||
'Relation field metadata in composite type is not supported yet',
|
||||
@@ -331,7 +331,7 @@ export class UpdateFieldActionHandlerService extends WorkspaceMigrationRunnerAct
|
||||
defaultValue: compositeDefaultValue,
|
||||
});
|
||||
|
||||
return await this.workspaceSchemaManagerService.columnManager.alterColumnDefault(
|
||||
await this.workspaceSchemaManagerService.columnManager.alterColumnDefault(
|
||||
{
|
||||
queryRunner,
|
||||
schemaName,
|
||||
@@ -341,8 +341,14 @@ export class UpdateFieldActionHandlerService extends WorkspaceMigrationRunnerAct
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const columnType = fieldMetadataTypeToColumnType(
|
||||
flatFieldMetadata.type,
|
||||
) as ColumnType;
|
||||
|
||||
const serializedNewDefaultValue = serializeDefaultValueV2({
|
||||
columnName: flatFieldMetadata.name,
|
||||
schemaName,
|
||||
|
||||
Reference in New Issue
Block a user