Move duplicate key error handling in ORM (#13893)

Error available in REST API
<img width="1360" height="653" alt="Screenshot 2025-08-13 at 11 48 19"
src="https://github.com/user-attachments/assets/a055859d-ce54-4ff6-9aba-fac48e03a98d"
/>

`curl http://localhost:3000/rest/people \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "emails": {
    "primaryEmail": "test@test.com"
  }
}'`

closes https://github.com/twentyhq/twenty/issues/13567
This commit is contained in:
Etienne
2025-08-14 18:38:04 +02:00
committed by GitHub
parent 5c61daa201
commit f6d0af5fb8
13 changed files with 156 additions and 50 deletions
@@ -200,7 +200,12 @@ export class WorkspaceInsertQueryBuilder<
identifiers: result.identifiers,
};
} catch (error) {
throw computeTwentyORMException(error);
const objectMetadata = getObjectMetadataFromEntityTarget(
this.getMainAliasTarget(),
this.internalContext,
);
throw computeTwentyORMException(error, objectMetadata);
}
}
@@ -176,7 +176,12 @@ export class WorkspaceUpdateQueryBuilder<
affected: result.affected,
};
} catch (error) {
throw computeTwentyORMException(error);
const objectMetadata = getObjectMetadataFromEntityTarget(
this.getMainAliasTarget(),
this.internalContext,
);
throw computeTwentyORMException(error, objectMetadata);
}
}
@@ -305,7 +310,12 @@ export class WorkspaceUpdateQueryBuilder<
affected: results.length,
};
} catch (error) {
throw computeTwentyORMException(error);
const objectMetadata = getObjectMetadataFromEntityTarget(
this.getMainAliasTarget(),
this.internalContext,
);
throw computeTwentyORMException(error, objectMetadata);
}
}