Skip to content

Conversation

m3k0813
Copy link
Contributor

@m3k0813 m3k0813 commented Aug 11, 2025

Fixes #1525

This PR enhances the Update class to support multiple operations on the same column, resolving the limitation of the previous Map-based implementation.

  • Changed the internal data structure of Update from Map<ColumnName, AssignmentOp> to List<AssignmentOp>. This allows multiple non-conflicting operations (e.g., setting different keys in a map) to coexist.

  • Introduced a conflict resolution mechanism to handle duplicate or conflicting operations. The new implementation follows a "last-wins" policy, as suggested in the issue discussion. For example, a set("name", "B") operation will replace a previous set("name", "A").

  • Added a comprehensive suite of unit tests to UpdateUnitTests to verify both the coexistence of non-conflicting operations and the "last-wins" replacement policy for various edge cases.


  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

Previously, the `Update` class used a `Map` to store its operations,
keyed by column name. This prevented multiple operations on the same
column, such as setting different keys in a map-type column, as later
operations would overwrite earlier ones.

This commit changes the internal data structure to a `List`, allowing
multiple operations to be recorded.

To align with the 'last-wins' semantics for conflicting operations
(e.g., setting the same column twice), a conflict resolution mechanism
has been added. New operations now replace existing, conflicting ones.

Adds comprehensive unit tests to verify both the coexistence of
non-conflicting operations and the replacement of conflicting ones.

Signed-off-by: Jeongjun Min <m3k0813@gmail.com>
Copy link
Member

@mp911de mp911de left a comment

Choose a reason for hiding this comment

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

Thanks a lot. This looks pretty decent. I'm going to polish this pull request for inclusion in the next release.

@Override
public String toString() {
return StringUtils.collectionToDelimitedString(updateOperations.values(), ", ");
private static boolean equalsNullSafe(@Nullable Object a, @Nullable Object b) {
Copy link
Member

Choose a reason for hiding this comment

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

This method isn't needed, use ObjectUtils.nullSafeEquals(…) instead.

@m3k0813
Copy link
Contributor Author

m3k0813 commented Aug 11, 2025

Thanks for the review and the feedback, @mp911de! I'm glad you liked the contribution :)

@mp911de mp911de changed the title GH-1525: Support multiple operations per column in Update Support multiple Update operations for a column Aug 11, 2025
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 11, 2025
@mp911de mp911de added this to the 4.5.3 (2025.0.3) milestone Aug 11, 2025
@mp911de mp911de changed the title Support multiple Update operations for a column Support multiple Update operations for the same column name Aug 11, 2025
mp911de pushed a commit that referenced this pull request Aug 11, 2025
Previously, the `Update` class used a `Map` to store its operations,
keyed by column name. This prevented multiple operations on the same
column, such as setting different keys in a map-type column, as later
operations would overwrite earlier ones.

This commit changes the internal data structure to a `List`, allowing
multiple operations to be recorded.

To align with the 'last-wins' semantics for conflicting operations
(e.g., setting the same column twice), a conflict resolution mechanism
has been added. New operations now replace existing, conflicting ones.

Adds comprehensive unit tests to verify both the coexistence of
non-conflicting operations and the replacement of conflicting ones.

Signed-off-by: Jeongjun Min <m3k0813@gmail.com>
See #1525
Original pull request: #1596
mp911de added a commit that referenced this pull request Aug 11, 2025
Reformat code. Rename conflicts method to overrides to indicate actual semantics and use type hierarchy for checks. Replace spaces with tab indents.
Extend test.

See #1525
Original pull request: #1596
mp911de pushed a commit that referenced this pull request Aug 11, 2025
Previously, the `Update` class used a `Map` to store its operations,
keyed by column name. This prevented multiple operations on the same
column, such as setting different keys in a map-type column, as later
operations would overwrite earlier ones.

This commit changes the internal data structure to a `List`, allowing
multiple operations to be recorded.

To align with the 'last-wins' semantics for conflicting operations
(e.g., setting the same column twice), a conflict resolution mechanism
has been added. New operations now replace existing, conflicting ones.

Adds comprehensive unit tests to verify both the coexistence of
non-conflicting operations and the replacement of conflicting ones.

Signed-off-by: Jeongjun Min <m3k0813@gmail.com>
See #1525
Original pull request: #1596
mp911de added a commit that referenced this pull request Aug 11, 2025
Reformat code. Rename conflicts method to overrides to indicate actual semantics and use type hierarchy for checks. Replace spaces with tab indents.
Extend test.

See #1525
Original pull request: #1596
@mp911de
Copy link
Member

mp911de commented Aug 11, 2025

Thank you for your contribution. That's merged, polished, and backported now.

@mp911de mp911de closed this Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support multiple Update operations for the same column
3 participants