Skip to content

Commit 996ebd9

Browse files
Merge branch 'master' of github.com:manticore-projects/JSqlParser
# Conflicts: # src/site/sphinx/changelog.rst
2 parents f5e9f53 + 6f27765 commit 996ebd9

File tree

11 files changed

+307
-55
lines changed

11 files changed

+307
-55
lines changed

.github/workflows/sphinx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
- name: Install XSLT Processor
1010
run: sudo apt-get install xsltproc sphinx-common
1111
- name: Install dependencies
12-
run: pip install sphinx_rtd_theme sphinx-book-theme myst_parser sphinx-prompt sphinx_substitution_extensions sphinx_issues sphinx-tabs sphinx_inline_tabs pygments
12+
run: pip install furo myst_parser sphinx-prompt sphinx_substitution_extensions sphinx_issues sphinx_inline_tabs pygments
1313
- name: Checkout project sources
1414
uses: actions/checkout@v2
1515
with:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void accept(ExpressionVisitor expressionVisitor) {
9696
expressionVisitor.visit(this);
9797
}
9898

99-
StringBuilder appendTo(StringBuilder builder) {
99+
public StringBuilder appendTo(StringBuilder builder) {
100100
builder.append("Trim(");
101101

102102
if (trimSpecification != null) {

src/main/java/net/sf/jsqlparser/parser/ASTNodeAccessImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,15 @@ public void setASTNode(SimpleNode node) {
2323
this.node = node;
2424
}
2525

26+
public StringBuilder appendTo(StringBuilder builder) {
27+
SimpleNode simpleNode = getASTNode();
28+
Token token = simpleNode.jjtGetFirstToken();
29+
Token lastToken = simpleNode.jjtGetLastToken();
30+
while (token.next != null && token.absoluteEnd <= lastToken.absoluteEnd) {
31+
builder.append(" ").append(token.image);
32+
token = token.next;
33+
}
34+
return builder;
35+
}
36+
2637
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package net.sf.jsqlparser.statement.select;
2+
3+
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
4+
5+
public class ForClause extends ASTNodeAccessImpl {
6+
public enum ForOption {
7+
BROWSE, XML, JSON;
8+
9+
public static ForOption from(String option) {
10+
return Enum.valueOf(ForOption.class, option.toUpperCase());
11+
}
12+
}
13+
14+
private ForOption forOption;
15+
16+
public ForOption getForOption() {
17+
return forOption;
18+
}
19+
20+
public ForClause setForOption(String forOption) {
21+
this.forOption = ForOption.from(forOption);
22+
return this;
23+
}
24+
25+
@Override
26+
public String toString() {
27+
return appendTo(new StringBuilder()).toString();
28+
}
29+
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public abstract class Select extends ASTNodeAccessImpl implements Statement, Exp
3030
Fetch fetch;
3131
WithIsolation isolation;
3232
boolean oracleSiblings = false;
33+
34+
ForClause forClause = null;
35+
3336
List<OrderByElement> orderByElements;
3437

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

160+
public ForClause getForClause() {
161+
return forClause;
162+
}
163+
164+
public Select setForClause(ForClause forClause) {
165+
this.forClause = forClause;
166+
return this;
167+
}
168+
157169
public List<OrderByElement> getOrderByElements() {
158170
return orderByElements;
159171
}
@@ -261,6 +273,10 @@ public StringBuilder appendTo(StringBuilder builder) {
261273

262274
appendSelectBodyTo(builder);
263275

276+
if (forClause != null) {
277+
forClause.appendTo(builder);
278+
}
279+
264280
builder.append(orderByToString(oracleSiblings, orderByElements));
265281

266282
if (limitBy != null) {

src/main/java/net/sf/jsqlparser/util/deparser/ExpressionDeParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,12 +820,12 @@ public void visit(IntervalExpression intervalExpression) {
820820
if (intervalExpression.isUsingIntervalKeyword()) {
821821
buffer.append("INTERVAL ");
822822
}
823-
if (intervalExpression.getExpression()!=null) {
823+
if (intervalExpression.getExpression() != null) {
824824
intervalExpression.getExpression().accept(this);
825825
} else {
826826
buffer.append(intervalExpression.getParameter());
827827
}
828-
if (intervalExpression.getIntervalType()!=null) {
828+
if (intervalExpression.getIntervalType() != null) {
829829
buffer.append(" ").append(intervalExpression.getIntervalType());
830830
}
831831
}

src/main/java/net/sf/jsqlparser/util/deparser/SelectDeParser.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ public void visit(PlainSelect plainSelect) {
272272
buffer.append(" SKIP LOCKED");
273273
}
274274
}
275+
if (plainSelect.getForClause() != null) {
276+
plainSelect.getForClause().appendTo(buffer);
277+
}
278+
275279
if (plainSelect.getOrderByElements() != null) {
276280
new OrderByDeParser(expressionVisitor, buffer).deParse(plainSelect.isOracleSiblings(),
277281
plainSelect.getOrderByElements());

0 commit comments

Comments
 (0)