Skip to content

Commit dc3ef91

Browse files
Merge github.com:JSQLParser/JSqlParser into Keywords
2 parents 1a9db26 + 7ddb7c8 commit dc3ef91

21 files changed

Lines changed: 391 additions & 44 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ To help JSqlParser's development you are encouraged to provide
5454

5555
Also I would like to know about needed examples or documentation stuff.
5656

57-
## Extensions in the latest SNAPSHOT version 4.3
57+
## Extensions in the latest SNAPSHOT version 4.4
5858

59-
* moved to JUnit 5 as a test framework
60-
* added **IGNORE NULLS** to window functions
59+
* support for **timestamp with local time zone**
60+
* improved support for quoted identifiers in casts
6161

6262
Additionally, we have fixed many errors and improved the code quality and the test coverage.
6363

pom.xml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>com.github.jsqlparser</groupId>
44
<artifactId>jsqlparser</artifactId>
5-
<version>4.3-SNAPSHOT</version>
5+
<version>4.4-SNAPSHOT</version>
66
<name>JSQLParser library</name>
77
<inceptionYear>2004</inceptionYear>
88
<organization>
@@ -381,7 +381,7 @@
381381
<plugin>
382382
<groupId>org.apache.maven.plugins</groupId>
383383
<artifactId>maven-surefire-report-plugin</artifactId>
384-
<version>2.22.2</version>
384+
<version>3.0.0-M5</version>
385385
<configuration>
386386
<outputDirectory>${project.reporting.outputDirectory}/testresults</outputDirectory>
387387
</configuration>
@@ -447,9 +447,9 @@
447447

448448
<!-- JJDoc report generating the BNF documentation -->
449449
<plugin>
450-
<groupId>org.codehaus.mojo</groupId>
450+
<groupId>org.javacc.plugin</groupId>
451451
<artifactId>javacc-maven-plugin</artifactId>
452-
<version>2.6</version>
452+
<version>3.0.3</version>
453453
<configuration>
454454
<!--
455455
/**
@@ -536,17 +536,6 @@
536536
</build>
537537
</profile>
538538

539-
<!--
540-
<profile>
541-
<id>doclint-java8-disable</id>
542-
<activation>
543-
<jdk>[1.8,)</jdk>
544-
</activation>
545-
<properties>
546-
<javadoc.opts>-Xdoclint:none</javadoc.opts>
547-
</properties>
548-
</profile>
549-
-->
550539
<profile>
551540
<id>check.sources</id>
552541
<activation>

src/main/java/net/sf/jsqlparser/expression/ExpressionVisitor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,6 @@ public interface ExpressionVisitor {
186186
void visit(AllTableColumns allTableColumns);
187187

188188
void visit(AllValue allValue);
189+
190+
void visit(IsDistinctExpression isDistinctExpression);
189191
}

src/main/java/net/sf/jsqlparser/expression/ExpressionVisitorAdapter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,11 @@ public void visit(AllTableColumns allTableColumns) {
504504
public void visit(AllValue allValue) {
505505
}
506506

507+
@Override
508+
public void visit(IsDistinctExpression isDistinctExpression) {
509+
visitBinaryExpression(isDistinctExpression);
510+
}
511+
507512
@Override
508513
public void visit(SelectExpressionItem selectExpressionItem) {
509514
selectExpressionItem.getExpression().accept(this);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*-
2+
* #%L
3+
* JSQLParser library
4+
* %%
5+
* Copyright (C) 2004 - 2019 JSQLParser
6+
* %%
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
* #L%
9+
*/
10+
package net.sf.jsqlparser.expression.operators.relational;
11+
12+
import net.sf.jsqlparser.expression.BinaryExpression;
13+
import net.sf.jsqlparser.expression.ExpressionVisitor;
14+
15+
public class IsDistinctExpression extends BinaryExpression {
16+
17+
private boolean not = false;
18+
19+
public boolean isNot() {
20+
return not;
21+
}
22+
23+
public void setNot(boolean b) {
24+
not = b;
25+
}
26+
27+
@Override
28+
public void accept(ExpressionVisitor expressionVisitor) {
29+
expressionVisitor.visit(this);
30+
}
31+
32+
@Override
33+
public String getStringExpression() {
34+
return " IS " + (isNot() ? "NOT " : "") + "DISTINCT FROM ";
35+
}
36+
37+
@Override
38+
public String toString() {
39+
String retval = getLeftExpression() + getStringExpression() + getRightExpression();
40+
return retval;
41+
}
42+
}

