Skip to content

Revive EntityUtil.merge() function. - #429

Merged
samchon merged 3 commits into
masterfrom
fix/entity-util-merge
Nov 24, 2025
Merged

Revive EntityUtil.merge() function.#429
samchon merged 3 commits into
masterfrom
fix/entity-util-merge

Conversation

@samchon

@samchon samchon commented Nov 24, 2025

Copy link
Copy Markdown
Owner

This pull request refactors and modularizes the entity merge logic by moving it out of EntityMergeProvider.ts and into a new utility module, EntityUtil.ts. The main purpose is to improve code organization and reusability for metadata handling and record merging, while preserving all existing functionality.

Refactoring and Modularization

  • Moved the metadata retrieval and record merge logic from EntityMergeProvider.ts into a new utility module EntityUtil.ts. This includes the getMetadata function, the main merge function, and related helpers for cascading merges and table name resolution. ([[1]](https://github.com/samchon/backend/pull/429/files#diff-52996d10a31875cefd3808d37f955ef225a6874c92d4b8e97d8f2f62fc283c7dL46-L212), [[2]](https://github.com/samchon/backend/pull/429/files#diff-a3f00de28cf17983ad28ffb850c0d3c356d3ff885b87b83dae60e66cf0013f88R1-R208))
  • Updated EntityMergeProvider.ts to use the new EntityUtil.getMetadata() and EntityUtil.merge() methods, removing the old in-file implementations. ([[1]](https://github.com/samchon/backend/pull/429/files#diff-52996d10a31875cefd3808d37f955ef225a6874c92d4b8e97d8f2f62fc283c7dL23-R18), [[2]](https://github.com/samchon/backend/pull/429/files#diff-52996d10a31875cefd3808d37f955ef225a6874c92d4b8e97d8f2f62fc283c7dL46-L212))

Code Cleanup

  • Removed unused imports and redundant code from EntityMergeProvider.ts that are now handled by EntityUtil.ts. ([[1]](https://github.com/samchon/backend/pull/429/files#diff-52996d10a31875cefd3808d37f955ef225a6874c92d4b8e97d8f2f62fc283c7dL2-R7), [[2]](https://github.com/samchon/backend/pull/429/files#diff-52996d10a31875cefd3808d37f955ef225a6874c92d4b8e97d8f2f62fc283c7dL46-L212))

Utility Improvements

  • Introduced a new interface IMergeProps in EntityUtil.ts to clarify the merge function’s input parameters. ([src/utils/EntityUtil.tsR1-R208](https://github.com/samchon/backend/pull/429/files#diff-a3f00de28cf17983ad28ffb850c0d3c356d3ff885b87b83dae60e66cf0013f88R1-R208))
  • Ensured all helper functions (such as unique constraint handling and recursive merging) are encapsulated within the utility module for better maintainability. ([src/utils/EntityUtil.tsR1-R208](https://github.com/samchon/backend/pull/429/files#diff-a3f00de28cf17983ad28ffb850c0d3c356d3ff885b87b83dae60e66cf0013f88R1-R208))

@samchon
samchon requested a review from Copilot November 24, 2025 15:55
@samchon samchon self-assigned this Nov 24, 2025
@samchon samchon added the enhancement New feature or request label Nov 24, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors entity merge functionality by extracting the merge logic from EntityMergeProvider.ts into a new reusable utility module EntityUtil.ts. The refactoring improves code organization and maintainability by separating business logic validation (provider layer) from core merge operations (utility layer), while preserving all existing functionality.

Key Changes:

  • Created new EntityUtil.ts with merge(), getMetadata(), and supporting functions for recursive entity merging
  • Introduced IMergeProps interface to generalize merge parameters beyond the specific IRecordMerge type
  • Updated EntityMergeProvider.ts to delegate to EntityUtil methods, reducing code duplication

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/utils/EntityUtil.ts New utility module containing metadata retrieval, merge logic, and cascade merge helpers extracted from EntityMergeProvider
src/providers/common/EntityMergeProvider.ts Refactored to use EntityUtil methods, removing redundant implementations and imports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/EntityUtil.ts Outdated
Comment thread src/utils/EntityUtil.ts Outdated
Comment thread src/utils/EntityUtil.ts
Comment thread src/utils/EntityUtil.ts
samchon and others added 2 commits November 25, 2025 00:59
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@samchon
samchon merged commit 345a56c into master Nov 24, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants