chore(twenty-server): upgrade typeorm to 0.3.29 (#21957)

## Summary

Upgrades **typeorm `0.3.26` → `0.3.29`** and adapts the twenty-orm
`update`/`upsert` overrides to typeorm's newly-added
`options.returning`. Upgrading to resolve
[this](https://github.com/twentyhq/twenty/security/dependabot/1573)
alert.

## Why

`0.3.29` is the latest release compatible with
`@ptc-org/nestjs-query-typeorm` (peers `typeorm@^0.3.15`; the `1.x` line
has no compatible release, so it's blocked until that dependency moves).

## Changes

**`chore` — bump**
- `typeorm` patch descriptor `0.3.26 → 0.3.29` + `yarn.lock`.
- Local patch carried over **unchanged** (pure rename) — both hunks
(`PickKeysByType` nullable-awareness, `DeleteResult.generatedMaps`) are
still absent upstream in `0.3.29`, so it remains load-bearing.

**`refactor` — adapt overrides**
- `0.3.29` adds `options?: UpdateOptions` (carrying `returning`) to
`EntityManager`/`Repository` `update()`. The override must accept it at
the base-mandated position, so it's added as its **own dedicated
parameter** (not hidden inside `permissionOptions`), honoring
`options.returning` with a fallback to Twenty's permission-aware
`selectedColumns` (`'*'` default).
- The same merge is applied to `upsert()`, which already received
`UpsertOptions` but was dropping its `returning` field — so both write
methods now treat the option identically.
- Internal call sites + specs updated for the new parameter slot.

## Verification

- `nx typecheck twenty-server` — **0 errors**
- twenty-orm unit tests — **191 / 191 pass**
- `oxlint` / `oxfmt` — clean
This commit is contained in:
Abdullah.
2026-06-22 19:08:09 +05:00
committed by GitHub
parent 6eb60f8a49
commit c171c62099
10 changed files with 83 additions and 43 deletions
@@ -474,7 +474,13 @@ describe('WorkspaceEntityManager', () => {
describe('Update Methods', () => {
it('should call createQueryBuilder with permissionOptions for update', async () => {
await withWorkspaceContext(mockWorkspaceContext, () =>
entityManager.update('test-entity', {}, {}, mockPermissionOptions),
entityManager.update(
'test-entity',
{},
{},
undefined,
mockPermissionOptions,
),
);
expect(entityManager['createQueryBuilder']).toHaveBeenCalledWith(
'test-entity',
@@ -30,6 +30,7 @@ import { FindOptionsUtils } from 'typeorm/find-options/FindOptionsUtils';
import { EntityPersistExecutor } from 'typeorm/persistence/EntityPersistExecutor';
import { type QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity';
import { PlainObjectToDatabaseEntityTransformer } from 'typeorm/query-builder/transformer/PlainObjectToDatabaseEntityTransformer';
import { type UpdateOptions } from 'typeorm/repository/UpdateOptions';
import { type UpsertOptions } from 'typeorm/repository/UpsertOptions';
import { InstanceChecker } from 'typeorm/util/InstanceChecker';
@@ -320,7 +321,7 @@ export class WorkspaceEntityManager extends EntityManager {
.into(target)
.values(entities)
.orUpdate(overwrites, conflictTargets, upsertOptions)
.returning(selectedColumns);
.returning(options.returning ?? selectedColumns);
return queryBuilder.execute();
}
@@ -338,6 +339,7 @@ export class WorkspaceEntityManager extends EntityManager {
| ObjectId[]
| unknown,
partialEntity: QueryDeepPartialEntity<Entity>,
options?: UpdateOptions,
permissionOptions?: PermissionOptions,
selectedColumns: string[] | '*' = '*',
): Promise<UpdateResult> {
@@ -370,7 +372,7 @@ export class WorkspaceEntityManager extends EntityManager {
.update()
.set(partialEntity)
.whereInIds(criteria)
.returning(selectedColumns)
.returning(options?.returning ?? selectedColumns)
.execute();
} else {
return this.createQueryBuilder(
@@ -382,7 +384,7 @@ export class WorkspaceEntityManager extends EntityManager {
.update()
.set(partialEntity)
.where(criteria)
.returning(selectedColumns)
.returning(options?.returning ?? selectedColumns)
.execute();
}
}
@@ -438,6 +440,7 @@ export class WorkspaceEntityManager extends EntityManager {
target,
criteria,
values,
undefined,
permissionOptions,
selectedColumns,
);
@@ -1050,6 +1053,7 @@ export class WorkspaceEntityManager extends EntityManager {
target,
criteria,
values,
undefined,
permissionOptions,
selectedColumns,
);
@@ -405,6 +405,7 @@ describe('WorkspaceRepository', () => {
'test-entity',
{ id: 'test-id' },
{ name: 'test' },
undefined,
{
shouldBypassPermissionChecks: false,
objectRecordsPermissions: mockObjectRecordsPermissions,
@@ -17,6 +17,7 @@ import {
} from 'typeorm';
import { type PickKeysByType } from 'typeorm/common/PickKeysByType';
import { type QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity';
import { type UpdateOptions } from 'typeorm/repository/UpdateOptions';
import { type UpsertOptions } from 'typeorm/repository/UpsertOptions';
import { type FeatureFlagMap } from 'src/engine/core-modules/feature-flag/interfaces/feature-flag-map.interface';
@@ -592,6 +593,7 @@ export class WorkspaceRepository<
| ObjectId[]
| FindOptionsWhere<T>,
partialEntity: QueryDeepPartialEntity<T>,
options?: UpdateOptions,
entityManager?: WorkspaceEntityManager,
selectedColumns?: string[],
): Promise<UpdateResult> {
@@ -610,6 +612,7 @@ export class WorkspaceRepository<
this.target,
criteria,
partialEntity,
options,
permissionOptions,
selectedColumns,
);