src/main/java/net/sf/jsqlparser/parser/feature/Feature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ public enum Feature {
699699
// MYSQL
700700

701701
mySqlHintStraightJoin,
702-
mysqlSqlNoCache,
702+
mysqlSqlCacheFlag,
703703
mysqlCalcFoundRows,
704704

705705
// SQLSERVER
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*-
2+
* #%L
3+
* JSQLParser library
4+
* %%
5+
* Copyright (C) 2004 - 2022 JSQLParser
6+
* %%
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
* #L%
9+
*/
10+
package net.sf.jsqlparser.statement.select;
11+
12+
/**
13+
*
14+
* @author tw
15+
*/
16+
public enum MySqlSqlCacheFlags {
17+
SQL_CACHE, SQL_NO_CACHE
18+
}

src/main/java/net/sf/jsqlparser/statement/select/PlainSelect.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ public class PlainSelect extends ASTNodeAccessImpl implements SelectBody {
4949
private boolean useBrackets = false;
5050
private Wait wait;
5151
private boolean mySqlSqlCalcFoundRows = false;
52-
private boolean sqlNoCacheFlag = false;
52+
private MySqlSqlCacheFlags mySqlCacheFlag = null;
5353
private String forXmlPath;
5454
private KSQLWindow ksqlWindow = null;
5555
private boolean noWait = false;
5656
private boolean emitChanges = false;
57+
private WithIsolation withIsolation;
5758

5859
public boolean isUseBrackets() {
5960
return useBrackets;
@@ -330,6 +331,15 @@ public boolean isEmitChanges() {
330331
return emitChanges;
331332
}
332333

334+
335+
public WithIsolation getWithIsolation() {
336+
return withIsolation;
337+
}
338+
339+
public void setWithIsolation(WithIsolation withIsolation) {
340+
this.withIsolation = withIsolation;
341+
}
342+
333343
@Override
334344
@SuppressWarnings({"PMD.CyclomaticComplexity" , "PMD.ExcessiveMethodLength", "PMD.NPathComplexity"})
335345
public String toString() {
@@ -361,8 +371,8 @@ public String toString() {
361371
if (top != null) {
362372
sql.append(top).append(" ");
363373
}
364-
if (sqlNoCacheFlag) {
365-
sql.append("SQL_NO_CACHE").append(" ");
374+
if (mySqlCacheFlag != null) {
375+
sql.append(mySqlCacheFlag.name()).append(" ");
366376
}
367377
if (mySqlSqlCalcFoundRows) {
368378
sql.append("SQL_CALC_FOUND_ROWS").append(" ");
@@ -421,6 +431,10 @@ public String toString() {
421431
if (fetch != null) {
422432
sql.append(fetch);
423433
}
434+
435+
if (withIsolation != null) {
436+
sql.append(withIsolation);
437+
}
424438
if (isForUpdate()) {
425439
sql.append(" FOR UPDATE");
426440

@@ -455,6 +469,9 @@ public String toString() {
455469
if (fetch != null) {
456470
sql.append(fetch);
457471
}
472+
if (withIsolation != null) {
473+
sql.append(withIsolation);
474+
}
458475
}
459476
if (forXmlPath != null) {
460477
sql.append(" FOR XML PATH(").append(forXmlPath).append(")");
@@ -544,25 +561,25 @@ public PlainSelect withMySqlSqlCalcFoundRows(boolean mySqlCalcFoundRows) {
544561
return this;
545562
}
546563

547-
public PlainSelect withMySqlSqlNoCache(boolean sqlNoCacheFlagSet) {
548-
this.setMySqlSqlNoCache(sqlNoCacheFlagSet);
564+
public PlainSelect withMySqlSqlNoCache(MySqlSqlCacheFlags mySqlCacheFlag) {
565+
this.setMySqlSqlCacheFlag(mySqlCacheFlag);
549566
return this;
550567
}
551568

552569
public void setMySqlSqlCalcFoundRows(boolean mySqlCalcFoundRows) {
553570
this.mySqlSqlCalcFoundRows = mySqlCalcFoundRows;
554571
}
555572

556-
public void setMySqlSqlNoCache(boolean sqlNoCacheFlagSet) {
557-
this.sqlNoCacheFlag = sqlNoCacheFlagSet;
573+
public void setMySqlSqlCacheFlag(MySqlSqlCacheFlags sqlCacheFlag) {
574+
this.mySqlCacheFlag = sqlCacheFlag;
558575
}
559576

560577
public boolean getMySqlSqlCalcFoundRows() {
561578
return this.mySqlSqlCalcFoundRows;
562579
}
563580

564-
public boolean getMySqlSqlNoCache() {
565-
return this.sqlNoCacheFlag;
581+
public MySqlSqlCacheFlags getMySqlSqlCacheFlag() {
582+
return this.mySqlCacheFlag;
566583
}
567584

568585
public void setNoWait(boolean noWait) {

src/main/java/net/sf/jsqlparser/statement/select/SetOperationList.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class SetOperationList implements SelectBody {
2424
private Limit limit;
2525
private Offset offset;
2626
private Fetch fetch;
27+
private WithIsolation withIsolation;
2728

2829
@Override
2930
public void accept(SelectVisitor selectVisitor) {
@@ -96,7 +97,16 @@ public void setFetch(Fetch fetch) {
9697
this.fetch = fetch;
9798
}
9899

100+
public WithIsolation getWithIsolation() {
101+
return this.withIsolation;
102+
}
103+
104+
public void setWithIsolation(WithIsolation withIsolation) {
105+
this.withIsolation = withIsolation;
106+
}
107+
99108
@Override
109+
@SuppressWarnings({"PMD.CyclomaticComplexity"})
100110
public String toString() {
101111
StringBuilder buffer = new StringBuilder();
102112

@@ -123,6 +133,9 @@ public String toString() {
123133
if (fetch != null) {
124134
buffer.append(fetch.toString());
125135
}
136+
if (withIsolation != null) {
137+
buffer.append(withIsolation.toString());
138+
}
126139
return buffer.toString();
127140
}
128141

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*-
2+
* #%L
3+
* JSQLParser library
4+
* %%
5+
* Copyright (C) 2004 - 2019 JSQLParser
6+
* %%
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
* #L%
9+
*/
10+
package net.sf.jsqlparser.statement.select;
11+
12+
13+
public class WithIsolation {
14+
15+
private String isolation = "UR";
16+
17+
public String getIsolation() {
18+
return this.isolation;
19+
}
20+
public void setIsolation(String s) {
21+
this.isolation = s;
22+
}
23+
24+
@Override
25+
public String toString() {
26+
return " WITH " + this.isolation;
27+
}
28+
}

0 commit comments

Comments
 (0)