Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 19 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
<groupId>org.javacc.plugin</groupId>
<artifactId>javacc-maven-plugin</artifactId>
<version>3.0.3</version>

<executions>
<execution>
<id>javacc</id>
Expand All @@ -202,15 +202,15 @@
<goal>jjtree-javacc</goal>
</goals>
</execution>

<!-- execute JJTree explicitely in order to generate the *.jj file needed for JJDoc -->
<execution>
<id>jjtree</id>
<phase>generate-sources</phase>
<goals>
<goal>jjtree</goal>
</goals>
</execution>
</execution>
</executions>
<dependencies>
<dependency>
Expand Down Expand Up @@ -394,7 +394,7 @@
<useStandardDocletOptions>true</useStandardDocletOptions>
<maxmemory>800m</maxmemory>
<doclint>none</doclint>

<!-- Doclint does not work on the Test Sources
<doclint>all,-missing</doclint>
<excludePackageNames>net.sf.jsqlparser.parser</excludePackageNames>
Expand All @@ -414,10 +414,10 @@
<artifactId>maven-jxr-plugin</artifactId>
<version>3.0.0</version>
</plugin>

<!-- Cobertura is broken with Java 1.8 and there is not fix
please refer to https://github.com/cobertura/cobertura/issues/248

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
Expand All @@ -428,13 +428,13 @@
</configuration>
</plugin>
-->

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.5</version>
</plugin>

<!-- Obsolete or Unused
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -444,60 +444,60 @@
</configuration>
</plugin>
-->

<!-- JJDoc report generating the BNF documentation -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javacc-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<!--
<!--
/**
* A flag to specify the output format for the generated documentation. If set to <code>true</code>, JJDoc will
* generate a plain text description of the BNF. Some formatting is done via tab characters, but the intention is to
* leave it as plain as possible. Specifying <code>false</code> causes JJDoc to generate a hyperlinked HTML document
* unless the parameter {@link #bnf} has been set to <code>true</code>. Default value is <code>false</code>.
*
*
* @parameter expression="${text}"
*/
-->
<text>false</text>

<!--
/**
* A flag whether to generate a plain text document with the unformatted BNF. Note that setting this option to
* <code>true</code> is only effective if the parameter {@link #text} is <code>false</code>. Default value is
* <code>false</code>.
*
*
* @parameter expression="${bnf}"
* @since 2.6
*/
-->
<bnf>false</bnf>

<!--
/**
* This option controls the structure of the generated HTML output. If set to <code>true</code>, a single HTML
* table for the entire BNF is generated. Setting it to <code>false</code> will produce one table for every
* production in the grammar.
*
*
* @parameter expression="${oneTable}" default-value=true
*/
-->
<oneTable>false</oneTable>

<!--
/**
* The hypertext reference to an optional CSS file for the generated HTML documents. If specified, this CSS file
* will be included via a <code>&lt;link&gt;</code> element in the HTML documents. Otherwise, the default style will
* be used.
*
*
* @parameter expression="${cssHref}"
* @since 2.5
*/
*/
-->
<!-- <cssHref></cssHref> -->

