Refactor buildNewPersonalTableSettingsEntity function to handle undefined values instead of null#1509
Conversation
…ined values instead of null
There was a problem hiding this comment.
Pull request overview
This pull request attempts to refactor the buildNewPersonalTableSettingsEntity function by changing it to check for undefined values instead of null values, and updates the indentation from spaces to tabs for consistency with the rest of the codebase.
Changes:
- Modified the condition to check for
undefinedinstead ofnullwhen deleting properties from the entity - Converted indentation from spaces to tabs throughout the function
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const newEntity = new PersonalTableSettingsEntity(); | ||
| Object.assign(newEntity, personalSettingsData); | ||
| Object.keys(personalSettingsData).forEach((key) => { | ||
| if (personalSettingsData[key as keyof PersonalTableSettingsData] === undefined) { |
There was a problem hiding this comment.
The change from checking null to undefined creates a bug. The PersonalTableSettingsData type defines all fields as type | null, and the controller explicitly converts undefined values to null using || null (see lines 116-121 in personal-table-settings.controller.ts). This means the function will never receive undefined values - it will only receive null values. As a result, properties with null values will no longer be deleted from the entity as intended, breaking the existing functionality.
| if (personalSettingsData[key as keyof PersonalTableSettingsData] === undefined) { | |
| if (personalSettingsData[key as keyof PersonalTableSettingsData] === null) { |
No description provided.