Skip to content

[Bug]: Updating a JTI child sends OnCreate to its parent roles #59

Open

Description

@roxblnfk

Describe the bug

Updating an entity of a joined-table-inheritance hierarchy dispatches OnCreate, not OnUpdate, to its parent roles. EventDrivenCommandGenerator::generateParentStoreCommand() always builds new OnCreate(...), and only the queued command depends on $isNew. So on update the parent's CreatedAt listener rewrites created_at (UPDATE documents SET … created_at = <now>), and the parent's OnUpdate listeners, such as UpdatedAt or OptimisticLock, never run.

Is this a regression?

Not checked.

To Reproduce

  1. A JTI parent Document with #[CreatedAt] and #[UpdatedAt], and a child Invoice with #[JoinedTable].
  2. Persist an Invoice, then change a field and persist it again.
  3. The UPDATE documents statement resets created_at to the current time, and updated_at stays unset.

Expected behaviour

On update the parent roles get OnUpdate, as the child does: created_at stays as it was and updated_at changes.

Media prove

Not applicable.

Database

All of them.

Your environment

cycle/entity-behavior 1.x, src/EventDrivenCommandGenerator.php:73-92.

Additional context

Found while raising coverage in #58.

Activity

  1. added
    status:to be verified
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:to be verifiedtype:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions