File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
main/java/net/sf/jsqlparser/statement/truncate
test/java/net/sf/jsqlparser/statement/truncate Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ public void setCascade(boolean c){
56
56
57
57
@ Override
58
58
public String toString () {
59
- if (cascade == true ){
59
+ if (cascade ){
60
60
return "TRUNCATE TABLE " + table +" CASCADE" ;
61
61
}
62
62
return "TRUNCATE TABLE " + table ;
Original file line number Diff line number Diff line change 2
2
3
3
import java .io .StringReader ;
4
4
5
+ import static net .sf .jsqlparser .test .TestUtils .*;
6
+ import net .sf .jsqlparser .*;
7
+
5
8
import net .sf .jsqlparser .parser .CCJSqlParserManager ;
6
9
import static org .junit .Assert .assertEquals ;
7
10
import org .junit .Test ;
@@ -23,5 +26,20 @@ public void testTruncate() throws Exception {
23
26
truncate = (Truncate ) parserManager .parse (new StringReader (statement ));
24
27
assertEquals ("mytab" , truncate .getTable ().getName ());
25
28
assertEquals (toStringStatement .toUpperCase (), truncate .toString ().toUpperCase ());
29
+
30
+ statement = "TRUNCATE TABLE mytab CASCADE" ;
31
+ truncate = (Truncate ) parserManager .parse (new StringReader (statement ));
32
+ assertEquals (statement , truncate .toString ());
33
+ }
34
+
35
+ @ Test
36
+ public void testTruncateDeparse () throws JSQLParserException {
37
+ assertSqlCanBeParsedAndDeparsed ("TRUNCATE TABLE foo" );
26
38
}
39
+
40
+ @ Test
41
+ public void testTruncateCascadeDeparse () throws JSQLParserException {
42
+ assertSqlCanBeParsedAndDeparsed ("TRUNCATE TABLE foo CASCADE" );
43
+ }
44
+
27
45
}
You can’t perform that action at this time.
0 commit comments