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

Issue/1828 aggregate ref with convertable #1829

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

schauder
Copy link
Contributor

@schauder schauder commented Jul 5, 2024

This resolves the issue at hand, but in an ad hoc way, which feels very wrong. I still feel like I/we are doing something wrong with these conversions.

The problem here is:

Given an AggregateReference<E, C> with E an entity and C a type for which a write converter is regsitered, we currently determine C as the target type of the conversion.
With this information we call the AggregateReference converter, which extracts the id value and determines it is done, because the result is of the desired target type.

This is demonstrated by the failing new unit test.

The integration test is fixed by just slapping a getPotentiallyConvertedSimpleWrite on the already converted type, which looks exactly for the customconversions, that we currently missing.

But this means we do 2 custom conversions. Why 2? Why not arbitrary many?

@mp911de
Copy link
Member

mp911de commented Oct 29, 2024

But this means we do 2 custom conversions. Why 2? Why not arbitrary many?

It should be exactly one to apply ConversionService. Converting AggregateReference via ConversionService from AggregateReference<S, …> to AggregateReference<T, …> isn't what we're looking for. Instead, we want to store the reference and using its identifier. Implicitly applying conversion, also without further context of identifiers creates a big ball of mud that obfuscates the actual processing.

Instead, we should be explicit that we work with a reference and apply domain-specific rules of the underlying entity.

For the time being, we can adopt the fix to align with the remainder of conversion. However, we should refactor AggregateReference into a clean approach.

@schauder schauder force-pushed the issue/1828-aggregate-ref-with-convertable branch from 38d2e6b to 08c1900 Compare November 6, 2024 11:48
@schauder
Copy link
Contributor Author

schauder commented Nov 6, 2024

I rebased the PR with the intend to clean it up. But it turns out the solution collides with the resolution of #1842

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants