Additional Fixes for Embedded Entities in Nested Queries #1628
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1627
In many ways, this represents a continuation of #1613. In #1613, schema protraction was introduced in order to solve the situation where a
querySchema
needs to be propagated for an entity that is wrapped into a tuple or case class e.g:This PR represents a fix for the opposite case, i.e. where an entity from a super-class is sub-selected:
Several additional changes to Schema Protraction needed to be made for this purpose including:
Entity
representing an entity whose embedded element is being extracted. This transformation is roughly:Or more sussinctly:
That is to say, every PropertyAlias path to
emb
inside of the host entity needs to be extracted from te Entity.An additional change that needed to be made was the introduction of invisible identities. This was specifically needed for certain queries where one embedded entity was mapped into another. For instance:
In this kind of situation
p.emb
(in the second map clause) needs to be directly sub-selected and it's properties are then appended to it in theExpandNestedQueries
phase. Since the default-case ofExpandNestedQueries
(inExpandSelect
) is to take the selected property directly i.e:We needed to enhance Ident to be able to be invisible and then propagate this property:
Many tests of this functionality were introduced that unwrap as well as unwrap and rewrap entities.
These kinds of changes are not necessarily the most "savory" form of AST manipulation and a Typed-AST would forego many of these issues. For example, if we knew that the
emb
identity in the query above is a nested entity, we could just expand it into it's component properties on the spot (i.e. inside ofExpandDistinct
as opposed to having to make the property invisible inside of recursive calls ofExpandNestedQueries
.README.md
if applicable[WIP]
to the pull request title if it's work in progresssbt scalariformFormat test:scalariformFormat
to make sure that the source files are formatted@getquill/maintainers