<outputDirectory>${project.reporting.outputDirectory}</outputDirectory>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public void visit(NamedExpressionList namedExpressionList) {

@Override
public void visit(MultiExpressionList multiExprList) {
for (ExpressionList list : multiExprList.getExprList()) {
for (ExpressionList list : multiExprList.getExpressionLists()) {
visit(list);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2021 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.expression;

import net.sf.jsqlparser.schema.Table;

import java.util.Collections;
import java.util.List;

public class SpannerInterleaveIn {

public enum OnDelete {
CASCADE,
NO_ACTION
}

private Table table;
private OnDelete onDelete;

public SpannerInterleaveIn() {

}

public SpannerInterleaveIn(Table table, OnDelete action) {
setTable(table);
setOnDelete(action);
}

public SpannerInterleaveIn(List<String> nameParts) {
this(new Table(nameParts), null);
}

public SpannerInterleaveIn(String tableName) {
this(Collections.singletonList(tableName));
}

public Table getTable() {
return table;
}

public void setTable(Table table) {
this.table = table;
}

public OnDelete getOnDelete() {
return onDelete;
}

public void setOnDelete(OnDelete action) {
this.onDelete = action;
}

@Override
public String toString() {
return "INTERLEAVE IN PARENT " + getTable().getName() +
(getOnDelete() == null ? "" : " ON DELETE " + (getOnDelete() == OnDelete.CASCADE ? "CASCADE" : "NO ACTION"));
}

public SpannerInterleaveIn withTable(Table table) {
this.setTable(table);
return this;
}

public SpannerInterleaveIn withOnDelete(OnDelete action) {
this.setOnDelete(action);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void visit(ExpressionList expressionList) {

@Override
public void visit(MultiExpressionList multiExprList) {
for (ExpressionList list : multiExprList.getExprList()) {
for (ExpressionList list : multiExprList.getExpressionLists()) {
visit(list);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.List;
import java.util.Optional;

import net.sf.jsqlparser.expression.SpannerInterleaveIn;
import net.sf.jsqlparser.schema.Table;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.StatementVisitor;
Expand All @@ -37,6 +38,7 @@ public class CreateTable implements Statement {
private boolean orReplace = false;

private RowMovement rowMovement;
private SpannerInterleaveIn interleaveIn = null;

@Override
public void accept(StatementVisitor statementVisitor) {
Expand Down Expand Up @@ -186,18 +188,21 @@ public String toString() {
sql += ")";
}
String options = PlainSelect.getStringList(tableOptionsStrings, false, false);
if (options != null && options.length() > 0) {
if (!options.isEmpty()) {
Copy link
Contributor

@manticore-projects manticore-projects Nov 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really NULL safe? In JSQLParser, we have (unfortunately) a lot of Lists which can be NULL.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is a StringBuilder result from the PlainSelect#getStringList(...)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for checking.
isEmpty is available on Java 8? I recall it was available in Java 11 only?

Copy link
Author

@s13o s13o Nov 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it is available, since 1.6
Maven build would fail otherwise but it was passed fine

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, sorry for bothering you.

Thanks for the PR, it looks very good in my opinion, well done.
But only @wumpz can merge it eventually. Please be patient.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance to have it merged this year?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the project abandoned?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project is very active and as accepted a few PRs since your contribution.
Thus you will need to resolve conflicts first (Pull + Merge + Resolve Conflicts + Commit + Push), before your PR can be accepted.

Thank you for understanding.

sql += " " + options;
}

if (rowMovement != null) {
sql += " " + rowMovement.getMode().toString() + " ROW MOVEMENT";
}
if (select != null) {
sql += " AS " + (selectParenthesis ? "(" : "") + select.toString() + (selectParenthesis ? ")" : "");
sql += " AS " + (selectParenthesis ? "(" : "") + select + (selectParenthesis ? ")" : "");
}
if (likeTable != null) {
sql += " LIKE " + (selectParenthesis ? "(" : "") + likeTable.toString() + (selectParenthesis ? ")" : "");
sql += " LIKE " + (selectParenthesis ? "(" : "") + likeTable + (selectParenthesis ? ")" : "");
}
if (interleaveIn != null) {
sql += ", " + interleaveIn;
}
return sql;
}
Expand Down Expand Up @@ -299,4 +304,17 @@ public CreateTable addIndexes(Collection<? extends Index> indexes) {
collection.addAll(indexes);
return this.withIndexes(collection);
}

public SpannerInterleaveIn getSpannerInterleaveIn() {
return interleaveIn;
}

public void setSpannerInterleaveIn(SpannerInterleaveIn spannerInterleaveIn) {
this.interleaveIn = spannerInterleaveIn;
}

public CreateTable withSpannerInterleaveIn(SpannerInterleaveIn spannerInterleaveIn) {
this.interleaveIn = spannerInterleaveIn;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public String toString() {
StringBuilder b = new StringBuilder();

b.append("(VALUES ");
for (Iterator<ExpressionList> it = getMultiExpressionList().getExprList().iterator(); it.
for (Iterator<ExpressionList> it = getMultiExpressionList().getExpressionLists().iterator(); it.
hasNext();) {
b.append(PlainSelect.getStringList(it.next().getExpressions(), true, !isNoBrackets()));
if (it.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ public void visit(LateralSubSelect lateralSubSelect) {

@Override
public void visit(MultiExpressionList multiExprList) {
for (ExpressionList exprList : multiExprList.getExprList()) {
for (ExpressionList exprList : multiExprList.getExpressionLists()) {
exprList.accept(this);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void deParse(CreateIndex createIndex) {

if (index.getColumnsNames() != null) {
buffer.append(" (");
buffer.append(index.getColumnWithParams().stream()
buffer.append(index.getColumns().stream()
.map(cp -> cp.columnName + (cp.getParams() != null ? " " + String.join(" ", cp.getParams()) : ""))
.collect(joining(", ")));
buffer.append(")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ public void deParse(CreateTable createTable) {
buffer.append(")");
}
}
if (createTable.getSpannerInterleaveIn() != null) {
buffer.append(", ").append(createTable.getSpannerInterleaveIn());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public void deParse(DeclareStatement declare) {
declare.getUserVariable().accept(expressionVisitor);
}

if (declare.getType() == DeclareType.AS) {
if (declare.getDeclareType() == DeclareType.AS) {
buffer.append(" AS ");
buffer.append(declare.getTypeName());
return;
}

if (declare.getType() == DeclareType.TABLE) {
if (declare.getDeclareType() == DeclareType.TABLE) {
buffer.append(" TABLE (");
for (int i = 0; i < declare.getColumnDefinitions().size(); i++) {
if (i > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ public void visit(ExtractExpression eexpr) {

@Override
public void visit(MultiExpressionList multiExprList) {
for (Iterator<ExpressionList> it = multiExprList.getExprList().iterator(); it.hasNext();) {
for (Iterator<ExpressionList> it = multiExprList.getExpressionLists().iterator(); it.hasNext();) {
it.next().accept(this);
if (it.hasNext()) {
buffer.append(", ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void visit(NamedExpressionList NamedExpressionList) {
@Override
public void visit(MultiExpressionList multiExprList) {
buffer.append(" VALUES ");
for (Iterator<ExpressionList> it = multiExprList.getExprList().iterator(); it.hasNext();) {
for (Iterator<ExpressionList> it = multiExprList.getExpressionLists().iterator(); it.hasNext();) {
buffer.append("(");
for (Iterator<Expression> iter = it.next().getExpressions().iterator(); iter.hasNext();) {
Expression expression = iter.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void setSelectVisitor(SelectVisitor visitor) {
@Override
public void visit(MultiExpressionList multiExprList) {
buffer.append("VALUES ");
for (Iterator<ExpressionList> it = multiExprList.getExprList().iterator(); it.hasNext();) {
for (Iterator<ExpressionList> it = multiExprList.getExpressionLists().iterator(); it.hasNext();) {
buffer.append("(");
for (Iterator<Expression> iter = it.next().getExpressions().iterator(); iter.hasNext();) {
Expression expression = iter.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void visit(NamedExpressionList namedExpressionList) {
@Override
public void visit(MultiExpressionList multiExprList) {
buffer.append(" VALUES ");
for (Iterator<ExpressionList> it = multiExprList.getExprList().iterator(); it.hasNext();) {
for (Iterator<ExpressionList> it = multiExprList.getExpressionLists().iterator(); it.hasNext();) {
buffer.append("(");
for (Iterator<Expression> iter = it.next().getExpressions().iterator(); iter.hasNext();) {
Expression expression = iter.next();
Expand Down
Loading