File tree Expand file tree Collapse file tree 5 files changed +79
-0
lines changed
jjtree/net/sf/jsqlparser/parser
test/java/net/sf/jsqlparser/test/create Expand file tree Collapse file tree 5 files changed +79
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ public class CreateView implements Statement {
38
38
private boolean orReplace = false ;
39
39
private List <String > columnNames = null ;
40
40
private boolean materialized = false ;
41
+ private ForceOption force = ForceOption .NONE ;
41
42
42
43
@ Override
43
44
public void accept (StatementVisitor statementVisitor ) {
@@ -98,12 +99,28 @@ public void setMaterialized(boolean materialized) {
98
99
this .materialized = materialized ;
99
100
}
100
101
102
+ public ForceOption getForce () {
103
+ return force ;
104
+ }
105
+
106
+ public void setForce (ForceOption force ) {
107
+ this .force = force ;
108
+ }
109
+
101
110
@ Override
102
111
public String toString () {
103
112
StringBuilder sql = new StringBuilder ("CREATE " );
104
113
if (isOrReplace ()) {
105
114
sql .append ("OR REPLACE " );
106
115
}
116
+ switch (force ) {
117
+ case FORCE :
118
+ sql .append ("FORCE " );
119
+ break ;
120
+ case NO_FORCE :
121
+ sql .append ("NO FORCE " );
122
+ break ;
123
+ }
107
124
if (isMaterialized ()) {
108
125
sql .append ("MATERIALIZED " );
109
126
}
Original file line number Diff line number Diff line change
1
+ /*
2
+ * #%L
3
+ * JSQLParser library
4
+ * %%
5
+ * Copyright (C) 2004 - 2018 JSQLParser
6
+ * %%
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as
9
+ * published by the Free Software Foundation, either version 2.1 of the
10
+ * License, or (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Lesser Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Lesser Public
18
+ * License along with this program. If not, see
19
+ * <http://www.gnu.org/licenses/lgpl-2.1.html>.
20
+ * #L%
21
+ */
22
+ package net .sf .jsqlparser .statement .create .view ;
23
+
24
+ /**
25
+ *
26
+ * @author Tobias Warneke ([email protected] )
27
+ */
28
+ public enum ForceOption {
29
+ NONE ,
30
+
31
+ FORCE ,
32
+
33
+ NO_FORCE
34
+ }
Original file line number Diff line number Diff line change @@ -56,6 +56,14 @@ public void deParse(CreateView createView) {
56
56
if (createView .isOrReplace ()) {
57
57
buffer .append ("OR REPLACE " );
58
58
}
59
+ switch (createView .getForce ()) {
60
+ case FORCE :
61
+ buffer .append ("FORCE " );
62
+ break ;
63
+ case NO_FORCE :
64
+ buffer .append ("NO FORCE " );
65
+ break ;
66
+ }
59
67
if (createView .isMaterialized ()) {
60
68
buffer .append ("MATERIALIZED " );
61
69
}
Original file line number Diff line number Diff line change @@ -3197,6 +3197,10 @@ CreateView CreateView():
3197
3197
{
3198
3198
<K_CREATE>
3199
3199
[ <K_OR> <K_REPLACE> { createView.setOrReplace(true);} ]
3200
+ [
3201
+ <K_NO> <K_FORCE> { createView.setForce(ForceOption.NO_FORCE); }
3202
+ | <K_FORCE> { createView.setForce(ForceOption.FORCE); }
3203
+ ]
3200
3204
[ <K_MATERIALIZED> { createView.setMaterialized(true);} ]
3201
3205
<K_VIEW> view=Table() { createView.setView(view); }
3202
3206
[ columnNames = ColumnsNamesList() { createView.setColumnNames(columnNames); } ]
Original file line number Diff line number Diff line change @@ -68,4 +68,20 @@ public void testCreateMaterializedView() throws JSQLParserException {
68
68
String stmt = "CREATE MATERIALIZED VIEW view1 AS SELECT a, b FROM testtab" ;
69
69
assertSqlCanBeParsedAndDeparsed (stmt );
70
70
}
71
+
72
+ public void testCreateForceView () throws JSQLParserException {
73
+ assertSqlCanBeParsedAndDeparsed ("CREATE FORCE VIEW view1 AS SELECT a, b FROM testtab" );
74
+ }
75
+
76
+ public void testCreateForceView1 () throws JSQLParserException {
77
+ assertSqlCanBeParsedAndDeparsed ("CREATE NO FORCE VIEW view1 AS SELECT a, b FROM testtab" );
78
+ }
79
+
80
+ public void testCreateForceView2 () throws JSQLParserException {
81
+ assertSqlCanBeParsedAndDeparsed ("CREATE OR REPLACE FORCE VIEW view1 AS SELECT a, b FROM testtab" );
82
+ }
83
+
84
+ public void testCreateForceView3 () throws JSQLParserException {
85
+ assertSqlCanBeParsedAndDeparsed ("CREATE OR REPLACE NO FORCE VIEW view1 AS SELECT a, b FROM testtab" );
86
+ }
71
87
}
You can’t perform that action at this time.
0 commit comments