Skip to content

Commit 4797a8d

Browse files
Prepare4.2 (#1329)
* Implement caching of the Gradle and Maven files Provided by @YunLemon via PR #1307 * Fix CREATE TABLE AS SELECT ... UNION SELECT ... Provided by @fanchuo via PR #1309 * Fix #1316 Add more specific tests verifying the nature of the UpdateSets Allow "SELECT *" (without FROM) to parse, its a valid SELECT statement * Add the enhancements since Release 4.1 * Adjust the Coverage * Improve Test Coverage * Revert the Special Oracle Tests (accidentally set to FAILURE) Co-authored-by: Tobias <t.warneke@gmx.net>
1 parent a7b5c2b commit 4797a8d

20 files changed

+297
-144
lines changed

.travis.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@ jdk:
44
- openjdk11
55

66
after_success:
7-
- mvn clean cobertura:cobertura coveralls:report
7+
- mvn clean cobertura:cobertura coveralls:report
8+
9+
cache:
10+
directories:
11+
- $HOME/.m2
12+
- $HOME/.gradle/caches/
13+
- $HOME/.gradle/wrapper/

README.md

+29-7
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,25 @@ To help JSqlParser's development you are encouraged to provide
5454
Also I would like to know about needed examples or documentation stuff.
5555

5656
## Extensions in the latest SNAPSHOT version 4.2
57-
57+
* API change: Support `SELECT ...` without a `FROM` clause, making `SELECT 1, 2` and `SELECT *` parsable statements (before those failed)
58+
* API change: Support complex `UPDATE` sets (using multiple `SubQuery` or `ValueList` or Single Values, in combination)
59+
* Support nested `CASE` expressions with complex expression arguments
60+
* API change: Support `JOIN` with multiple trailing `ON` Expressions (`JOIN ... JOIN ... ON ... ON ...`)
61+
* Support Oracle Hierarchical `CONNECT_BY_ROOT` Operator
62+
* Support Transact-SQL `IF ... ELSE ...` Statement Control Flows.
63+
* Allow optional parameters for the `ALTER TABLE ...` statement (e.g. `ALTER TABLE ... MOVE TABLESPACE ...`)
64+
* Support Oracle `ALTER SYSTEM ...` statement
65+
* Support Oracle Named Function Parameters`Func( param1 => arg1, ...`
66+
* Add Gradle build
67+
* Allow `JdbcParameter` or `JdbcNamedParameter` for MySQL FullTextSearch
68+
* Allow `Cast` into `Row` Constructor
69+
* Support Oracle `RENAME ... TO ...` statement
70+
* Support Oracle `PURGE` statement
71+
* Support JSON functions `JSON_OBJECT()`, `JSON_ARRAY()`, `JSON_OBJECTAGG()`, `JSON_ARRAYAGG()`
5872
* API change: merge ALL and ANY expressions class
59-
* allow `CURRENT DATE`in addition to `CURRENT_DATE` (without underbar)
73+
* Allow DB2 compliant `CURRENT DATE`in addition to `CURRENT_DATE` (without underscore)
74+
75+
Additionally, we have fixed many errors and improved the code quality and the test coverage.
6076

6177
## Extensions of JSqlParser releases
6278

@@ -67,16 +83,22 @@ Also I would like to know about needed examples or documentation stuff.
6783
## Building from the sources
6884

6985
As the project is a Maven project, building is rather simple by running:
86+
```shell
87+
mvn package
88+
```
7089

71-
mvn package
90+
Since 4.2, alternatively Gradle can be used
91+
```shell
92+
gradle build
93+
```
7294

7395
The project requires the following to build:
74-
- Maven
96+
- Maven (or Gradle)
7597
- JDK 8 or later. The jar will target JDK 8, but the version of the maven-compiler-plugin that JsqlParser uses requires JDK 8+
7698

77-
This will produce the jsqlparser-VERSION.jar file in the target/ directory.
99+
This will produce the jsqlparser-VERSION.jar file in the `target/` directory (`build/libs/jsqlparser-VERSION.jar` in case of Gradle).
78100

79-
**To build this project without using Maven, one has to build the parser by JavaCC using the CLI options it provides.**
101+
**To build this project without using Maven or Gradle, one has to build the parser by JavaCC using the CLI options it provides.**
80102

81103
## Debugging through problems
82104

@@ -124,7 +146,7 @@ And this is the dependency declaration in your pom:
124146
<dependency>
125147
<groupId>com.github.jsqlparser</groupId>
126148
<artifactId>jsqlparser</artifactId>
127-
<version>4.0</version>
149+
<version>4.1</version>
128150
</dependency>
129151
```
130152

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jacocoTestCoverageVerification {
7373
violationRules {
7474
rule {
7575
limit {
76-
minimum = 0.837
76+
minimum = 0.838
7777
}
7878
}
7979
}

src/main/java/net/sf/jsqlparser/statement/update/Update.java

+11-29
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,12 @@ public void setSelect(Select select) {
183183

184184
@Deprecated
185185
public boolean isUseColumnsBrackets() {
186-
return updateSets.get(0).usingBrackets;
186+
return updateSets.get(0).usingBracketsForColumns;
187187
}
188188

189189
@Deprecated
190190
public void setUseColumnsBrackets(boolean useColumnsBrackets) {
191-
updateSets.get(0).usingBrackets = useColumnsBrackets;
191+
updateSets.get(0).usingBracketsForColumns = useColumnsBrackets;
192192
}
193193

194194
@Deprecated
@@ -268,7 +268,7 @@ public String toString() {
268268
b.append(", ");
269269
}
270270

271-
if (updateSet.usingBrackets) {
271+
if (updateSet.usingBracketsForColumns) {
272272
b.append("(");
273273
}
274274

@@ -279,46 +279,28 @@ public String toString() {
279279
b.append(updateSet.columns.get(i));
280280
}
281281

282-
if (updateSet.usingBrackets) {
282+
if (updateSet.usingBracketsForColumns) {
283283
b.append(")");
284284
}
285285

286286
b.append(" = ");
287287

288+
if (updateSet.usingBracketsForValues) {
289+
b.append("(");
290+
}
291+
288292
for (int i = 0; i < updateSet.expressions.size(); i++) {
289293
if (i > 0) {
290294
b.append(", ");
291295
}
292296
b.append(updateSet.expressions.get(i));
293297
}
298+
if (updateSet.usingBracketsForValues) {
299+
b.append(")");
300+
}
294301

295302
j++;
296303
}
297-
298-
// if (!useSelect) {
299-
// for (int i = 0; i < getColumns().size(); i++) {
300-
// if (i != 0) {
301-
// b.append(", ");
302-
// }
303-
// b.append(columns.get(i)).append(" = ");
304-
// b.append(expressions.get(i));
305-
// }
306-
// } else {
307-
// if (useColumnsBrackets) {
308-
// b.append("(");
309-
// }
310-
// for (int i = 0; i < getColumns().size(); i++) {
311-
// if (i != 0) {
312-
// b.append(", ");
313-
// }
314-
// b.append(columns.get(i));
315-
// }
316-
// if (useColumnsBrackets) {
317-
// b.append(")");
318-
// }
319-
// b.append(" = ");
320-
// b.append("(").append(select).append(")");
321-
// }
322304
if (fromItem != null) {
323305
b.append(" FROM ").append(fromItem);
324306
if (joins != null) {

src/main/java/net/sf/jsqlparser/statement/update/UpdateSet.java

+22-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
import java.util.Objects;
1818

1919
public class UpdateSet {
20-
protected boolean usingBrackets = false;
20+
protected boolean usingBracketsForColumns = false;
21+
protected boolean usingBracketsForValues = false;
2122
protected ArrayList<Column> columns = new ArrayList<>();
2223
protected ArrayList<Expression> expressions = new ArrayList<>();
2324

@@ -34,12 +35,20 @@ public UpdateSet(Column column, Expression expression) {
3435
this.expressions.add(expression);
3536
}
3637

37-
public boolean isUsingBrackets() {
38-
return usingBrackets;
38+
public boolean isUsingBracketsForValues() {
39+
return usingBracketsForValues;
3940
}
4041

41-
public void setUsingBrackets(boolean usingBrackets) {
42-
this.usingBrackets = usingBrackets;
42+
public void setUsingBracketsForValues(boolean usingBracketsForValues) {
43+
this.usingBracketsForValues = usingBracketsForValues;
44+
}
45+
46+
public boolean isUsingBracketsForColumns() {
47+
return usingBracketsForColumns;
48+
}
49+
50+
public void setUsingBracketsForColumns(boolean usingBracketsForColumns) {
51+
this.usingBracketsForColumns = usingBracketsForColumns;
4352
}
4453

4554
public ArrayList<Column> getColumns() {
@@ -61,13 +70,18 @@ public void setExpressions(ArrayList<Expression> expressions) {
6170
public void add(Column column, Expression expression) {
6271
columns.add(column);
6372
expressions.add(expression);
64-
};
73+
}
6574

6675
public void add(Column column) {
6776
columns.add(column);
68-
};
77+
}
78+
79+
public void add(Expression expression) {
80+
expressions.add(expression);
81+
}
6982

7083
public void add(ExpressionList expressionList) {
7184
expressions.addAll(expressionList.getExpressions());
72-
};
85+
}
86+
7387
}

src/main/java/net/sf/jsqlparser/util/deparser/UpdateDeParser.java

+8-37
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void deParse(Update update) {
6666
buffer.append(", ");
6767
}
6868

69-
if (updateSet.isUsingBrackets()) {
69+
if (updateSet.isUsingBracketsForColumns()) {
7070
buffer.append("(");
7171
}
7272
for (int i = 0; i < updateSet.getColumns().size(); i++) {
@@ -75,56 +75,27 @@ public void deParse(Update update) {
7575
}
7676
updateSet.getColumns().get(i).accept(expressionVisitor);
7777
}
78-
if (updateSet.isUsingBrackets()) {
78+
if (updateSet.isUsingBracketsForColumns()) {
7979
buffer.append(")");
8080
}
8181

8282
buffer.append(" = ");
8383

84+
if (updateSet.isUsingBracketsForValues()) {
85+
buffer.append("(");
86+
}
8487
for (int i = 0; i < updateSet.getExpressions().size(); i++) {
8588
if (i > 0) {
8689
buffer.append(", ");
8790
}
8891
updateSet.getExpressions().get(i).accept(expressionVisitor);
8992
}
93+
if (updateSet.isUsingBracketsForValues()) {
94+
buffer.append(")");
95+
}
9096

9197
j++;
9298
}
93-
94-
// if (!update.isUseSelect()) {
95-
// for (int i = 0; i < update.getColumns().size(); i++) {
96-
// Column column = update.getColumns().get(i);
97-
// column.accept(expressionVisitor);
98-
//
99-
// buffer.append(" = ");
100-
//
101-
// Expression expression = update.getExpressions().get(i);
102-
// expression.accept(expressionVisitor);
103-
// if (i < update.getColumns().size() - 1) {
104-
// buffer.append(", ");
105-
// }
106-
// }
107-
// } else {
108-
// if (update.isUseColumnsBrackets()) {
109-
// buffer.append("(");
110-
// }
111-
// for (int i = 0; i < update.getColumns().size(); i++) {
112-
// if (i != 0) {
113-
// buffer.append(", ");
114-
// }
115-
// Column column = update.getColumns().get(i);
116-
// column.accept(expressionVisitor);
117-
// }
118-
// if (update.isUseColumnsBrackets()) {
119-
// buffer.append(")");
120-
// }
121-
// buffer.append(" = ");
122-
// buffer.append("(");
123-
// Select select = update.getSelect();
124-
// select.getSelectBody().accept(selectVisitor);
125-
// buffer.append(")");
126-
// }
127-
12899
if (update.getFromItem() != null) {
129100
buffer.append(" FROM ").append(update.getFromItem());
130101
if (update.getJoins() != null) {

0 commit comments

Comments
 (0)