Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
747152a
Fixes #1684: Support CREATE MATERIALIZED VIEW with AUTO REFRESH
zaza Dec 11, 2022
9e09005
Merge branch 'master' into 1684-create-mv-auto-refresh
zaza Dec 22, 2022
ea4477b
Reduce cyclomatic complexity in CreateView.toString
zaza Jan 8, 2023
b5321d6
Enhanced Keywords
manticore-projects Oct 18, 2021
5fae2f5
Fix incorrect tests
manticore-projects Oct 18, 2021
f49e828
Define Reserved Keywords explicitly
manticore-projects Oct 24, 2021
86f337d
Fix test resources
manticore-projects Oct 24, 2021
2d51a82
Adjust Gradle to JUnit 5
manticore-projects Nov 22, 2021
232aff6
Do not mark SpeedTest for concurrent execution
manticore-projects Nov 24, 2021
3ba5410
Remove unused imports
manticore-projects Nov 28, 2021
e960a35
Adjust Gradle to JUnit 5
manticore-projects Nov 22, 2021
67f7951
Do not mark SpeedTest for concurrent execution
manticore-projects Nov 24, 2021
a016be0
Remove unused imports
manticore-projects Nov 28, 2021
2ef6637
Sphinx Documentation
manticore-projects Sep 2, 2022
57193b8
doc: request for `Conventional Commit` messages
manticore-projects Sep 6, 2022
b94b2cc
feat: make important Classes Serializable
manticore-projects Sep 15, 2022
02202c5
chore: Make Serializable
manticore-projects Oct 14, 2022
a3ca325
doc: Better integration of the RR diagrams
manticore-projects Jan 7, 2023
fcb5ab1
Merge
manticore-projects Jan 7, 2023
c57c427
feat: Oracle Alternative Quoting
manticore-projects Jan 29, 2023
2aec1f6
style: Appease PMD/Codacy
manticore-projects Jan 29, 2023
1c8d8da
feat: CREATE VIEW ... REFRESH AUTO...
manticore-projects Jan 30, 2023
b707b23
doc: fix the issue template
manticore-projects Feb 1, 2023
46314c4
Update issue templates
manticore-projects Feb 1, 2023
4aeafbc
Update issue templates
manticore-projects Feb 1, 2023
b081484
feat: Support more Statement Separators
manticore-projects Feb 2, 2023
5885e1c
Merge remote-tracking branch 'origin/master'
manticore-projects Feb 13, 2023
581d97a
Merge branch 'master' of https://github.com/JSQLParser/JSqlParser
manticore-projects Feb 24, 2023
0979b2e
feat: FETCH uses EXPRESSION
manticore-projects Mar 7, 2023
ed17f87
style: apply Spotless
manticore-projects Mar 7, 2023
96808d2
test: commit missing test
manticore-projects Mar 7, 2023
21c4550
Merge branch 'master' of https://github.com/JSQLParser/JSqlParser
manticore-projects Mar 12, 2023
029588f
fix: JSon Operator can use Simple Function
manticore-projects Mar 14, 2023
4b312ff
style: Reformat changed files and headers
manticore-projects Mar 14, 2023
91c9503
style: Remove unused variable
manticore-projects Mar 14, 2023
64fe908
feat: Add support for Hangul "\uAC00"-"\uD7A3"
manticore-projects Mar 17, 2023
a6d9e40
style: expose `SetStatement` key-value list
manticore-projects Mar 17, 2023
c5ec0c5
style: Appease PMD/Codacy
manticore-projects Mar 17, 2023
8bfcde6
Merge remote-tracking branch 'manticore/JSonOperatorIssue1571' into J…
manticore-projects Mar 17, 2023
043b71a
feat: `ConflictTarget` allows multiple `IndexColumnNames`
manticore-projects Mar 18, 2023
f75df51
doc: fix reference in the Java Doc
manticore-projects Mar 18, 2023
500046f
build: better Upload Groovy Task
manticore-projects Mar 18, 2023
e460cda
feat: ParenthesedSelectBody and ParenthesedFromItem
manticore-projects Mar 23, 2023
ad9e98d
feat: ParenthesedSelectBody and ParenthesedFromItem
manticore-projects Mar 23, 2023
31935b3
Merge remote-tracking branch 'origin/master' into ParenthesedSelectBody
manticore-projects Mar 23, 2023
f0f8876
feat: ParenthesedSelectBody and ParenthesedFromItem
manticore-projects Mar 23, 2023
d134137
feat: ParenthesedSelectBody and ParenthesedFromItem
manticore-projects Mar 23, 2023
616bf23
feat: ParenthesedSelectBody and ParenthesedFromItem
manticore-projects Mar 24, 2023
465934c
feat: ParenthesedSelectBody and ParenthesedFromItem
manticore-projects Mar 25, 2023
9b3294c
style: Appease PMD/Codacy
manticore-projects Mar 25, 2023
e470d6e
style: Appease PMD/Codacy
manticore-projects Mar 25, 2023
9f999e3
feat: Refactor SelectBody implementations
manticore-projects Mar 26, 2023
8cddd39
feat: Refactor SelectBody implementations
manticore-projects Mar 27, 2023
d0ea5e0
style: Code cleanup
manticore-projects Mar 27, 2023
4056ca5
feat: Merge `SelectBody` into `Select` Statement
manticore-projects Mar 27, 2023
a6aab00
style: Remove unused import
manticore-projects Mar 27, 2023
a914fe0
test: @Disabled invalid Test
manticore-projects Mar 27, 2023
8b9dd3e
style: Appease PMD/Codacy
manticore-projects Mar 27, 2023
ab127d4
test: Add a SubSelect Parsing Test
manticore-projects Apr 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: ParenthesedSelectBody and ParenthesedFromItem
- First properly working version
- Work in progress, 13 tests failing
  • Loading branch information
