diff --git a/zpa-checks/src/integrationTest/resources/expected/oracle-database_23/ParsingErrorCheck.json b/zpa-checks/src/integrationTest/resources/expected/oracle-database_23/ParsingErrorCheck.json index 307bd8ab..279b2c17 100644 --- a/zpa-checks/src/integrationTest/resources/expected/oracle-database_23/ParsingErrorCheck.json +++ b/zpa-checks/src/integrationTest/resources/expected/oracle-database_23/ParsingErrorCheck.json @@ -2939,36 +2939,6 @@ "sqlrf/annotations_clause-5.sql" : [ 3 ], - "sqlrf/boolean_and_agg-2.sql" : [ - 4 - ], - "sqlrf/boolean_and_agg-3.sql" : [ - 4 - ], - "sqlrf/boolean_and_agg-4.sql" : [ - 4 - ], - "sqlrf/boolean_and_agg-5.sql" : [ - 4 - ], - "sqlrf/boolean_and_agg-6.sql" : [ - 4 - ], - "sqlrf/boolean_or_agg-2.sql" : [ - 4 - ], - "sqlrf/boolean_or_agg-3.sql" : [ - 4 - ], - "sqlrf/boolean_or_agg-4.sql" : [ - 4 - ], - "sqlrf/boolean_or_agg-5.sql" : [ - 4 - ], - "sqlrf/boolean_or_agg-6.sql" : [ - 4 - ], "sqlrf/constraint-1.sql" : [ 10 ], diff --git a/zpa-checks/src/integrationTest/resources/expected/oracle-database_23/SameConditionCheck.json b/zpa-checks/src/integrationTest/resources/expected/oracle-database_23/SameConditionCheck.json new file mode 100644 index 00000000..febd04d7 --- /dev/null +++ b/zpa-checks/src/integrationTest/resources/expected/oracle-database_23/SameConditionCheck.json @@ -0,0 +1,9 @@ +{ + "sqlrf/boolean_and_agg-6.sql" : [ + 2, + 2 + ], + "sqlrf/boolean_or_agg-6.sql" : [ + 2 + ] +} \ No newline at end of file diff --git a/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/ConditionsGrammar.kt b/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/ConditionsGrammar.kt index 0bf71a9c..a5835705 100644 --- a/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/ConditionsGrammar.kt +++ b/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/ConditionsGrammar.kt @@ -22,6 +22,7 @@ package org.sonar.plugins.plsqlopen.api import com.felipebz.flr.grammar.GrammarRuleKey import org.sonar.plsqlopen.sslr.PlSqlGrammarBuilder import org.sonar.plugins.plsqlopen.api.PlSqlGrammar.CONCATENATION_EXPRESSION +import org.sonar.plugins.plsqlopen.api.PlSqlGrammar.NULL_LITERAL import org.sonar.plugins.plsqlopen.api.PlSqlGrammar.OBJECT_REFERENCE import org.sonar.plugins.plsqlopen.api.PlSqlKeyword.* @@ -39,6 +40,7 @@ enum class ConditionsGrammar : GrammarRuleKey { // conditions RELATIONAL_CONDITION, + BOOLEAN_TEST_CONDITION, LIKE_CONDITION, BETWEEN_CONDITION, MULTISET_CONDITION, @@ -71,6 +73,10 @@ enum class ConditionsGrammar : GrammarRuleKey { CONCATENATION_EXPRESSION, RELATIONAL_OPERATOR, CONCATENATION_EXPRESSION ).skip() + b.rule(BOOLEAN_TEST_CONDITION).define( + CONCATENATION_EXPRESSION, IS, b.optional(NOT), b.firstOf(NULL_LITERAL, TRUE, FALSE) + ) + b.rule(LIKE_CONDITION).define( CONCATENATION_EXPRESSION, b.optional(NOT), LIKE, @@ -244,6 +250,7 @@ enum class ConditionsGrammar : GrammarRuleKey { b.rule(CONDITION).define( b.firstOf( RELATIONAL_CONDITION, + BOOLEAN_TEST_CONDITION, LIKE_CONDITION, BETWEEN_CONDITION, MULTISET_CONDITION, diff --git a/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/PlSqlGrammar.kt b/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/PlSqlGrammar.kt index 82bd317a..b32a4554 100644 --- a/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/PlSqlGrammar.kt +++ b/zpa-core/src/main/kotlin/org/sonar/plugins/plsqlopen/api/PlSqlGrammar.kt @@ -793,7 +793,6 @@ enum class PlSqlGrammar : GrammarRuleKey { b.rule(POSTFIX_EXPRESSION).define(OBJECT_REFERENCE, b.optional(b.firstOf( - b.sequence(IS, b.optional(NOT), NULL_LITERAL), ANALYTIC_CLAUSE, b.sequence(KEEP_CLAUSE, b.optional(ANALYTIC_CLAUSE))))).skipIfOneChild() diff --git a/zpa-core/src/test/kotlin/org/sonar/plugins/plsqlopen/api/expressions/OtherExpressionTest.kt b/zpa-core/src/test/kotlin/org/sonar/plugins/plsqlopen/api/expressions/OtherExpressionTest.kt index d2c95505..d8857fc8 100644 --- a/zpa-core/src/test/kotlin/org/sonar/plugins/plsqlopen/api/expressions/OtherExpressionTest.kt +++ b/zpa-core/src/test/kotlin/org/sonar/plugins/plsqlopen/api/expressions/OtherExpressionTest.kt @@ -68,6 +68,26 @@ class OtherExpressionTest : RuleTest() { assertThat(p).matches("var is not null") } + @Test + fun matchesIsTrue() { + assertThat(p).matches("var is true") + } + + @Test + fun matchesIsNotTrue() { + assertThat(p).matches("var is not true") + } + + @Test + fun matchesIsFalse() { + assertThat(p).matches("var is false") + } + + @Test + fun matchesIsNotFalse() { + assertThat(p).matches("var is not false") + } + @Test fun matchesBasicIn() { assertThat(p).matches("var in (1)")