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 {
3838 private boolean orReplace = false ;
3939 private List <String > columnNames = null ;
4040 private boolean materialized = false ;
41+ private ForceOption force = ForceOption .NONE ;
4142
4243 @ Override
4344 public void accept (StatementVisitor statementVisitor ) {
@@ -98,12 +99,28 @@ public void setMaterialized(boolean materialized) {
9899 this .materialized = materialized ;
99100 }
100101
102+ public ForceOption getForce () {
103+ return force ;
104+ }
105+
106+ public void setForce (ForceOption force ) {
107+ this .force = force ;
108+ }
109+
101110 @ Override
102111 public String toString () {
103112 StringBuilder sql = new StringBuilder ("CREATE " );
104113 if (isOrReplace ()) {
105114 sql .append ("OR REPLACE " );
106115 }
116+ switch (force ) {
117+ case FORCE :
118+ sql .append ("FORCE " );
119+ break ;
120+ case NO_FORCE :
121+ sql .append ("NO FORCE " );
122+ break ;
123+ }
107124 if (isMaterialized ()) {
108125 sql .append ("MATERIALIZED " );
109126 }
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 (t.warneke@gmx.net)
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) {
5656 if (createView .isOrReplace ()) {
5757 buffer .append ("OR REPLACE " );
5858 }
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+ }
5967 if (createView .isMaterialized ()) {
6068 buffer .append ("MATERIALIZED " );
6169 }
Original file line number Diff line number Diff line change @@ -3197,6 +3197,10 @@ CreateView CreateView():
31973197{
31983198 <K_CREATE>
31993199 [ <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+ ]
32003204 [ <K_MATERIALIZED> { createView.setMaterialized(true);} ]
32013205 <K_VIEW> view=Table() { createView.setView(view); }
32023206 [ columnNames = ColumnsNamesList() { createView.setColumnNames(columnNames); } ]
Original file line number Diff line number Diff line change @@ -68,4 +68,20 @@ public void testCreateMaterializedView() throws JSQLParserException {
6868 String stmt = "CREATE MATERIALIZED VIEW view1 AS SELECT a, b FROM testtab" ;
6969 assertSqlCanBeParsedAndDeparsed (stmt );
7070 }
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+ }
7187}
You can’t perform that action at this time.
0 commit comments