Skip to content

Commit

Permalink
Merge branch 'master' of github.com:manticore-projects/JSqlParser
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/site/sphinx/changelog.rst
  • Loading branch information
manticore-projects committed Jun 11, 2023
2 parents f5e9f53 + 6f27765 commit 996ebd9
Show file tree
Hide file tree
Showing 11 changed files with 307 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: Install XSLT Processor
run: sudo apt-get install xsltproc sphinx-common
- name: Install dependencies
run: pip install sphinx_rtd_theme sphinx-book-theme myst_parser sphinx-prompt sphinx_substitution_extensions sphinx_issues sphinx-tabs sphinx_inline_tabs pygments
run: pip install furo myst_parser sphinx-prompt sphinx_substitution_extensions sphinx_issues sphinx_inline_tabs pygments
- name: Checkout project sources
uses: actions/checkout@v2
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void accept(ExpressionVisitor expressionVisitor) {
expressionVisitor.visit(this);
}

StringBuilder appendTo(StringBuilder builder) {
public StringBuilder appendTo(StringBuilder builder) {
builder.append("Trim(");

if (trimSpecification != null) {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/net/sf/jsqlparser/parser/ASTNodeAccessImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,15 @@ public void setASTNode(SimpleNode node) {
this.node = node;
}

public StringBuilder appendTo(StringBuilder builder) {
SimpleNode simpleNode = getASTNode();
Token token = simpleNode.jjtGetFirstToken();
Token lastToken = simpleNode.jjtGetLastToken();
while (token.next != null && token.absoluteEnd <= lastToken.absoluteEnd) {
builder.append(" ").append(token.image);
token = token.next;
}
return builder;
}

}
29 changes: 29 additions & 0 deletions src/main/java/net/sf/jsqlparser/statement/select/ForClause.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.sf.jsqlparser.statement.select;

import net.sf.jsqlparser.parser.ASTNodeAccessImpl;

public class ForClause extends ASTNodeAccessImpl {
public enum ForOption {
BROWSE, XML, JSON;

public static ForOption from(String option) {
return Enum.valueOf(ForOption.class, option.toUpperCase());
}
}

private ForOption forOption;

public ForOption getForOption() {
return forOption;
}

public ForClause setForOption(String forOption) {
this.forOption = ForOption.from(forOption);
return this;
}

@Override
public String toString() {
return appendTo(new StringBuilder()).toString();
}
}
16 changes: 16 additions & 0 deletions src/main/java/net/sf/jsqlparser/statement/select/Select.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public abstract class Select extends ASTNodeAccessImpl implements Statement, Exp
Fetch fetch;
WithIsolation isolation;
boolean oracleSiblings = false;

ForClause forClause = null;

List<OrderByElement> orderByElements;

public static String orderByToString(List<OrderByElement> orderByElements) {
Expand Down Expand Up @@ -154,6 +157,15 @@ public Select withOracleSiblings(boolean oracleSiblings) {
return this;
}

public ForClause getForClause() {
return forClause;
}

public Select setForClause(ForClause forClause) {
this.forClause = forClause;
return this;
}

public List<OrderByElement> getOrderByElements() {
return orderByElements;
}
Expand Down Expand Up @@ -261,6 +273,10 @@ public StringBuilder appendTo(StringBuilder builder) {

appendSelectBodyTo(builder);

if (forClause != null) {
forClause.appendTo(builder);
}

builder.append(orderByToString(oracleSiblings, orderByElements));

if (limitBy != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,12 @@ public void visit(IntervalExpression intervalExpression) {
if (intervalExpression.isUsingIntervalKeyword()) {
buffer.append("INTERVAL ");
}
if (intervalExpression.getExpression()!=null) {
if (intervalExpression.getExpression() != null) {
intervalExpression.getExpression().accept(this);
} else {
buffer.append(intervalExpression.getParameter());
}
if (intervalExpression.getIntervalType()!=null) {
if (intervalExpression.getIntervalType() != null) {
buffer.append(" ").append(intervalExpression.getIntervalType());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ public void visit(PlainSelect plainSelect) {
buffer.append(" SKIP LOCKED");
}
}
if (plainSelect.getForClause() != null) {
plainSelect.getForClause().appendTo(buffer);
}

if (plainSelect.getOrderByElements() != null) {
new OrderByDeParser(expressionVisitor, buffer).deParse(plainSelect.isOracleSiblings(),
plainSelect.getOrderByElements());
Expand Down
Loading

0 comments on commit 996ebd9

Please sign in to comment.