diff --git a/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Eql.g4 b/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Eql.g4 index db358d673d..1a6cac83c1 100644 --- a/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Eql.g4 +++ b/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Eql.g4 @@ -1,5 +1,5 @@ /* - * Copyright 2023 the original author or authors. + * Copyright 2023-present the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ grammar Eql; * @see https://eclipse.dev/eclipselink/documentation/3.0/jpa/extensions/jpql.htm * @author Greg Turnquist * @author Christoph Strobl + * @author Jewoo Shin * @since 3.2 */ } @@ -677,6 +678,7 @@ constructor_name literal : STRINGLITERAL + | CHARACTER | JAVASTRINGLITERAL | INTLITERAL | FLOATLITERAL diff --git a/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Jpql.g4 b/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Jpql.g4 index 4e7bd9e466..7531ab49d7 100644 --- a/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Jpql.g4 +++ b/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Jpql.g4 @@ -1,5 +1,5 @@ /* - * Copyright 2011-2023 the original author or authors. + * Copyright 2011-present the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ grammar Jpql; * @see https://github.com/jakartaee/persistence/blob/master/spec/src/main/asciidoc/ch04-query-language.adoc#bnf * @author Greg Turnquist * @author Christoph Strobl + * @author Jewoo Shin * @since 3.1 */ } @@ -670,6 +671,7 @@ constructor_name literal : STRINGLITERAL + | CHARACTER | JAVASTRINGLITERAL | INTLITERAL | FLOATLITERAL diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpqlQueryRendererTckTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpqlQueryRendererTckTests.java index 9a5297f19d..d22ea39404 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpqlQueryRendererTckTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpqlQueryRendererTckTests.java @@ -250,6 +250,22 @@ void specialOperators() { assertQuery("SELECT p FROM Phone p WHERE FUNCTION('TO_NUMBER', p.areaCode) > 613"); } + @Test // GH-4278 + void singleCharacterLiteralAsCollectionMemberExpression() { + + assertQuery("SELECT e FROM Employee e WHERE 'c' MEMBER OF e.responsibilities"); + assertQuery("SELECT e FROM Employee e WHERE 'c' NOT MEMBER OF e.responsibilities"); + + assertQuery(""" + SELECT e + FROM Employee e + WHERE EXISTS (SELECT p FROM Person p WHERE 'c' MEMBER OF p.nicknames) + """); + + assertQuery("UPDATE Employee e SET e.name = 'x' WHERE 'c' MEMBER OF e.responsibilities"); + assertQuery("DELETE FROM Employee e WHERE 'c' MEMBER OF e.responsibilities"); + } + @Test // GH-3314 void isNullAndIsNotNull() {