Skip to content

fixGH-215): Cannot query set of enums within select clause #218

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

Merged

Conversation

igdianov
Copy link
Collaborator

@igdianov igdianov commented Dec 1, 2019

Fixes #215

This PR fixes runtime error when the following query is executed using nested search criteria on selection field with EQ, NE, IN, NIN predicates:

{
  Humans {
    select {
      name
      friends(where: {appearsIn: {EQ: THE_FORCE_AWAKENS}}) {
        name
      }
    }
  }
}

Also, because of GH-216 fix, there is no longer need to use GraphQLJpaOneToManyDataFetcher for many-to-many associations. It has been removed for good. As a result, there will be improved query performance without N+1 queries generated for many-to-many associations attributes with where search criteria, i.e the above GraphQL query will generate JPQL query:

select distinct human 
  from Human as human left join fetch human.friends as generatedAlias0 
  where :param0 member of generatedAlias0.appearsIn 
  order by human.id asc

followed by SQL:

Hibernate: 
    select
        human0_.id as id2_0_0_,
        character2_.id as id2_0_1_,
        human0_.name as name3_0_0_,
        human0_.favorite_droid_id as favorite6_0_0_,
        human0_.gender_code_id as gender_c7_0_0_,
        human0_.homePlanet as homePlan4_0_0_,
        character2_.name as name3_0_1_,
        character2_.primary_function as primary_5_0_1_,
        character2_.favorite_droid_id as favorite6_0_1_,
        character2_.gender_code_id as gender_c7_0_1_,
        character2_.homePlanet as homePlan4_0_1_,
        character2_.DTYPE as DTYPE1_0_1_,
        friends1_.source_id as source_i1_2_0__,
        friends1_.friend_id as friend_i2_2_0__ 
    from
        Character human0_ 
    left outer join
        character_friends friends1_ 
            on human0_.id=friends1_.source_id 
    left outer join
        Character character2_ 
            on friends1_.friend_id=character2_.id 
    where
        human0_.DTYPE='Human' 
        and (
            ? in (
                select
                    appearsin3_.appearsIn 
                from
                    Character_appearsIn appearsin3_ 
                where
                    character2_.id=appearsin3_.Character_id
            )
        ) 
    order by
        human0_.id asc,
        character2_.name asc

@igdianov igdianov self-assigned this Dec 1, 2019
@igdianov igdianov added the bug label Dec 1, 2019
@codecov
Copy link

codecov bot commented Dec 1, 2019

Codecov Report

Merging #218 into master will increase coverage by 0.03%.
The diff coverage is 80%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #218      +/-   ##
============================================
+ Coverage     73.65%   73.69%   +0.03%     
+ Complexity      862      850      -12     
============================================
  Files            50       49       -1     
  Lines          3727     3668      -59     
  Branches        624      613      -11     
============================================
- Hits           2745     2703      -42     
+ Misses          707      700       -7     
+ Partials        275      265      -10
Impacted Files Coverage Δ Complexity Δ
...jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java 91.59% <ø> (-0.03%) 117 <0> (-1)
...hql/jpa/query/schema/impl/JpaPredicateBuilder.java 60.31% <80%> (+0.8%) 114 <0> (+2) ⬆️
.../query/schema/impl/GraphQLJpaQueryDataFetcher.java 91.48% <0%> (-1.07%) 25% <0%> (-1%)
...a/query/schema/impl/QraphQLJpaBaseDataFetcher.java 73.53% <0%> (ø) 149% <0%> (-1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6e204fc...887ed28. Read the comment docs.

@igdianov igdianov merged commit 5705b95 into master Dec 1, 2019
@igdianov igdianov deleted the fix-GH-215-cannot-query-set-of-enums-within-select-clause branch December 1, 2019 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot query set of enums within select clause: Column "GENERATEDALIAS1" not found
1 participant