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: 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()
  • Loading branch information
manticore-projects committed Mar 7, 2023
commit 0979b2e5ea76b8c49d02e24fba7994cb750aa2e6
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
34 changes: 24 additions & 10 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 @@ -55,8 +70,7 @@ public void setFetchParamFirst(boolean b) {
@Override
public String toString() {
return " FETCH " + (isFetchParamFirst ? "FIRST" : "NEXT") + " "
+ (fetchJdbcParameter!=null ? fetchJdbcParameter.toString() :
Long.toString(rowCount)) + " " + fetchParam + " ONLY";
+ expression.toString() + " " + fetchParam + " ONLY";
}

public Fetch withRowCount(long rowCount) {
Expand Down
20 changes: 8 additions & 12 deletions src/main/java/net/sf/jsqlparser/util/deparser/SelectDeParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ public void visit(PlainSelect plainSelect) {
new LimitDeparser(buffer).deParse(plainSelect.getLimit());
}
if (plainSelect.getOffset() != null) {
deparseOffset(plainSelect.getOffset());
visit(plainSelect.getOffset());
}
if (plainSelect.getFetch() != null) {
deparseFetch(plainSelect.getFetch());
visit(plainSelect.getFetch());
}
if (plainSelect.getWithIsolation() != null) {
buffer.append(plainSelect.getWithIsolation().toString());
Expand Down Expand Up @@ -349,30 +349,26 @@ public void visit(PivotXml pivot) {
buffer.append("))");
}

public void deparseOffset(Offset offset) {
public void visit(Offset offset) {
// OFFSET offset
// or OFFSET offset (ROW | ROWS)
buffer.append(" OFFSET ");
buffer.append(offset.getOffset());
offset.getOffset().accept(expressionVisitor);
if (offset.getOffsetParam() != null) {
buffer.append(" ").append(offset.getOffsetParam());
}

}

public void deparseFetch(Fetch fetch) {
public void visit(Fetch fetch) {
// FETCH (FIRST | NEXT) row_count (ROW | ROWS) ONLY
buffer.append(" FETCH ");
if (fetch.isFetchParamFirst()) {
buffer.append("FIRST ");
} else {
buffer.append("NEXT ");
}
if (fetch.getFetchJdbcParameter() != null) {
buffer.append(fetch.getFetchJdbcParameter().toString());
} else {
buffer.append(fetch.getRowCount());
}
fetch.getExpression().accept(expressionVisitor);
buffer.append(" ").append(fetch.getFetchParam()).append(" ONLY");

}
Expand Down Expand Up @@ -490,10 +486,10 @@ public void visit(SetOperationList list) {
new LimitDeparser(buffer).deParse(list.getLimit());
}
if (list.getOffset() != null) {
deparseOffset(list.getOffset());
visit(list.getOffset());
}
if (list.getFetch() != null) {
deparseFetch(list.getFetch());
visit(list.getFetch());
}
if (list.getWithIsolation() != null) {
buffer.append(list.getWithIsolation().toString());
Expand Down
16 changes: 6 additions & 10 deletions src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -3079,19 +3079,15 @@ Fetch Fetch():
{
Fetch fetch = new Fetch();
Token token = null;
JdbcParameter jdbc;
Expression expression;
}
{
(
// sqlserver-oracle-> FETCH (FIRST | NEXT) row_count (ROW | ROWS) ONLY
<K_FETCH>
(<K_FIRST> { fetch.setFetchParamFirst(true); } | <K_NEXT>)
(token=<S_LONG> { fetch.setRowCount(Long.parseLong(token.image)); }
| jdbc = SimpleJdbcParameter() { fetch.setFetchJdbcParameter(jdbc); } ) /* "?" { fetch.setFetchJdbcParameter(true); } ) */
(<K_ROWS> { fetch.setFetchParam("ROWS"); } | <K_ROW>)
<K_ONLY>

)
// sqlserver-oracle-> FETCH (FIRST | NEXT) expression (ROW | ROWS) ONLY
<K_FETCH> (<K_FIRST> { fetch.setFetchParamFirst(true); } | <K_NEXT>)
expression = Expression() { fetch.setExpression(expression); }
(<K_ROWS> { fetch.setFetchParam("ROWS"); } | <K_ROW>) <K_ONLY>
)
{
return fetch;
}
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/net/sf/jsqlparser/statement/select/FetchTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.sf.jsqlparser.statement.select;

import net.sf.jsqlparser.*;
import net.sf.jsqlparser.statement.*;
import net.sf.jsqlparser.test.*;
import org.junit.jupiter.api.*;

class FetchTest {
@Test
void testParser() throws JSQLParserException {
String sqlStr = "SELECT table_schema \n" +
"FROM information_schema.tables \n" +
"fetch next :variable rows only";
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true);
}

@Test
void getExpression() throws JSQLParserException {
String sqlStr = "SELECT table_schema \n" +
"FROM information_schema.tables \n" +
"fetch next (SELECT 1 FROM DUAL) rows only";
Select select = (Select) TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true);
PlainSelect plainSelect = (PlainSelect) select.getSelectBody();
Fetch fetch = plainSelect.getFetch();
Assertions.assertInstanceOf( SubSelect.class, fetch.getExpression());
}
}