GetEntityChangeSet for Custom Mapping Type get unchanged items #5902

Closed
opened 2026-01-22 15:21:35 +01:00 by admin · 2 comments
Owner

Originally created by @myspulin on GitHub (Feb 26, 2018).

Originally assigned to: @Ocramius on GitHub.

Hi,

I use Custom Mapping Type for my entity (ENUM). When I try to call GetEntityChangeSet when onFlush called, I get the same value even if entity did not changed.

I use doctrine/orm: v2.5.14

This is the result, both values are the same:

"status" => array:2 [▼
    0 => DocumentStatus {#540 ▼
      -status: "draft"
    }
    1 => DocumentStatus {#1715 ▼
      -status: "draft"
    }
  ]
  "visibility" => array:2 [▼
    0 => DocumentVisibility {#541 ▼
      -state: "internal"
    }
    1 => DocumentVisibility {#1720 ▼
      -state: "internal"
    }
  ]

Also SQL update is called but it is not necessary to do that if no changes have made:

UPDATE documents SET status = ?, visibility = ? WHERE id = ?

Parameters: [0 => draft, 1 => internal, 2 => 221] 

Could you please check this issue, thank you!

Originally created by @myspulin on GitHub (Feb 26, 2018). Originally assigned to: @Ocramius on GitHub. Hi, I use Custom Mapping Type for my entity (ENUM). When I try to call GetEntityChangeSet when onFlush called, I get the same value even if entity did not changed. I use `doctrine/orm: v2.5.14` This is the result, both values are the same: ``` "status" => array:2 [▼ 0 => DocumentStatus {#540 ▼ -status: "draft" } 1 => DocumentStatus {#1715 ▼ -status: "draft" } ] "visibility" => array:2 [▼ 0 => DocumentVisibility {#541 ▼ -state: "internal" } 1 => DocumentVisibility {#1720 ▼ -state: "internal" } ] ``` Also SQL update is called but it is not necessary to do that if no changes have made: ``` UPDATE documents SET status = ?, visibility = ? WHERE id = ? Parameters: [0 => draft, 1 => internal, 2 => 221] ``` Could you please check this issue, thank you!
admin added the InvalidQuestion labels 2026-01-22 15:21:35 +01:00
admin closed this issue 2026-01-22 15:21:36 +01:00
Author
Owner

@Ocramius commented on GitHub (Feb 26, 2018):

The DocumentVisibility instances are compared by reference (like all objects), so this is expected behavior.

See also https://stackoverflow.com/questions/15486402/doctrine2-orm-does-not-save-changes-to-a-datetime-field for another example of how this could go wrong.

@Ocramius commented on GitHub (Feb 26, 2018): The `DocumentVisibility` instances are compared by reference (like all objects), so this is expected behavior. See also https://stackoverflow.com/questions/15486402/doctrine2-orm-does-not-save-changes-to-a-datetime-field for another example of how this could go wrong.
Author
Owner

@myspulin commented on GitHub (Feb 27, 2018):

Make sense, thanks for info.

@myspulin commented on GitHub (Feb 27, 2018): Make sense, thanks for info.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5902