fix(tenant-setting): save existing settings under MikroORM

Merged
CE
10d ago
+58-2

Problem

Under MikroORM, TenantSettingService.saveSettings and saveGlobalSettings loaded the existing settings, serialized them (wrap(entity).toJSON() → plain objects), changed their values and passed them to persistAndFlush, which rejects plain objects as undiscovered entities. Saving any setting that already existed failed; only new keys worked.

Fix

Keep the managed entities for the write path; the returned key / value map is built from them as before.

Tests

New tenant-setting.service.mikro-orm-save.spec.ts: both methods write the managed entity of an existing setting with its new value, and a new TenantSetting for a new key.

Notes

Not built or run locally.


Summary by cubic

Fixes saving existing tenant settings under MikroORM, which failed because settings were serialized into plain objects before being persisted.

  • saveSettings and saveGlobalSettings now keep the managed entities and update their values in place instead of writing serialized copies.
  • Adds a spec covering both methods, verifying existing settings are persisted with their new values and new keys create new TenantSetting entities.