manticore-projects committed Mar 23, 2023
commit e460cda3dd94da60b02264902429c68848f5f8ac
2 changes: 2 additions & 0 deletions src/main/java/net/sf/jsqlparser/parser/CCJSqlParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public static Statement parse(String sql, Consumer<CCJSqlParser> consumer) throw
consumer.accept(parser);
}
statement = parseStatement(parser);
} else {
throw ex;
}
}
return statement;
Expand Down
59 changes: 19 additions & 40 deletions src/main/java/net/sf/jsqlparser/parser/feature/Feature.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public enum Feature {
limitOffset,
/**
* "OFFSET offset"
*
* @see Offset
*/
offset,
Expand All @@ -129,12 +130,12 @@ public enum Feature {
fetch,
/**
* "FETCH FIRST row_count (ROW | ROWS) ONLY"
*
* @see Fetch#isFetchParamFirst()
*/
fetchFirst,
/**
* "FETCH NEXT row_count (ROW | ROWS) ONLY"
* if not {@link #fetchFirst}
* "FETCH NEXT row_count (ROW | ROWS) ONLY" if not {@link #fetchFirst}
*
* @see Fetch#isFetchParamFirst()
*/
Expand Down Expand Up @@ -193,8 +194,7 @@ public enum Feature {
*/
joinApply,

joinWindow,
joinUsingColumns,
joinWindow, joinUsingColumns,

/**
* "SKIP variable" | "SKIP ?" | "SKIP rowCount"
Expand All @@ -203,9 +203,7 @@ public enum Feature {
*/
skip,
/**
* "FIRST" \?|[0-9]+|variable
* or
* "LIMIT" \?|[0-9]+|variable
* "FIRST" \?|[0-9]+|variable or "LIMIT" \?|[0-9]+|variable
*
* @see First
*/
Expand Down Expand Up @@ -328,9 +326,7 @@ public enum Feature {
/**
* UPDATE table SET (col, ...) = (SELECT col, ... )"
*/
updateUseSelect,
updateOrderBy,
updateLimit,
updateUseSelect, updateOrderBy, updateLimit,
/**
* "RETURNING expr(, expr)*"
*
Expand Down Expand Up @@ -429,8 +425,7 @@ public enum Feature {
*
* @see Execute
*/
execute,
executeExec, executeCall, executeExecute,
execute, executeExec, executeCall, executeExecute,

/**
* SQL "EXECUTE" statement is allowed
Expand All @@ -454,13 +449,7 @@ public enum Feature {
*
* @see Drop
*/
drop,
dropTable,
dropIndex,
dropView,
dropSchema,
dropSequence,
dropTableIfExists, dropIndexIfExists, dropViewIfExists, dropSchemaIfExists, dropSequenceIfExists,
drop, dropTable, dropIndex, dropView, dropSchema, dropSequence, dropTableIfExists, dropIndexIfExists, dropViewIfExists, dropSchemaIfExists, dropSequenceIfExists,

/**
* SQL "CREATE SCHEMA" statement is allowed
Expand Down Expand Up @@ -650,17 +639,12 @@ public enum Feature {
*/
pivotXml,

setOperation,
setOperationUnion,
setOperationIntersect,
setOperationExcept,
setOperationMinus,
setOperation, setOperationUnion, setOperationIntersect, setOperationExcept, setOperationMinus,

/**
* "WITH name query"
*/
withItem,
withItemRecursive,
withItem, withItemRecursive,

lateralSubSelect,
/**
Expand Down Expand Up @@ -722,14 +706,11 @@ public enum Feature {
*
* @see OracleHierarchicalExpression
*/
oracleHierarchicalExpression,
oracleOrderBySiblings,
oracleHierarchicalExpression, oracleOrderBySiblings,

// MYSQL

mySqlHintStraightJoin,
mysqlSqlCacheFlag,
mysqlCalcFoundRows,
mySqlHintStraightJoin, mysqlSqlCacheFlag, mysqlCalcFoundRows,

// SQLSERVER

Expand All @@ -744,32 +725,30 @@ public enum Feature {
allowSquareBracketQuotation(false),

/**
* allow parsing of RDBMS specific syntax by switching off SQL Standard
* Compliant Syntax
* allow parsing of RDBMS specific syntax by switching off SQL Standard Compliant Syntax
*/
allowPostgresSpecificSyntax(false),

// PERFORMANCE

/**
* allows complex expression parameters or named parameters for functions
* will be switched off, when deep nesting of functions is detected
* allows complex expression parameters or named parameters for functions will be switched off,
* when deep nesting of functions is detected
*/
allowComplexParsing(true),

/**
* allows passing through Unsupported Statements as a plain List of Tokens
* needs to be switched off, when VALIDATING statements or parsing blocks
* allows passing through Unsupported Statements as a plain List of Tokens needs to be switched
* off, when VALIDATING statements or parsing blocks
*/
allowUnsupportedStatements(false),

timeOut( 6000),
timeOut(6000),

/**
* allows Backslash '\' as Escape Character
*/
allowBackslashEscapeCharacter(false),
;
allowBackslashEscapeCharacter(false),;

private final Object value;
private final boolean configurable;
Expand Down
47 changes: 19 additions & 28 deletions src/main/java/net/sf/jsqlparser/statement/insert/Insert.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@
*/
package net.sf.jsqlparser.statement.insert;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;

import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.OracleHint;
import net.sf.jsqlparser.expression.RowConstructor;
Expand All @@ -30,10 +23,16 @@
import net.sf.jsqlparser.statement.select.Select;
import net.sf.jsqlparser.statement.select.SelectBody;
import net.sf.jsqlparser.statement.select.SelectItem;
import net.sf.jsqlparser.statement.select.SetOperationList;
import net.sf.jsqlparser.statement.select.WithItem;
import net.sf.jsqlparser.statement.values.ValuesStatement;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;

@SuppressWarnings({"PMD.CyclomaticComplexity"})
public class Insert implements Statement {

Expand Down Expand Up @@ -103,27 +102,19 @@ public void setColumns(List<Column> list) {
public ItemsList getItemsList() {
if (select!=null) {
SelectBody selectBody = select.getSelectBody();
if (selectBody instanceof SetOperationList) {
SetOperationList setOperationList = (SetOperationList) selectBody;
List<SelectBody> selects = setOperationList.getSelects();

if (selects.size() == 1) {
SelectBody selectBody1 = selects.get(0);
if (selectBody1 instanceof ValuesStatement) {
ValuesStatement valuesStatement = (ValuesStatement) selectBody1;
if (valuesStatement.getExpressions() instanceof ExpressionList) {
ExpressionList expressionList = (ExpressionList) valuesStatement.getExpressions();

if (expressionList.getExpressions().size() == 1 && expressionList.getExpressions().get(0) instanceof RowConstructor) {
RowConstructor rowConstructor = (RowConstructor) expressionList.getExpressions().get(0);
return rowConstructor.getExprList();
} else {
return expressionList;
}
} else {
return valuesStatement.getExpressions();
}
if (selectBody instanceof ValuesStatement) {
ValuesStatement valuesStatement = (ValuesStatement) selectBody;
if (valuesStatement.getExpressions() instanceof ExpressionList) {
ExpressionList expressionList = (ExpressionList) valuesStatement.getExpressions();

if (expressionList.getExpressions().size() == 1 && expressionList.getExpressions().get(0) instanceof RowConstructor) {
RowConstructor rowConstructor = (RowConstructor) expressionList.getExpressions().get(0);
return rowConstructor.getExprList();
} else {
return expressionList;
}
} else {
return valuesStatement.getExpressions();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package net.sf.jsqlparser.statement.select;

public class ParenthesedJoin extends Join {
private Join join;

public Join getJoin() {
return join;
}

public void setJoin(Join join) {
this.join = join;
}

public ParenthesedJoin withJoin(Join join) {
setJoin(join);
return this;
}

@Override
public String toString() {
return "(" + super.toString() + ")";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.sf.jsqlparser.statement.select;

public class ParenthesedSelectBody implements SelectBody {
private SelectBody selectBody;

public SelectBody getSelectBody() {
return selectBody;
}

public void setSelectBody(SelectBody selectBody) {
this.selectBody = selectBody;
}

public ParenthesedSelectBody withSelectBody(SelectBody selectBody) {
setSelectBody(selectBody);
return this;
}

@Override
public void accept(SelectVisitor selectVisitor) {
selectVisitor.visit(this);
}

public String toString() {
return "(" + selectBody + ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@

import net.sf.jsqlparser.expression.Alias;

public class ParenthesisFromItem implements FromItem {
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

public class ParenthesisFromItem implements FromItem {
private FromItem fromItem;

private List<Join> joins;
private Alias alias;
private Pivot pivot;
private UnPivot unPivot;

public ParenthesisFromItem() {
}
Expand All @@ -32,14 +38,54 @@ public final void setFromItem(FromItem fromItem) {
this.fromItem = fromItem;
}

public List<Join> getJoins() {
return joins;
}

public FromItem addJoins(Join... joins) {
List<Join> list = Optional.ofNullable(getJoins()).orElseGet(ArrayList::new);
Collections.addAll(list, joins);
return withJoins(list);
}

public FromItem withJoins(List<Join> joins) {
this.setJoins(joins);
return this;
}

public void setJoins(List<Join> list) {
joins = list;
}

@Override
public void accept(FromItemVisitor fromItemVisitor) {
fromItemVisitor.visit(this);
}

public StringBuilder appendTo(StringBuilder builder) {
builder.append("(");
builder.append(fromItem);
if (joins != null) {
for (Join join : joins) {
if (join.isSimple()) {
builder.append(", ").append(join);
} else {
builder.append(" ").append(join);
}
}
}
builder.append(")");

if (alias!=null) {
builder.append(alias);
}

return builder;
}

@Override
public String toString() {
return "(" + fromItem + ")" + (alias != null ? alias.toString() : "");
return appendTo(new StringBuilder()).toString();
}

@Override
Expand All @@ -54,22 +100,22 @@ public void setAlias(Alias alias) {

@Override
public Pivot getPivot() {
return null;
return pivot;
}

@Override
public void setPivot(Pivot pivot) {
throw new UnsupportedOperationException("Not supported yet.");
this.pivot = pivot;
}

@Override
public UnPivot getUnPivot() {
return null;
return unPivot;
}

@Override
public void setUnPivot(UnPivot unpivot) {
throw new UnsupportedOperationException("Not supported yet.");
this.unPivot = unpivot;
}

public ParenthesisFromItem withFromItem(FromItem fromItem) {
Expand Down
Loading