-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(grammar): Support TRUNCATE TABLE statement
- Loading branch information
Showing
11 changed files
with
139 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
zpa-checks/src/integrationTest/resources/expected/utPLSQL2/CommitRollbackCheck.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
{ | ||
"examples/mybooks_setup.sql" : [ | ||
55, | ||
61, | ||
67 | ||
], | ||
"examples/test_te_employee.pkb" : [ | ||
191, | ||
237, | ||
|
22 changes: 22 additions & 0 deletions
22
zpa-checks/src/integrationTest/resources/expected/utPLSQL2/ExplicitInParameterCheck.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
zpa-checks/src/integrationTest/resources/expected/utPLSQL2/InsertWithoutColumnsCheck.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"examples/mybooks_setup.sql" : [ | ||
19, | ||
20, | ||
21, | ||
22, | ||
23, | ||
54 | ||
], | ||
"source/ut_receq.pkb" : [ | ||
245, | ||
255 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...s/src/integrationTest/resources/expected/utPLSQL2/QueryWithoutExceptionHandlingCheck.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"examples/mybooks_setup.sql" : [ | ||
48 | ||
], | ||
"examples/te_employee.pkb" : [ | ||
863, | ||
874, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
199, | ||
238 | ||
], | ||
"examples/mybooks_setup.sql" : [ | ||
41, | ||
72 | ||
], | ||
"examples/test_te_employee.pkb" : [ | ||
179 | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
zpa-core/src/test/kotlin/org/sonar/plugins/plsqlopen/api/ddl/TruncateTableTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* Z PL/SQL Analyzer | ||
* Copyright (C) 2015-2024 Felipe Zorzo | ||
* mailto:felipe AT felipezorzo DOT com DOT br | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.sonar.plugins.plsqlopen.api.ddl | ||
|
||
import com.felipebz.flr.tests.Assertions.assertThat | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.sonar.plugins.plsqlopen.api.DdlGrammar | ||
import org.sonar.plugins.plsqlopen.api.RuleTest | ||
|
||
class TruncateTableTest : RuleTest() { | ||
|
||
@BeforeEach | ||
fun init() { | ||
setRootRule(DdlGrammar.TRUNCATE_TABLE) | ||
} | ||
|
||
@Test | ||
fun matchesSimpleTruncate() { | ||
assertThat(p).matches("truncate table foo;") | ||
} | ||
|
||
@Test | ||
fun matchesTruncatePreserveMaterializedViewLog() { | ||
assertThat(p).matches("truncate table foo preserve materialized view log;") | ||
} | ||
|
||
@Test | ||
fun matchesTruncatePurgeMaterializedViewLog() { | ||
assertThat(p).matches("truncate table foo purge materialized view log;") | ||
} | ||
|
||
@Test | ||
fun matchesTruncateDropStorage() { | ||
assertThat(p).matches("truncate table foo drop storage;") | ||
assertThat(p).matches("truncate table foo drop all storage;") | ||
} | ||
|
||
@Test | ||
fun matchesTruncateReuseStorage() { | ||
assertThat(p).matches("truncate table foo reuse storage;") | ||
} | ||
|
||
@Test | ||
fun matchesTruncateCascade() { | ||
assertThat(p).matches("truncate table foo cascade;") | ||
} | ||
|
||
@Test | ||
fun matchesLongTruncate() { | ||
assertThat(p).matches("truncate table sch.foo purge materialized view log drop all storage cascade;") | ||
} | ||
|
||
} |