Skip to content

Commit dbef3a5

Browse files
authored
Merge pull request #2 from JSQLParser/master
periodic sync from JSqlParser repository
2 parents de29e1e + c5a0b02 commit dbef3a5

File tree

321 files changed

+990
-143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

321 files changed

+990
-143
lines changed

README.md

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[![Build Status](https://travis-ci.org/JSQLParser/JSqlParser.svg?branch=master)](https://travis-ci.org/JSQLParser/JSqlParser) [![Coverage Status](https://coveralls.io/repos/JSQLParser/JSqlParser/badge.svg?branch=master)](https://coveralls.io/r/JSQLParser/JSqlParser?branch=master)
44
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/00b2d91995764ae4805b55627aca8d39)](https://www.codacy.com/app/wumpz/JSqlParser?utm_source=github.com&utm_medium=referral&utm_content=JSQLParser/JSqlParser&utm_campaign=Badge_Grade)
5+
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.jsqlparser/jsqlparser/badge.svg)](http://maven-badges.herokuapp.com/maven-central/com.github.jsqlparser/jsqlparser)
6+
[![Javadocs](https://www.javadoc.io/badge/com.github.jsqlparser/jsqlparser.svg)](https://www.javadoc.io/doc/com.github.jsqlparser/jsqlparser)
57

68
[![PayPal donate button](http://img.shields.io/paypal/donate.png?color=blue)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=64CCN9JJANZXA "Help this JSqlParser version using Paypal")
79

@@ -15,6 +17,7 @@ JSqlParser is dual licensed under **LGPL V2.1** and **Apache Software License, V
1517

1618

1719
## News
20+
* Released version **1.2** of JSqlParser
1821
* breaking **API** change: merge of *within group* and *over* (window expressions)
1922
* Released version **1.1** of JSqlParser.
2023
* JSqlParser has now a build in checkstyle configuration to introduce source code conventions.
@@ -42,27 +45,12 @@ To help JSqlParsers development you are encouraged to provide
4245

4346
Also I would like to know about needed examples or documentation stuff.
4447

45-
## Extensions in the latest SNAPSHOT version 1.2
46-
47-
* support for single quoted aliases ___select col1 as 'alias'___
48-
* support for Unicode string literal like **N'test'** or **U'test'**
49-
* support for bitwise not **~**
50-
* support for **drop view**
51-
* support for indexed JDBC parameters at multiple places
52-
* allowed **index** as object name
53-
* switched to JavaCC **modern template**
54-
* switched to JDK 1.7
55-
* introduced more AST node links
56-
* support for aliased table in **insert into** statement
57-
* **SQL_CALC_FOUND_ROWS** support
58-
* support for more complex expressions within **case expr when expr then expr end**.
59-
* support for **<<** and **>>** left and right shift operations
60-
* breaking **API** change: merge of *within group* and *over* (window expressions)
61-
* first support for *use* statements
62-
* first support for *call* statements
63-
* create table allows now quoted identifiers within primary key definition
64-
* introduced alias for subquery in combination with a pivot definition (this **changes** alias handling within the library for pivot sqls)
65-
* force the parser to fully parse a String using parseCondExpression or parseExpression
48+
## Extensions in the latest SNAPSHOT version 1.3
49+
50+
* corrected ISNULL regression (issue #610)
51+
* refactored statement test classes to the class corresponding packages
52+
* allowed nested postgresql casts (e.g. col::bigint::int)
53+
6654

6755
## Extensions of JSqlParser releases
6856

@@ -130,7 +118,7 @@ And this is the dependency declaration in your pom:
130118
<dependency>
131119
<groupId>com.github.jsqlparser</groupId>
132120
<artifactId>jsqlparser</artifactId>
133-
<version>1.1</version>
121+
<version>1.2</version>
134122
</dependency>
135123
```
136124

nb-configuration.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
That way multiple projects can share the same settings (useful for formatting rules for example).
1414
Any value defined here will override the pom.xml file value but is only applicable to the current project.
1515
-->
16-
<netbeans.compile.on.save>none</netbeans.compile.on.save>
16+
<netbeans.compile.on.save>all</netbeans.compile.on.save>
1717
<com-junichi11-netbeans-changelf.enable>false</com-junichi11-netbeans-changelf.enable>
1818
<com-junichi11-netbeans-changelf.use-project>true</com-junichi11-netbeans-changelf.use-project>
1919
<com-junichi11-netbeans-changelf.lf-kind>LF</com-junichi11-netbeans-changelf.lf-kind>
2020
<com-junichi11-netbeans-changelf.use-global>false</com-junichi11-netbeans-changelf.use-global>
21+
<org-netbeans-modules-javascript2-requirejs.enabled>true</org-netbeans-modules-javascript2-requirejs.enabled>
22+
<netbeans.hint.jdkPlatform>JDK_1.8</netbeans.hint.jdkPlatform>
2123
</properties>
2224
</project-shared-configuration>

pom.xml

Lines changed: 3 additions & 8 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>1.2-SNAPSHOT</version>
5+
<version>1.3-SNAPSHOT</version>
66
<name>JSQLParser library</name>
77
<inceptionYear>2004</inceptionYear>
88
<organization>
@@ -46,7 +46,7 @@
4646
<dependency>
4747
<groupId>org.mockito</groupId>
4848
<artifactId>mockito-core</artifactId>
49-
<version>2.7.22</version>
49+
<version>2.16.0</version>
5050
<scope>test</scope>
5151
</dependency>
5252
</dependencies>
@@ -106,11 +106,6 @@
106106
</goals>
107107
</execution>
108108
</executions>
109-
<configuration>
110-
<nodeDefaultVoid>true</nodeDefaultVoid>
111-
<visitor>true</visitor>
112-
<trackTokens>true</trackTokens>
113-
</configuration>
114109
<dependencies>
115110
<dependency>
116111
<groupId>net.java.dev.javacc</groupId>
@@ -182,7 +177,7 @@
182177
<plugin>
183178
<groupId>org.apache.maven.plugins</groupId>
184179
<artifactId>maven-source-plugin</artifactId>
185-
<version>2.4</version>
180+
<version>3.0.1</version>
186181
<executions>
187182
<execution>
188183
<id>attach-sources</id>

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class AnalyticExpression extends ASTNodeAccessImpl implements Expression
4848
private WindowElement windowElement;
4949
private KeepExpression keep = null;
5050
private AnalyticType type = AnalyticType.OVER;
51+
private boolean distinct = false;
5152

5253
@Override
5354
public void accept(ExpressionVisitor expressionVisitor) {
@@ -126,11 +127,22 @@ public void setType(AnalyticType type) {
126127
this.type = type;
127128
}
128129

130+
public boolean isDistinct() {
131+
return distinct;
132+
}
133+
134+
public void setDistinct(boolean distinct) {
135+
this.distinct = distinct;
136+
}
137+
129138
@Override
130139
public String toString() {
131140
StringBuilder b = new StringBuilder();
132141

133142
b.append(name).append("(");
143+
if (isDistinct()) {
144+
b.append("DISTINCT ");
145+
}
134146
if (expression != null) {
135147
b.append(expression.toString());
136148
if (offset != null) {
@@ -146,7 +158,7 @@ public String toString() {
146158
if (keep != null) {
147159
b.append(keep.toString()).append(" ");
148160
}
149-
161+
150162
switch (type) {
151163
case WITHIN_GROUP:
152164
b.append("WITHIN GROUP");

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ public interface ExpressionVisitor {
167167
void visit(KeepExpression aexpr);
168168

169169
void visit(MySQLGroupConcat groupConcat);
170+
171+
void visit(ValueListExpression valueList);
170172

171173
void visit(RowConstructor rowConstructor);
172174

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,13 @@ public void visit(MySQLGroupConcat groupConcat) {
416416
}
417417
}
418418
}
419+
420+
@Override
421+
public void visit(ValueListExpression valueListExpression) {
422+
for (Expression expr : valueListExpression.getExpressionList().getExpressions()) {
423+
expr.accept(this);
424+
}
425+
}
419426

420427
@Override
421428
public void visit(Pivot pivot) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
public class Parenthesis extends ASTNodeAccessImpl implements Expression {
3030

3131
private Expression expression;
32+
3233
private boolean not = false;
3334

3435
public Parenthesis() {
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
/**
23+
*
24+
*/
25+
package net.sf.jsqlparser.expression;
26+
27+
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
28+
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
29+
30+
/**
31+
* Models a list of expressions usable as condition.<br>
32+
* This allows for instance the following expression :
33+
* <code>"[WHERE] (a, b) [OPERATOR] (c, d)"</code>
34+
* where "(a, b)" and "(c, d)" are instances of this class.
35+
*
36+
* @author adriil
37+
*/
38+
public class ValueListExpression extends ASTNodeAccessImpl implements Expression {
39+
40+
private ExpressionList expressionList;
41+
42+
public ExpressionList getExpressionList() {
43+
return expressionList;
44+
}
45+
46+
public void setExpressionList(ExpressionList expressionList) {
47+
this.expressionList = expressionList;
48+
}
49+
50+
@Override
51+
public void accept(ExpressionVisitor expressionVisitor) {
52+
expressionVisitor.visit(this);
53+
}
54+
55+
@Override
56+
public String toString() {
57+
return expressionList.toString();
58+
}
59+
60+
}

src/main/java/net/sf/jsqlparser/expression/operators/relational/ExpressionList.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222
package net.sf.jsqlparser.expression.operators.relational;
2323

24+
import java.util.Arrays;
2425
import java.util.List;
2526

2627
import net.sf.jsqlparser.expression.Expression;
@@ -39,6 +40,10 @@ public ExpressionList() {
3940
public ExpressionList(List<Expression> expressions) {
4041
this.expressions = expressions;
4142
}
43+
44+
public ExpressionList(Expression ... expressions) {
45+
this.expressions = Arrays.asList(expressions);
46+
}
4247

4348
public List<Expression> getExpressions() {
4449
return expressions;

src/main/java/net/sf/jsqlparser/expression/operators/relational/IsNullExpression.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class IsNullExpression extends ASTNodeAccessImpl implements Expression {
2929

3030
private Expression leftExpression;
3131
private boolean not = false;
32+
private boolean useIsNull = false;
3233

3334
public Expression getLeftExpression() {
3435
return leftExpression;
@@ -46,13 +47,25 @@ public void setNot(boolean b) {
4647
not = b;
4748
}
4849

50+
public boolean isUseIsNull() {
51+
return useIsNull;
52+
}
53+
54+
public void setUseIsNull(boolean useIsNull) {
55+
this.useIsNull = useIsNull;
56+
}
57+
4958
@Override
5059
public void accept(ExpressionVisitor expressionVisitor) {
5160
expressionVisitor.visit(this);
5261
}
5362

5463
@Override
5564
public String toString() {
56-
return leftExpression + " IS " + (not ? "NOT " : "") + "NULL";
65+
if (isUseIsNull()) {
66+
return leftExpression + (not ? " NOT" : "") + " ISNULL";
67+
} else {
68+
return leftExpression + " IS " + (not ? "NOT " : "") + "NULL";
69+
}
5770
}
5871
}

0 commit comments

Comments
 (0)