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 #2313 - Formalisation of fetch models #2322

Open
wants to merge 116 commits into
base: 2.0.0-SNAPSHOT
Choose a base branch
from

Conversation

homedirectory
Copy link
Contributor

@homedirectory homedirectory commented Oct 2, 2024

Resolve #2313

…pertyValidator

RangePropertyValidator used a separate EntityUtils.validate*Range
method for each supported property type. In RangeValidatorFunction this
role is played by a single ComparableValidator, which is possible
because all supported types implement Comparable. There were only 2
non-trivial cases:
* Date: isAfter has the same semantics as compareTo
* DateTime: isAfter has the same semantics as compareTo but also treats
  null as now. But since EntityUtils.validateDateTimeRange explicitly
  checks for non-nullness, this difference can be disregarded. And
  anyway, DateTime is no longer a supported property type.
…uring yields enhancement

The FIXME is resovled: retrieval models now recognise presence of ID in
synthetic entities.

As IRetrievalModel.containsOnlyTotals had been introduced only for the
purpose of special handling of ID, it is no longer needed as well.
Optional.filter().isPresent() is more efficient than Optional.map()
because it doesn't perform allocation.
Introduce method signature with(propName) which explores entities by
default. This change does not affect semantics.

         private void includeAllCompositeKeyMembers() {
             entityMetadataUtils.compositeKeyMembers(entityMetadata)
-                    .forEach(pm -> with(pm.name(), !pm.type().isEntity()));
+                    .forEach(pm -> with(pm.name()));
         }

The above piece is also unaffected, as entity exploration skipping would
have been true only for non-entity typed properties...
Optional.filter().isPresent() is more efficient than Optional.map()
because it doesn't perform allocation.
It had already been effectively immutable due to the use of method
`copy` but still used mutable data structures for internal state, which
was not a strong invariant.
@01es 01es marked this pull request as draft October 4, 2024 07:21
… property

The main change is in Source1BasedOnQueries.produceQuerySourceInfoForEntityType.

Implementin this required IDomainMetadata to be accessible to
Source1BasedOnQueries. Its `transform` method takes a
TransformationContextFromStage1To2 as an argument, so I considered it
reasonable to enhance that type with a IDomainMetadata component. The
bulk of changes is related to this enhancement.
Prior to this change, the following example query would have failed:

select(select(Vehicle.class).yieldAll().modelAsAggregate())
    .yield().prop("id").as("id")
    .modelAsEntity(Vehicle.class)
QuerySourceInfoProvider is more suited to contain this method as it is
similar to other methods declared by it - most of them produce instances
of QuerySourceInfo.
And the returned null wasn't being handled.
@homedirectory homedirectory marked this pull request as ready for review October 9, 2024 11:05
@homedirectory homedirectory requested a review from 01es October 17, 2024 08:48
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.

1 participant