Skip to content

Commit e71e57d

Browse files
Oracle Alternative Quoting (#1722)
* Fixes #1684: Support CREATE MATERIALIZED VIEW with AUTO REFRESH Support parsing create view statements in Redshift with AUTO REFRESH option. * Reduce cyclomatic complexity in CreateView.toString Extract adding the force option into a dedicated method resulting in the cyclomatic complexity reduction of the CreateView.toString method. * Enhanced Keywords Add Keywords and document, which keywords are allowed for what purpose * Fix incorrect tests * Define Reserved Keywords explicitly Derive All Keywords from Grammar directly Generate production for Object Names (semi-) automatically Add parametrized Keyword Tests * Fix test resources * Adjust Gradle to JUnit 5 Parallel Test execution Gradle Caching Explicitly request for latest JavaCC 7.0.10 * Do not mark SpeedTest for concurrent execution * Remove unused imports * Adjust Gradle to JUnit 5 Parallel Test execution Gradle Caching Explicitly request for latest JavaCC 7.0.10 * Do not mark SpeedTest for concurrent execution * Remove unused imports * Sphinx Documentation Update the MANTICORE Sphinx Theme, but ignore it in GIT Add the content to the Sphinx sites Add a Gradle function to derive Stable and Snapshot version from GIT Tags Add a Gradle GIT change task Add a Gradle sphinx task Add a special Test case for illustrating the use of JSQLParser * doc: request for `Conventional Commit` messages * feat: make important Classes Serializable Implement Serializable for persisting via ObjectOutputStream * chore: Make Serializable * doc: Better integration of the RR diagrams - apply neutral Sphinx theme - insert the RR diagrams into the sphinx sources - better documentation on Gradle dependencies - link GitHub repository * Merge * feat: Oracle Alternative Quoting - add support for Oracle Alternative Quoting e.g. `q'(...)'` - fixes #1718 - add a Logo and FavIcon to the Website - document recent changes on Quoting/Escaping - add an example on building SQL from Java - rework the README.md, promote the Website - add Spotless Formatter, using Google Java Style (with Tab=4 Spaces) * style: Appease PMD/Codacy * doc: fix the issue template - fix the issue template - fix the -SNAPSHOT version number * Update issue templates * Update issue templates * feat: Support more Statement Separators - `GO` - Slash `/` - Two empty lines --------- Co-authored-by: zaza <tzarna@gmail.com>
1 parent 2ced7de commit e71e57d

File tree

26 files changed

+5739
-2340
lines changed

26 files changed

+5739
-2340
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,41 @@
11
---
2-
name: SQL Parser Error
2+
name: @ SQL Parser Error
33
about: Create a report to help us improve
4-
title: 'JSQLParser Version : RDBMS : failing feature description'
4+
title: '[BUG] JSQLParser Version : RDBMS : failing feature description'
55
labels: 'Parser Error', 'Feature Request', 'Documentation', 'Java API', 'RDBMS support'
66
assignees: ''
77

88
---
99

10-
**Failing SQL Feature**
10+
<!--
11+
Note: Please search to see if an issue already exists for the bug you encountered.
12+
-->
13+
14+
### Failing SQL Feature:
15+
<!--
1116
- Brief description of the failing SQL feature
1217
- Example: `WITH ROLLUP` can't be parsed
18+
-->
1319

14-
**SQL Example**
20+
### SQL Example:
21+
<!--
1522
- Simplified Query Example, focusing on the failing feature
1623
```sql
1724
-- Replace with your ACTUAL example
1825
select 1
1926
from dual
2027
```
28+
-->
2129

22-
**Software Information**
30+
### Software Information:
31+
<!--
2332
- JSqlParser version
2433
- Database (e. g. Oracle, MS SQL Server, H2, PostgreSQL, IBM DB2 )
34+
-->
2535

26-
**Tips**
36+
### Tips:
37+
<!--
2738
Please write in English and avoid Screenshots (as we can't copy and paste content from it).
2839
[Try your example online with the latest JSQLParser](http://217.160.215.75:8080/jsqlformatter/demo.html) and share the link in the error report.
40+
Do provide Links or References to the specific Grammar and Syntax you are trying to use.
41+
-->
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: Feature request
3+
about: Suggest an unsupported Statement or Expression
4+
title: "[FEATURE] missing feature description"
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
### Grammar or Syntax Description
11+
- Brief description of the failing SQL feature and the EBNF
12+
- Example: `WITH ROLLUP` clause is not supported yet
13+
14+
### SQL Example
15+
- Simplified Query Example, focusing on the failing feature
16+
```sql
17+
-- Replace with your ACTUAL example
18+
select 1
19+
from dual
20+
```
21+
- Please don't send screen shots
22+
23+
### Additional context
24+
The used JSQLParser Version (please test the latest SNAPSHOT version before submitting).
25+
State the applicable RDBMS and version
26+
Links to the reference documentation
27+
28+
### Tips:
29+
<!--
30+
Please write in English and avoid Screenshots (as we can't copy and paste content from it).
31+
-->
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: SQL Parser Error
3+
about: Report a Parser Error
4+
title: "[BUG] JSQLParser Version : RDBMS : failing feature description"
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
Always check against the **Latest SNAPSHOT of JSQLParser** and the [Syntax Diagram](https://jsqlparser.github.io/JSqlParser/syntax.html)
11+
12+
### Failing SQL Feature:
13+
- Brief description of the failing SQL feature
14+
- Example: `WITH ROLLUP` can't be parsed
15+
16+
### SQL Example:
17+
- Simplified Query Example, focusing on the failing feature
18+
```sql
19+
-- Replace with your ACTUAL example
20+
select 1
21+
from dual
22+
```
23+
24+
### Software Information:
25+
- JSqlParser version
26+
- Database (e. g. Oracle, MS SQL Server, H2, PostgreSQL, IBM DB2 )
27+
28+
### Tips:
29+
Please write in English and avoid Screenshots (as we can't copy and paste content from it).
30+
[Try your example online with the latest JSQLParser](http://217.160.215.75:8080/jsqlformatter/demo.html) and share the link in the error report.
31+
Do provide Links or References to the specific Grammar and Syntax you are trying to use.

README.md

Lines changed: 44 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# JSqlParser
1+
# [JSqlParser (4.5 Stable or 4.6 Snapshot)](https://jsqlparser.github.io/JSqlParser) <img src="src/site/sphinx/_images/logo-no-background.svg" alt="drawing" width="200" align="right"/>
22

33
![Build Status](https://github.com/JSQLParser/JSqlParser/actions/workflows/maven.yml/badge.svg)
44

@@ -9,127 +9,63 @@
99

1010
[![Gitter](https://badges.gitter.im/JSQLParser/JSqlParser.svg)](https://gitter.im/JSQLParser/JSqlParser?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
1111

12-
Look here for more information and examples: https://github.com/JSQLParser/JSqlParser/wiki.
13-
14-
## License
15-
16-
JSqlParser is dual licensed under **LGPL V2.1** or **Apache Software License, Version 2.0**.
17-
18-
## Discussion
19-
20-
Please provide feedback on:
21-
22-
* API changes: extend visitor with return values (https://github.com/JSQLParser/JSqlParser/issues/901)
23-
24-
## News
25-
* Released version **4.5** of JSqlParser
26-
* The array parsing is the default behaviour. Square bracket quotation has to be enabled using
27-
a parser flag (**CCJSqlParser.withSquareBracketQuotation**).
28-
* due to an API change the version will be 3.0
29-
* JSqlParser uses now Java 8 at the minimum
30-
31-
More news can be found here: https://github.com/JSQLParser/JSqlParser/wiki/News.
32-
33-
## Alternatives to JSqlParser?
34-
[**General SQL Parser**](http://www.sqlparser.com/features/introduce.php?utm_source=github-jsqlparser&utm_medium=text-general) looks pretty good, with extended SQL syntax (like PL/SQL and T-SQL) and java + .NET APIs. The tool is commercial (license available online), with a free download option.
35-
36-
## JSqlParser
37-
38-
JSqlParser is a SQL statement parser. It translates SQLs in a traversable hierarchy of Java classes. JSqlParser is not limited to one database but provides support for a lot of specials of Oracle, SqlServer, MySQL, PostgreSQL ... To name some, it has support for Oracles join syntax using (+), PostgreSQLs cast syntax using ::, relational operators like != and so on.
39-
40-
## Support
41-
If you need help using JSqlParser feel free to file an issue or contact me.
42-
43-
## Contributions
44-
To help JSqlParser's development you are encouraged to provide
45-
* feedback
46-
* bugreports
47-
* pull requests for new features
48-
* improvement requests
49-
* fund new features or sponsor JSqlParser ([**Sponsor**](https://www.paypal.me/wumpz))
50-
51-
**Please write in English, since it's the language most of the dev team knows.**
12+
## Summary
5213

53-
Any requests for examples or any particular documentation will be most welcome.
14+
Please visit the [WebSite](https://jsqlparser.github.io/JSqlParser). **JSqlParser** is a RDBMS agnostic SQL statement parser. It translates SQL statements into a traversable hierarchy of Java classes (see [Samples](https://jsqlparser.github.io/JSqlParser/usage.html#parse-a-sql-statements)):
5415

55-
## Extensions in the latest SNAPSHOT version 4.6
56-
57-
* support for named windows in window expressions: `SELECT sum(c) OVER winName FROM mytable WINDOW winName AS (PARTITION BY pcol)`
16+
```sql
17+
SELECT 1 FROM dual WHERE a = b
18+
```
5819

59-
Additionally, we have fixed many errors and improved the code quality and the test coverage.
20+
```text
21+
SQL Text
22+
└─Statements: net.sf.jsqlparser.statement.select.Select
23+
└─selectBody: net.sf.jsqlparser.statement.select.PlainSelect
24+
├─selectItems -> Collection<SelectExpressionItem>
25+
│ └─selectItems: net.sf.jsqlparser.statement.select.SelectExpressionItem
26+
│ └─LongValue: 1
27+
├─Table: dual
28+
└─where: net.sf.jsqlparser.expression.operators.relational.EqualsTo
29+
├─Column: a
30+
└─Column: b
31+
```
6032

61-
## Extensions of JSqlParser releases
33+
```java
34+
Statement statement = CCJSqlParserUtil.parse(sqlStr);
35+
if (statement instanceof Select) {
36+
Select select = (Select) statement;
37+
PlainSelect plainSelect = (PlainSelect) select.getSelectBody();
6238

63-
* [Release Notes](https://github.com/JSQLParser/JSqlParser/releases)
64-
* Modifications before GitHub's release tagging are listed in the [Older Releases](https://github.com/JSQLParser/JSqlParser/wiki/Older-Releases) page.
39+
SelectExpressionItem selectExpressionItem =
40+
(SelectExpressionItem) plainSelect.getSelectItems().get(0);
6541

66-
## Building from the sources
42+
Table table = (Table) plainSelect.getFromItem();
6743

68-
As the project is a Maven project, building is rather simple by running:
69-
```shell
70-
mvn package
44+
EqualsTo equalsTo = (EqualsTo) plainSelect.getWhere();
45+
Column a = (Column) equalsTo.getLeftExpression();
46+
Column b = (Column) equalsTo.getRightExpression();
47+
}
7148
```
7249

73-
Since 4.2, alternatively Gradle can be used
74-
```shell
75-
gradle build
76-
```
77-
78-
The project requires the following to build:
79-
- Maven (or Gradle)
80-
- JDK 8 or later. The JAR will target JDK 8, but the version of the maven-compiler-plugin that JSqlParser uses requires JDK 8+
50+
## [Supported Grammar and Syntax](https://jsqlparser.github.io/JSqlParser/syntax.html)
8151

82-
This will produce the jsqlparser-VERSION.jar file in the `target/` directory (`build/libs/jsqlparser-VERSION.jar` in case of Gradle).
52+
**JSqlParser** aims to support the SQL standard as well as all major RDBMS. Any missing syntax or features can be added on demand.
8353

84-
**To build this project without using Maven or Gradle, one has to build the parser by JavaCC using the CLI options it provides.**
54+
| RDBMS | Statements |
55+
|------------------------------------|-----------------------------------------|
56+
| Oracle<br>MS SQL Server and Sybase<br>PostgreSQL<br>MySQL and MariaDB<br>DB2<br>H2 and HSQLDB and Derby<br>SQLite| `SELECT`<br>`INSERT`, `UPDATE`, `UPSERT`, `MERGE`<br>`DELETE`, `TRUNCATE TABLE`<br>`CREATE ...`, `ALTER ....`, `DROP ...`<br>`WITH ...` |
8557

86-
## Debugging through problems
8758

88-
Refer to the [Visualize Parsing](https://github.com/JSQLParser/JSqlParser/wiki/Examples-of-SQL-parsing#visualize-parsing) section to learn how to run the parser in debug mode.
59+
**JSqlParser** can also be used to create SQL Statements from Java Code with a fluent API (see [Samples](https://jsqlparser.github.io/JSqlParser/usage.html#build-a-sql-statements)).
8960

90-
## Source Code conventions
61+
## [Documentation](https://jsqlparser.github.io/JSqlParser)
9162

92-
Recently a checkstyle process was integrated into the build process. JSqlParser follows the sun java format convention. There are no TABs allowed. Use spaces.
63+
### [Samples](https://jsqlparser.github.io/JSqlParser/usage.html#parse-a-sql-statements)
64+
### [Build Instructions](https://jsqlparser.github.io/JSqlParser/usage.html)
65+
### [Contribution](https://jsqlparser.github.io/JSqlParser/contribution.html)
66+
### [Change Log](https://jsqlparser.github.io/JSqlParser/changelog.html#latest-changes-since-jsqlparser-version)
67+
### [Issues](https://github.com/JSQLParser/JSqlParser/issues)
9368

94-
```java
95-
public void setUsingSelect(SubSelect usingSelect) {
96-
this.usingSelect = usingSelect;
97-
if (this.usingSelect != null) {
98-
this.usingSelect.setUseBrackets(false);
99-
}
100-
}
101-
```
102-
103-
This is a valid piece of source code:
104-
* blocks without braces are not allowed
105-
* after control statements (if, while, for) a whitespace is expected
106-
* the opening brace should be in the same line as the control statement
107-
108-
## Maven Repository
109-
110-
JSQLParser is deployed at Sonatype open source maven repository.
111-
Starting from now I will deploy there. The first snapshot version there will be 0.8.5-SNAPSHOT.
112-
To use it this is the repository configuration:
113-
114-
```xml
115-
<repositories>
116-
<repository>
117-
<id>jsqlparser-snapshots</id>
118-
<snapshots>
119-
<enabled>true</enabled>
120-
</snapshots>
121-
<url>https://oss.sonatype.org/content/groups/public/</url>
122-
</repository>
123-
</repositories>
124-
```
125-
These repository releases will be synchronised to Maven Central. Snapshots remain at Sonatype.
126-
127-
And this is the dependency declaration in your pom:
128-
```xml
129-
<dependency>
130-
<groupId>com.github.jsqlparser</groupId>
131-
<artifactId>jsqlparser</artifactId>
132-
<version>4.5</version>
133-
</dependency>
134-
```
69+
## License
13570

71+
**JSqlParser** is dual licensed under **LGPL V2.1** or **Apache Software License, Version 2.0**.

0 commit comments

Comments
 (0)