Correct grammar to disallow filter clause in quantified subqueries

Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
Jan Schatteman 2021-07-07 14:46:03 +02:00 committed by Christian Beikov
parent 78209dc506
commit 00a8a6c20e
2 changed files with 9 additions and 6 deletions

View File

@ -710,11 +710,13 @@ countFunction
;
everyFunction
: (EVERY|ALL) LEFT_PAREN (predicate | subQuery) RIGHT_PAREN filterClause?
: (EVERY|ALL) LEFT_PAREN predicate RIGHT_PAREN filterClause?
| (EVERY|ALL) LEFT_PAREN subQuery RIGHT_PAREN
;
anyFunction
: (ANY|SOME) LEFT_PAREN (predicate | subQuery) RIGHT_PAREN filterClause?
: (ANY|SOME) LEFT_PAREN predicate RIGHT_PAREN filterClause?
| (ANY|SOME) LEFT_PAREN subQuery RIGHT_PAREN
;
filterClause

View File

@ -10,6 +10,7 @@ import java.util.Date;
import org.hibernate.query.Query;
import org.hibernate.query.SemanticException;
import org.hibernate.query.sqm.ParsingException;
import org.hibernate.testing.orm.domain.StandardDomainModel;
import org.hibernate.testing.orm.domain.gambit.EntityOfBasics;
@ -245,11 +246,11 @@ public class AggregateFilterClauseTest {
Exception e = Assertions.assertThrows(
IllegalArgumentException.class,
() -> {
session.createQuery( "select every( eob.theInteger > 0 ) filter ( where select 1 ) from EntityOfBasics eob" );
session.createQuery( "select every( select 1 ) filter ( where eob.theBoolean = false ) from EntityOfBasics eob" );
}
);
assertEquals( SemanticException.class, e.getCause().getClass() );
assertEquals( ParsingException.class, e.getCause().getClass() );
}
);
scope.inTransaction(
@ -257,11 +258,11 @@ public class AggregateFilterClauseTest {
Exception e = Assertions.assertThrows(
IllegalArgumentException.class,
() -> {
session.createQuery( "select any( eob.theInteger > 0 ) filter ( where select 1 ) from EntityOfBasics eob" );
session.createQuery( "select any( select 1 ) filter ( where eob.theBoolean = false ) from EntityOfBasics eob" );
}
);
assertEquals( SemanticException.class, e.getCause().getClass() );
assertEquals( ParsingException.class, e.getCause().getClass() );
}
);
}