Skip to content

Commit adeed53

Browse files
Assorted Fixes #6 (#1740)
* Fixes #1684: Support CREATE MATERIALIZED VIEW with AUTO REFRESH Support parsing create view statements in Redshift with AUTO REFRESH option. * Reduce cyclomatic complexity in CreateView.toString Extract adding the force option into a dedicated method resulting in the cyclomatic complexity reduction of the CreateView.toString method. * Enhanced Keywords Add Keywords and document, which keywords are allowed for what purpose * Fix incorrect tests * Define Reserved Keywords explicitly Derive All Keywords from Grammar directly Generate production for Object Names (semi-) automatically Add parametrized Keyword Tests * Fix test resources * Adjust Gradle to JUnit 5 Parallel Test execution Gradle Caching Explicitly request for latest JavaCC 7.0.10 * Do not mark SpeedTest for concurrent execution * Remove unused imports * Adjust Gradle to JUnit 5 Parallel Test execution Gradle Caching Explicitly request for latest JavaCC 7.0.10 * Do not mark SpeedTest for concurrent execution * Remove unused imports * Sphinx Documentation Update the MANTICORE Sphinx Theme, but ignore it in GIT Add the content to the Sphinx sites Add a Gradle function to derive Stable and Snapshot version from GIT Tags Add a Gradle GIT change task Add a Gradle sphinx task Add a special Test case for illustrating the use of JSQLParser * doc: request for `Conventional Commit` messages * feat: make important Classes Serializable Implement Serializable for persisting via ObjectOutputStream * chore: Make Serializable * doc: Better integration of the RR diagrams - apply neutral Sphinx theme - insert the RR diagrams into the sphinx sources - better documentation on Gradle dependencies - link GitHub repository * Merge * feat: Oracle Alternative Quoting - add support for Oracle Alternative Quoting e.g. `q'(...)'` - fixes #1718 - add a Logo and FavIcon to the Website - document recent changes on Quoting/Escaping - add an example on building SQL from Java - rework the README.md, promote the Website - add Spotless Formatter, using Google Java Style (with Tab=4 Spaces) * style: Appease PMD/Codacy * doc: fix the issue template - fix the issue template - fix the -SNAPSHOT version number * Update issue templates * Update issue templates * feat: Support more Statement Separators - `GO` - Slash `/` - Two empty lines * feat: FETCH uses EXPRESSION - `FETCH` uses `EXPRESSION` instead of SimpleJDBCParameter only - Visit/Accept `FETCH` `EXPRESSION` instead of `append` to String - Visit/Accept `OFFSET` `EXPRESSION` instead of `append` to String - Gradle: remove obsolete/incompatible `jvmArgs` from Test() * style: apply Spotless * test: commit missing test * feat: Unicode CJK Unified Ideographs (Unicode block) fixes #1741 * feat: Unicode CJK Unified Ideographs (Unicode block) fixes #1741 * feat: Functions with nested Attributes Supports `SELECT schemaName.f1(arguments).f2(arguments).f3.f4` and similar constructs fixes #1742 fixes #1050 --------- Co-authored-by: zaza <[email protected]>
1 parent 745701b commit adeed53

File tree

15 files changed

+2734
-2157
lines changed

15 files changed

+2734
-2157
lines changed

build.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,6 @@ test {
106106
minHeapSize = "128m"
107107
maxHeapSize = "1G"
108108

109-
jvmArgs << [
110-
'-Djunit.jupiter.execution.parallel.enabled=true',
111-
'-Djunit.jupiter.execution.parallel.config.strategy=dynamic',
112-
'-Djunit.jupiter.execution.parallel.mode.default=concurrent'
113-
]
114-
115109
finalizedBy check
116110
}
117111

config/checkstyle/checkstyle_checks.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
<property name="format" value="^ \* .+(Type|Default value|Validation type) is \{@code "/>
124124
<property name="minimum" value="0"/>
125125
<property name="maximum" value="0"/>
126-
<property name="message" value="Property attribute should be on new javadoc line"/>
126+
<property name="message" value="Property attributeExpression should be on new javadoc line"/>
127127
</module>
128128
<module name="RegexpSingleline">
129129
<property name="id" value="commentFirstSentenceSingleline"/>
@@ -410,7 +410,7 @@
410410
<property name="query" value="//METHOD_DEF/MODIFIERS//
411411
ANNOTATION[./IDENT[@text='Test']]/ANNOTATION_MEMBER_VALUE_PAIR
412412
[./IDENT[@text='expected']]"/>
413-
<message key="matchxpath.match" value="Avoid using 'expected' attribute in Test annotation."/>
413+
<message key="matchxpath.match" value="Avoid using 'expected' attributeExpression in Test annotation."/>
414414
</module>
415415
<module name="MatchXpath">
416416
<property name="query" value="//ANNOTATION[./IDENT[@text='Issue']]"/>

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

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
1515
import net.sf.jsqlparser.expression.operators.relational.NamedExpressionList;
1616
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
17+
import net.sf.jsqlparser.schema.*;
1718
import net.sf.jsqlparser.statement.select.OrderByElement;
1819
import net.sf.jsqlparser.statement.select.PlainSelect;
1920

@@ -29,8 +30,8 @@ public class Function extends ASTNodeAccessImpl implements Expression {
2930
private boolean distinct = false;
3031
private boolean unique = false;
3132
private boolean isEscaped = false;
32-
private Expression attribute;
33-
private String attributeName;
33+
private Expression attributeExpression;
34+
private Column attributeColumn = null;
3435
private List<OrderByElement> orderByElements;
3536
private KeepExpression keep = null;
3637
private boolean ignoreNulls = false;
@@ -43,20 +44,20 @@ public void accept(ExpressionVisitor expressionVisitor) {
4344
public String getName() {
4445
return nameparts == null ? null : String.join(".", nameparts);
4546
}
46-
47+
4748
public List<String> getMultipartName() {
4849
return nameparts;
4950
}
5051

5152
public void setName(String string) {
5253
nameparts = Arrays.asList(string);
5354
}
54-
55+
5556
public Function withName(String name) {
5657
this.setName(name);
5758
return this;
5859
}
59-
60+
6061
public void setName(List<String> string) {
6162
nameparts = string;
6263
}
@@ -148,20 +149,35 @@ public void setEscaped(boolean isEscaped) {
148149
this.isEscaped = isEscaped;
149150
}
150151

151-
public Expression getAttribute() {
152-
return attribute;
152+
public Object getAttribute() {
153+
return attributeExpression != null ? attributeExpression : attributeColumn;
153154
}
154155

155-
public void setAttribute(Expression attribute) {
156-
this.attribute = attribute;
156+
public void setAttribute(Expression attributeExpression) {
157+
this.attributeExpression = attributeExpression;
157158
}
158159

160+
@Deprecated
159161
public String getAttributeName() {
160-
return attributeName;
162+
return attributeColumn.toString();
161163
}
162164

163165
public void setAttributeName(String attributeName) {
164-
this.attributeName = attributeName;
166+
this.attributeColumn = new Column().withColumnName(attributeName);
167+
}
168+
169+
public Column getAttributeColumn() {
170+
return attributeColumn;
171+
}
172+
173+
public void setAttribute(Column attributeColumn) {
174+
attributeExpression = null;
175+
this.attributeColumn = attributeColumn;
176+
}
177+
178+
public Function withAttribute(Column attributeColumn) {
179+
setAttribute(attributeColumn);
180+
return this;
165181
}
166182

167183
public KeepExpression getKeep() {
@@ -213,14 +229,14 @@ public String toString() {
213229

214230
String ans = getName() + params;
215231

216-
if (attribute != null) {
217-
ans += "." + attribute.toString();
218-
} else if (attributeName != null) {
219-
ans += "." + attributeName;
232+
if (attributeExpression != null) {
233+
ans += "." + attributeExpression;
234+
} else if (attributeColumn != null) {
235+
ans += "." + attributeColumn;
220236
}
221237

222238
if (keep != null) {
223-
ans += " " + keep.toString();
239+
ans += " " + keep;
224240
}
225241

226242
if (isEscaped) {
@@ -235,6 +251,7 @@ public Function withAttribute(Expression attribute) {
235251
return this;
236252
}
237253

254+
@Deprecated
238255
public Function withAttributeName(String attributeName) {
239256
this.setAttributeName(attributeName);
240257
return this;

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

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,41 @@
99
*/
1010
package net.sf.jsqlparser.statement.select;
1111

12-
import net.sf.jsqlparser.expression.JdbcParameter;
12+
import net.sf.jsqlparser.expression.*;
1313

1414
import java.io.Serializable;
1515

1616
public class Fetch implements Serializable {
17-
18-
private long rowCount;
19-
private JdbcParameter fetchJdbcParameter = null;
17+
private Expression expression = null;
2018
private boolean isFetchParamFirst = false;
2119
private String fetchParam = "ROW";
2220

21+
@Deprecated
2322
public long getRowCount() {
24-
return rowCount;
23+
return expression instanceof LongValue ? ((LongValue) expression).getValue() : null;
2524
}
2625

26+
@Deprecated
2727
public void setRowCount(long l) {
28-
rowCount = l;
28+
setExpression(new LongValue(l));
29+
}
30+
31+
public Expression getExpression() {
32+
return expression;
33+
}
34+
35+
public void setExpression(Expression expression) {
36+
this.expression = expression;
37+
}
38+
39+
public Fetch withExpression(Expression expression) {
40+
this.setExpression(expression);
41+
return this;
2942
}
3043

44+
@Deprecated
3145
public JdbcParameter getFetchJdbcParameter() {
32-
return fetchJdbcParameter;
46+
return expression instanceof JdbcParameter ? (JdbcParameter) expression : null;
3347
}
3448

3549
public String getFetchParam() {
@@ -40,8 +54,9 @@ public boolean isFetchParamFirst() {
4054
return isFetchParamFirst;
4155
}
4256

57+
@Deprecated
4358
public void setFetchJdbcParameter(JdbcParameter jdbc) {
44-
fetchJdbcParameter = jdbc;
59+
this.setExpression(jdbc);
4560
}
4661

4762
public void setFetchParam(String s) {
@@ -54,9 +69,8 @@ public void setFetchParamFirst(boolean b) {
5469

5570
@Override
5671
public String toString() {
57-
return " FETCH " + (isFetchParamFirst ? "FIRST" : "NEXT") + " "
58-
+ (fetchJdbcParameter!=null ? fetchJdbcParameter.toString() :
59-
Long.toString(rowCount)) + " " + fetchParam + " ONLY";
72+
return " FETCH " + (isFetchParamFirst ? "FIRST" : "NEXT") + " " + expression.toString()
73+
+ " " + fetchParam + " ONLY";
6074
}
6175

6276
public Fetch withRowCount(long rowCount) {

0 commit comments

Comments
 (0)