Skip to content

Commit

Permalink
Merge origin/master
Browse files Browse the repository at this point in the history
Conflicts:
	src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java
  • Loading branch information
wumpz committed Dec 4, 2018
2 parents c0801a7 + 572a6c6 commit 4da4f13
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Look here for more information and examples: https://github.com/JSQLParser/JSqlP

JSqlParser is dual licensed under **LGPL V2.1** and **Apache Software License, Version 2.0**.

## Discussion

Please provide feedback on https://github.com/JSQLParser/JSqlParser/issues/677, about removing bracket identifier quotation to support array processing.

## News
* Released version **1.3** of JSqlParser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class AlterView implements Statement {

private Table view;
private SelectBody selectBody;
private boolean useReplace = false;
private List<String> columnNames = null;

@Override
Expand Down Expand Up @@ -74,9 +75,23 @@ public void setColumnNames(List<String> columnNames) {
this.columnNames = columnNames;
}

public boolean isUseReplace() {
return useReplace;
}

public void setUseReplace(boolean useReplace) {
this.useReplace = useReplace;
}


@Override
public String toString() {
StringBuilder sql = new StringBuilder("ALTER ");
StringBuilder sql;
if(useReplace){
sql = new StringBuilder("REPLACE ");
}else{
sql = new StringBuilder("ALTER ");
}
sql.append("VIEW ");
sql.append(view);
if (columnNames != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ public AlterViewDeParser(StringBuilder buffer, SelectVisitor selectVisitor) {
}

public void deParse(AlterView alterView) {
buffer.append("ALTER ");
if(alterView.isUseReplace()){
buffer.append("REPLACE ");
}else{
buffer.append("ALTER ");
}
buffer.append("VIEW ").append(alterView.getView().getFullyQualifiedName());
if (alterView.getColumnNames() != null) {
buffer.append(PlainSelect.getStringList(alterView.getColumnNames(), true, true));
Expand Down
5 changes: 3 additions & 2 deletions src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ Statement SingleStatement() :
|
stm = Delete()
|
LOOKAHEAD(2)
stm = Replace()
|
LOOKAHEAD(2)
Expand Down Expand Up @@ -618,7 +619,7 @@ Replace Replace():
Expression exp = null;
}
{
<K_REPLACE> [<K_INTO> { replace.setUseIntoTables(true); }] table=Table()
( <K_REPLACE> [LOOKAHEAD(2) <K_INTO> { replace.setUseIntoTables(true); }] table=Table() )

(
(
Expand Down Expand Up @@ -3445,7 +3446,7 @@ AlterView AlterView():
List<String> columnNames = null;
}
{
<K_ALTER>
( (<K_ALTER> ) | (<K_REPLACE> {alterView.setUseReplace(true);}) )
<K_VIEW> view=Table() { alterView.setView(view); }
[ columnNames = ColumnsNamesList() { alterView.setColumnNames(columnNames); } ]
<K_AS>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ public void testAlterView() throws JSQLParserException {
String stmt = "ALTER VIEW myview AS SELECT * FROM mytab";
assertSqlCanBeParsedAndDeparsed(stmt);
}

@Test
public void testReplaceView() throws JSQLParserException {
String stmt = "REPLACE VIEW myview AS SELECT * FROM mytab";
assertSqlCanBeParsedAndDeparsed(stmt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3284,6 +3284,11 @@ public void testCharNotParsedIssue718() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("SELECT a FROM x WHERE a LIKE '%' + char(9) + '%'");
}

@Test
public void testTrueFalseLiteral() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("SELECT * FROM tbl WHERE true OR clm1 = 3");
}

@Test
public void testRawStringExpressionIssue656() throws JSQLParserException {
for (String c : new String[]{"u", "e", "n", "r", "b", "rb"}) {
Expand Down

0 comments on commit 4da4f13

Please sign in to comment.