Skip to content

Commit

Permalink
Assorted Fixes #6 (#1740)
Browse files Browse the repository at this point in the history
* 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 <tzarna@gmail.com>
  • Loading branch information
manticore-projects and zaza authored Mar 9, 2023
1 parent 745701b commit adeed53
Show file tree
Hide file tree
Showing 15 changed files with 2,734 additions and 2,157 deletions.
6 changes: 0 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ test {
minHeapSize = "128m"
maxHeapSize = "1G"

jvmArgs << [
'-Djunit.jupiter.execution.parallel.enabled=true',
'-Djunit.jupiter.execution.parallel.config.strategy=dynamic',
'-Djunit.jupiter.execution.parallel.mode.default=concurrent'
]

finalizedBy check
}

Expand Down
4 changes: 2 additions & 2 deletions config/checkstyle/checkstyle_checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<property name="format" value="^ \* .+(Type|Default value|Validation type) is \{@code "/>
<property name="minimum" value="0"/>
<property name="maximum" value="0"/>
<property name="message" value="Property attribute should be on new javadoc line"/>
<property name="message" value="Property attributeExpression should be on new javadoc line"/>
</module>
<module name="RegexpSingleline">
<property name="id" value="commentFirstSentenceSingleline"/>
Expand Down Expand Up @@ -410,7 +410,7 @@
<property name="query" value="//METHOD_DEF/MODIFIERS//
ANNOTATION[./IDENT[@text='Test']]/ANNOTATION_MEMBER_VALUE_PAIR
[./IDENT[@text='expected']]"/>
<message key="matchxpath.match" value="Avoid using 'expected' attribute in Test annotation."/>
<message key="matchxpath.match" value="Avoid using 'expected' attributeExpression in Test annotation."/>
</module>
<module name="MatchXpath">
<property name="query" value="//ANNOTATION[./IDENT[@text='Issue']]"/>
Expand Down
49 changes: 33 additions & 16 deletions src/main/java/net/sf/jsqlparser/expression/Function.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
import net.sf.jsqlparser.expression.operators.relational.NamedExpressionList;
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
import net.sf.jsqlparser.schema.*;
import net.sf.jsqlparser.statement.select.OrderByElement;
import net.sf.jsqlparser.statement.select.PlainSelect;

Expand All @@ -29,8 +30,8 @@ public class Function extends ASTNodeAccessImpl implements Expression {
private boolean distinct = false;
private boolean unique = false;
private boolean isEscaped = false;
private Expression attribute;
private String attributeName;
private Expression attributeExpression;
private Column attributeColumn = null;
private List<OrderByElement> orderByElements;
private KeepExpression keep = null;
private boolean ignoreNulls = false;
Expand All @@ -43,20 +44,20 @@ public void accept(ExpressionVisitor expressionVisitor) {
public String getName() {
return nameparts == null ? null : String.join(".", nameparts);
}

public List<String> getMultipartName() {
return nameparts;
}

public void setName(String string) {
nameparts = Arrays.asList(string);
}

public Function withName(String name) {
this.setName(name);
return this;
}

public void setName(List<String> string) {
nameparts = string;
}
Expand Down Expand Up @@ -148,20 +149,35 @@ public void setEscaped(boolean isEscaped) {
this.isEscaped = isEscaped;
}

public Expression getAttribute() {
return attribute;
public Object getAttribute() {
return attributeExpression != null ? attributeExpression : attributeColumn;
}

public void setAttribute(Expression attribute) {
this.attribute = attribute;
public void setAttribute(Expression attributeExpression) {
this.attributeExpression = attributeExpression;
}

@Deprecated
public String getAttributeName() {
return attributeName;
return attributeColumn.toString();
}

public void setAttributeName(String attributeName) {
this.attributeName = attributeName;
this.attributeColumn = new Column().withColumnName(attributeName);
}

public Column getAttributeColumn() {
return attributeColumn;
}

public void setAttribute(Column attributeColumn) {
attributeExpression = null;
this.attributeColumn = attributeColumn;
}

public Function withAttribute(Column attributeColumn) {
setAttribute(attributeColumn);
return this;
}

public KeepExpression getKeep() {
Expand Down Expand Up @@ -213,14 +229,14 @@ public String toString() {

String ans = getName() + params;

if (attribute != null) {
ans += "." + attribute.toString();
} else if (attributeName != null) {
ans += "." + attributeName;
if (attributeExpression != null) {
ans += "." + attributeExpression;
} else if (attributeColumn != null) {
ans += "." + attributeColumn;
}

if (keep != null) {
ans += " " + keep.toString();
ans += " " + keep;
}

if (isEscaped) {
Expand All @@ -235,6 +251,7 @@ public Function withAttribute(Expression attribute) {
return this;
}

@Deprecated
public Function withAttributeName(String attributeName) {
this.setAttributeName(attributeName);
return this;
Expand Down
36 changes: 25 additions & 11 deletions src/main/java/net/sf/jsqlparser/statement/select/Fetch.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,41 @@
*/
package net.sf.jsqlparser.statement.select;

import net.sf.jsqlparser.expression.JdbcParameter;
import net.sf.jsqlparser.expression.*;

import java.io.Serializable;

public class Fetch implements Serializable {

private long rowCount;
private JdbcParameter fetchJdbcParameter = null;
private Expression expression = null;
private boolean isFetchParamFirst = false;
private String fetchParam = "ROW";

@Deprecated
public long getRowCount() {
return rowCount;
return expression instanceof LongValue ? ((LongValue) expression).getValue() : null;
}

@Deprecated
public void setRowCount(long l) {
rowCount = l;
setExpression(new LongValue(l));
}

public Expression getExpression() {
return expression;
}

public void setExpression(Expression expression) {
this.expression = expression;
}

public Fetch withExpression(Expression expression) {
this.setExpression(expression);
return this;
}

@Deprecated
public JdbcParameter getFetchJdbcParameter() {
return fetchJdbcParameter;
return expression instanceof JdbcParameter ? (JdbcParameter) expression : null;
}

public String getFetchParam() {
Expand All @@ -40,8 +54,9 @@ public boolean isFetchParamFirst() {
return isFetchParamFirst;
}

@Deprecated
public void setFetchJdbcParameter(JdbcParameter jdbc) {
fetchJdbcParameter = jdbc;
this.setExpression(jdbc);
}

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

@Override
public String toString() {
return " FETCH " + (isFetchParamFirst ? "FIRST" : "NEXT") + " "
+ (fetchJdbcParameter!=null ? fetchJdbcParameter.toString() :
Long.toString(rowCount)) + " " + fetchParam + " ONLY";
return " FETCH " + (isFetchParamFirst ? "FIRST" : "NEXT") + " " + expression.toString()
+ " " + fetchParam + " ONLY";
}

public Fetch withRowCount(long rowCount) {
Expand Down
Loading

0 comments on commit adeed53

Please sign in to comment.