Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle "inverse one to one" without "placeholder" solution #855

Merged
merged 2 commits into from
Mar 30, 2025

Conversation

nikophil
Copy link
Member

@nikophil nikophil commented Mar 28, 2025

This PR will hopefully fix every problem with "inverse one to one", in a simpler way than the "placeholder" solution which introduced a lot of glitches.

now, the inverse one to one is resolved this way:

- is the field nullable in the current object ?
    -> add `null` to the current field, and defer the creation of the other object after the instantiation

- otherwise, is the inverse field nullable ?
    -> create the inverse object now, but set null the inverse relationship

- otherwise, throw an exception: a bi-directional one-to-one relationship with both objects nullable introduces circular dependency

fixes #835

@nikophil nikophil changed the base branch from 2.x to 2.3.x March 28, 2025 06:37
@nikophil nikophil changed the title fix/remove placeholder fix: handle "inverse one to one" without "placeholder" solution Mar 28, 2025
@nikophil nikophil force-pushed the fix/remove-placeholder branch from ba5bbca to 2173a48 Compare March 28, 2025 12:46
@nikophil nikophil requested a review from kbond March 30, 2025 08:35
@nikophil nikophil force-pushed the fix/remove-placeholder branch from 2173a48 to b9a7c6b Compare March 30, 2025 10:04
Copy link
Member

@kbond kbond left a comment

Choose a reason for hiding this comment

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

👍🏻

@nikophil nikophil merged commit e5c6973 into zenstruck:2.3.x Mar 30, 2025
132 checks passed
@nikophil nikophil deleted the fix/remove-placeholder branch March 30, 2025 14:25
nikophil added a commit to nikophil/foundry that referenced this pull request Mar 31, 2025
* 2.3.x:
  bot: fix cs [skip ci]
  fix: handle "inverse one to one" without "placeholder" solution (zenstruck#855)
  bot: fix cs [skip ci]
  feat: add force() helper (zenstruck#854)
  chore: add support for doctrine/persistence 4 (zenstruck#852)
  fix: fix doctrine collection with union/intersection type (zenstruck#847)
  bot: fix cs [skip ci]
  fix: bug with factory collectin of persistent factory in unit test (zenstruck#842)
  fix: use Doctrine metadata event when persist is disabled (zenstruck#841)
  minor: add parameter "withAutoRefresh" to unproxy() function (zenstruck#840)
  chore: upgrade also dama when upgrading phpunit version (zenstruck#839)
  bot: fix cs [skip ci]
  changelog: update [skip ci]
  fix: can call ->create() in after persist callback (zenstruck#833)
@nikophil nikophil mentioned this pull request Mar 31, 2025
nikophil added a commit that referenced this pull request Mar 31, 2025
* fix: can call ->create() in after persist callback (#833)

* changelog: update [skip ci]

* bot: fix cs [skip ci]

* chore: upgrade also dama when upgrading phpunit version (#839)

* minor: add parameter "withAutoRefresh" to unproxy() function (#840)

* fix: use Doctrine metadata event when persist is disabled (#841)

* fix: bug with factory collectin of persistent factory in unit test (#842)

* bot: fix cs [skip ci]

* fix: fix doctrine collection with union/intersection type (#847)

* fix: fix hydrator with doctrine collections using intersection types

* feat: add unit tests for hydrator

* test: add functional test for union type

---------

Co-authored-by: Nicolas PHILIPPE <[email protected]>

* chore: add support for doctrine/persistence 4 (#852)

* feat: add force() helper (#854)

* bot: fix cs [skip ci]

* fix: handle "inverse one to one" without "placeholder" solution (#855)

* fix: one to one no more uses placeholder

* fix: use different error message if types are missing

* bot: fix cs [skip ci]

* changelog: update

---------

Co-authored-by: nikophil <[email protected]>
Co-authored-by: Maarten de Boer <[email protected]>
Co-authored-by: chris <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants