diff --git a/.travis.yml b/.travis.yml index 6cba97ed6..c0d692ce8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: java sudo: required jdk: - - oraclejdk8 + - openjdk8 - openjdk11 services: diff --git a/CHANGELOG.md b/CHANGELOG.md index 6102840ee..6228411ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change Log -## 0.3.34-SNAPSHOT +## 0.3.35-SNAPSHOT +* feat(GH-204): added LOWER predicate for case insensitive match (#206) [6ff6992](https://github.com/introproventures/graphql-jpa-query/commit/6ff699284a2340de0f22d7a5e447444e8347f0f7) +* fix(travis): changed to openjdk8 [8f1e36c](https://github.com/introproventures/graphql-jpa-query/commit/8f1e36c302a1083f11ff4342e96005ead23e38ef) +* docs(README): polish description [skip travis] [4ad2ad2](https://github.com/introproventures/graphql-jpa-query/commit/4ad2ad245659f3c6b78a9b119c1e791d99129925) * fix(GH-193): Fixed error in GQL Queries when `total` or `pages` is included with condition `where: NOT_EXISTS` or `EXISTS` (#201) [40a0e2d](https://github.com/introproventures/graphql-jpa-query/commit/40a0e2d844854f8888e3502d1d6434db9cb1dd7e) * fix(GH-198): adedd support for fetching optional element collections elements (#200) [5d99c3b](https://github.com/introproventures/graphql-jpa-query/commit/5d99c3b4629521ebee2788c6b877250c279c8bf2) * fix: Added support for binding orderBy argument as a variable (#195) [2a01382](https://github.com/introproventures/graphql-jpa-query/commit/2a0138237cb639427f169b18f6b6f159c430afac) diff --git a/graphql-jpa-query-annotations/pom.xml b/graphql-jpa-query-annotations/pom.xml index 310c94a5a..2fcdc6188 100644 --- a/graphql-jpa-query-annotations/pom.xml +++ b/graphql-jpa-query-annotations/pom.xml @@ -6,7 +6,7 @@ com.introproventures graphql-jpa-query-dependencies - 0.3.34-SNAPSHOT + 0.3.35-SNAPSHOT ../graphql-jpa-query-dependencies diff --git a/graphql-jpa-query-autoconfigure/pom.xml b/graphql-jpa-query-autoconfigure/pom.xml index 0e47a05d5..cab9e80f8 100644 --- a/graphql-jpa-query-autoconfigure/pom.xml +++ b/graphql-jpa-query-autoconfigure/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-build - 0.3.34-SNAPSHOT + 0.3.35-SNAPSHOT ../graphql-jpa-query-build graphql-jpa-query-autoconfigure diff --git a/graphql-jpa-query-boot-starter/pom.xml b/graphql-jpa-query-boot-starter/pom.xml index 6560dfa4d..29da7de4c 100644 --- a/graphql-jpa-query-boot-starter/pom.xml +++ b/graphql-jpa-query-boot-starter/pom.xml @@ -7,7 +7,7 @@ com.introproventures graphql-jpa-query-build - 0.3.34-SNAPSHOT + 0.3.35-SNAPSHOT ../graphql-jpa-query-build diff --git a/graphql-jpa-query-build/pom.xml b/graphql-jpa-query-build/pom.xml index 2a2fca240..f3dad9997 100644 --- a/graphql-jpa-query-build/pom.xml +++ b/graphql-jpa-query-build/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-dependencies - 0.3.34-SNAPSHOT + 0.3.35-SNAPSHOT ../graphql-jpa-query-dependencies graphql-jpa-query-build diff --git a/graphql-jpa-query-dependencies/pom.xml b/graphql-jpa-query-dependencies/pom.xml index 6709c8b19..9489c27b1 100644 --- a/graphql-jpa-query-dependencies/pom.xml +++ b/graphql-jpa-query-dependencies/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query - 0.3.34-SNAPSHOT + 0.3.35-SNAPSHOT .. graphql-jpa-query-dependencies diff --git a/graphql-jpa-query-example-merge/pom.xml b/graphql-jpa-query-example-merge/pom.xml index cf4d61ac6..71dbf360f 100644 --- a/graphql-jpa-query-example-merge/pom.xml +++ b/graphql-jpa-query-example-merge/pom.xml @@ -7,7 +7,7 @@ com.introproventures graphql-jpa-query-build - 0.3.34-SNAPSHOT + 0.3.35-SNAPSHOT ../graphql-jpa-query-build diff --git a/graphql-jpa-query-example-model-books/pom.xml b/graphql-jpa-query-example-model-books/pom.xml index ff711c100..2ebb6c9c5 100644 --- a/graphql-jpa-query-example-model-books/pom.xml +++ b/graphql-jpa-query-example-model-books/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-build - 0.3.34-SNAPSHOT + 0.3.35-SNAPSHOT ../graphql-jpa-query-build graphql-jpa-query-example-model-books diff --git a/graphql-jpa-query-example-model-starwars/pom.xml b/graphql-jpa-query-example-model-starwars/pom.xml index 68994082c..4b48fc5fd 100644 --- a/graphql-jpa-query-example-model-starwars/pom.xml +++ b/graphql-jpa-query-example-model-starwars/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-build - 0.3.34-SNAPSHOT + 0.3.35-SNAPSHOT ../graphql-jpa-query-build diff --git a/graphql-jpa-query-example-simple/pom.xml b/graphql-jpa-query-example-simple/pom.xml index d240d315e..22dfff6c0 100644 --- a/graphql-jpa-query-example-simple/pom.xml +++ b/graphql-jpa-query-example-simple/pom.xml @@ -7,7 +7,7 @@ com.introproventures graphql-jpa-query-build - 0.3.34-SNAPSHOT + 0.3.35-SNAPSHOT ../graphql-jpa-query-build diff --git a/graphql-jpa-query-graphiql/pom.xml b/graphql-jpa-query-graphiql/pom.xml index b0c5c492b..47b97bd48 100644 --- a/graphql-jpa-query-graphiql/pom.xml +++ b/graphql-jpa-query-graphiql/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query - 0.3.34-SNAPSHOT + 0.3.35-SNAPSHOT graphql-jpa-query-graphiql \ No newline at end of file diff --git a/graphql-jpa-query-schema/pom.xml b/graphql-jpa-query-schema/pom.xml index b2fbee6df..63cc7858b 100644 --- a/graphql-jpa-query-schema/pom.xml +++ b/graphql-jpa-query-schema/pom.xml @@ -5,7 +5,7 @@ com.introproventures graphql-jpa-query-build - 0.3.34-SNAPSHOT + 0.3.35-SNAPSHOT ../graphql-jpa-query-build diff --git a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java index 8e7708f55..c1f081c03 100644 --- a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java +++ b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java @@ -515,6 +515,12 @@ private GraphQLInputType getWhereAttributeType(Attribute attribute) { .type(getAttributeInputType(attribute)) .build() ) + .field(GraphQLInputObjectField.newInputObjectField() + .name(Criteria.LOWER.name()) + .description("Case insensitive match criteria") + .type(getAttributeInputType(attribute)) + .build() + ) .field(GraphQLInputObjectField.newInputObjectField() .name(Criteria.CASE.name()) .description("Case sensitive match criteria") diff --git a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/JpaPredicateBuilder.java b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/JpaPredicateBuilder.java index f823e021a..1b79ed7bb 100644 --- a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/JpaPredicateBuilder.java +++ b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/JpaPredicateBuilder.java @@ -129,7 +129,7 @@ protected Predicate getStringPredicate(Path root, PredicateFilter filter if(arrayValuePredicate == null) { String compareValue = filter.getValue().toString(); Expression fieldValue = root; - + if (filter.getCriterias().contains(PredicateFilter.Criteria.IN)) { CriteriaBuilder.In in = cb.in(root); return in.value(compareValue); @@ -141,6 +141,10 @@ protected Predicate getStringPredicate(Path root, PredicateFilter filter if (filter.getCriterias().contains(PredicateFilter.Criteria.EQ)) { return cb.equal(fieldValue, compareValue); } + else if (filter.getCriterias().contains(PredicateFilter.Criteria.LOWER)) { + return cb.equal(cb.lower(fieldValue), + compareValue.toLowerCase()); + } else if (filter.getCriterias().contains(PredicateFilter.Criteria.NE)) { return cb.notEqual(fieldValue, compareValue); } diff --git a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/PredicateFilter.java b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/PredicateFilter.java index 8e7080ced..b4840ec39 100644 --- a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/PredicateFilter.java +++ b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/PredicateFilter.java @@ -60,10 +60,13 @@ public enum Criteria { * case sensitive (strings) */ CASE, + /** + * case insensitive match + *
LOWER(field) = LOWER(SEARCH)
+ */ + LOWER, /** * end of the string matches - *
LOWER(field) LIKE LOWER(SEARCH)
if not set then case - * insensitive match */ ENDS, /** diff --git a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/GraphQLExecutorTests.java b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/GraphQLExecutorTests.java index b909ff962..cc4a35591 100644 --- a/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/GraphQLExecutorTests.java +++ b/graphql-jpa-query-schema/src/test/java/com/introproventures/graphql/jpa/query/schema/GraphQLExecutorTests.java @@ -1550,6 +1550,38 @@ public void queryWithEQMatchingCase() { assertThat(result.toString()).isEqualTo(expected); } + @Test + public void queryWithLOWERNotMatchingCase() { + //given: + String query = "query { Books ( where: { title: {LOWER: \"WAR AND PEACE\"}}) { select { id title} } }"; + + String expected = "{Books={select=[" + + "{id=2, title=War and Peace}" + + "]}}"; + + //when: + Object result = executor.execute(query).getData(); + + //then: + assertThat(result.toString()).isEqualTo(expected); + } + + @Test + public void queryWithLOWERMatchingCase() { + //given: + String query = "query { Books ( where: { title: {LOWER: \"War and Peace\"}}) { select { id title} } }"; + + String expected = "{Books={select=[" + + "{id=2, title=War and Peace}" + + "]}}"; + + //when: + Object result = executor.execute(query).getData(); + + //then: + assertThat(result.toString()).isEqualTo(expected); + } + @Test public void shouldNotReturnStaleCacheResultsFromPreviousQueryForCollectionCriteriaExpression() { //given: diff --git a/graphql-jpa-query-web/pom.xml b/graphql-jpa-query-web/pom.xml index 37583511e..f3a3d096c 100644 --- a/graphql-jpa-query-web/pom.xml +++ b/graphql-jpa-query-web/pom.xml @@ -3,7 +3,7 @@ com.introproventures graphql-jpa-query-build - 0.3.34-SNAPSHOT + 0.3.35-SNAPSHOT ../graphql-jpa-query-build graphql-jpa-query-web diff --git a/pom.xml b/pom.xml index 3adcbf567..1519cee7b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.introproventures graphql-jpa-query - 0.3.34-SNAPSHOT + 0.3.35-SNAPSHOT pom