fix: validate enum values before opening transaction in alterEnumValues (#20376)

## Context
The validation throws after startTransaction() and outside the
surrounding try.
If the empty-enum branch ever fires, a BEGIN is left open on the
borrowed QueryRunner and never rolled back by this method the caller has
no way of knowing it now owes a ROLLBACK. Whatever the caller does next
on that QueryRunner runs inside the leftover transaction, and if its
lifecycle ends with a release() instead of a rollbackTransaction(), the
connection goes back to the pool with state still pending.
This commit is contained in:
Weiko
2026-05-08 09:00:13 +02:00
committed by GitHub
parent 546ab0a036
commit cb0b71dbdc
@@ -129,12 +129,6 @@ export class WorkspaceSchemaEnumManagerService {
enumValues: string[];
oldToNewEnumOptionMap: Record<string, string>;
}): Promise<void> {
const isTransactionAlreadyActive = queryRunner.isTransactionActive;
if (!isTransactionAlreadyActive) {
await queryRunner.startTransaction();
}
if (!enumValues || enumValues.length === 0) {
throw new WorkspaceSchemaManagerException(
`Cannot alter enum values for column ${columnDefinition.name} because it has no enum values`,
@@ -142,6 +136,12 @@ export class WorkspaceSchemaEnumManagerService {
);
}
const isTransactionAlreadyActive = queryRunner.isTransactionActive;
if (!isTransactionAlreadyActive) {
await queryRunner.startTransaction();
}
try {
const columnName = columnDefinition.name;