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

Fixed bug where alias of filter clause did not match alias of inner query. #1924

Merged
merged 1 commit into from Aug 6, 2020

Conversation

guitaristmo
Copy link

Problem

An embedded filter where the filter had a different alias than the query, if it was not placed after a .nested, would throw an exception as the filter alias would be different than the alias of the query, and the query was not being wrapped up.

Solution

Only add the filter clause directly into the existing flattenSqlQuery if the filter alias matched an alias of one of the fromContext's.
Do so by adding a condition in the filter case to check the alias before adding the clause directly into the base flattenSqlQuery.
Otherwise, nest the inner query just like if there was already an existent filter clause.
Same for SortBy.

@getquill/maintainers

@guitaristmo guitaristmo closed this Aug 5, 2020
@guitaristmo guitaristmo reopened this Aug 5, 2020
@guitaristmo
Copy link
Author

Fixed issue where a filter on an entity in a map was trying to nest the inner query, even though the filter also referred to the outside entity.
The condition for adding a filter clause directly into a flattenSqlQuery now checks to make sure that only if the filter alias is used in the body, does it need to be in the fromContext.

@guitaristmo guitaristmo force-pushed the master branch 3 times, most recently from 7284b8f to 56646d5 Compare August 5, 2020 20:50
…clauses to the existing flattenSqlQuery if the aliases in the clauses are compatible.

Added two tests for embedded filter and sortBy
Cleaned up last test in ExpandNestedQueriesSpec
@deusaquilus
Copy link
Collaborator

Looks good!

@deusaquilus deusaquilus merged commit 7e7648d into zio:master Aug 6, 2020
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.

None yet

2 participants