Skip to content

Commit

Permalink
fix: Add missing set operators from Oracle 20c+ (minus all, intersect…
Browse files Browse the repository at this point in the history
… all, except, and except all)
  • Loading branch information
felipebz committed Feb 15, 2024
1 parent 9c3a4f5 commit 1254a36
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ enum class DmlGrammar : GrammarRuleKey {
b.rule(SELECT_EXPRESSION).define(
b.optional(SUBQUERY_FACTORING_CLAUSE),
QUERY_BLOCK,
b.zeroOrMore(b.firstOf(MINUS_KEYWORD, INTERSECT, b.sequence(UNION, b.optional(ALL))), QUERY_BLOCK),
b.zeroOrMore(b.firstOf(MINUS_KEYWORD, INTERSECT, UNION, EXCEPT), b.optional(ALL), QUERY_BLOCK),
b.optional(b.firstOf(
b.sequence(ORDER_BY_CLAUSE, b.optional(b.firstOf(FOR_UPDATE_CLAUSE, ROW_LIMITING_CLAUSE))),
ROW_LIMITING_CLAUSE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,40 @@ class SelectExpressionTest : RuleTest() {

@Test
fun matchesSelectWithMinus() {
assertThat(p).matches("select 1 from dual minus select 2 from dual")
assertThat(p).matches("(select 1 from dual) minus (select 2 from dual)")
}

@Test
fun matchesSelectWithMinusAll() {
assertThat(p).matches("select 1 from dual minus all select 2 from dual")
assertThat(p).matches("(select 1 from dual) minus all (select 2 from dual)")
}

@Test
fun matchesSelectWithIntersect() {
assertThat(p).matches("select 1 from dual intersect select 2 from dual")
assertThat(p).matches("(select 1 from dual) intersect (select 2 from dual)")
}

@Test
fun matchesSelectWithIntersectAll() {
assertThat(p).matches("select 1 from dual intersect all select 2 from dual")
assertThat(p).matches("(select 1 from dual) intersect all (select 2 from dual)")
}

@Test
fun matchesSelectWithExcept() {
assertThat(p).matches("select 1 from dual except select 2 from dual")
assertThat(p).matches("(select 1 from dual) except (select 2 from dual)")
}

@Test
fun matchesSelectWithExceptAll() {
assertThat(p).matches("select 1 from dual except all select 2 from dual")
assertThat(p).matches("(select 1 from dual) except all (select 2 from dual)")
}

@Test
fun matchesSelectCountDistinct() {
assertThat(p).matches("select count(distinct foo) from dual")
Expand Down

0 comments on commit 1254a36

Please sign in to comment.