Skip to content

Commit

Permalink
Merge origin/master
Browse files Browse the repository at this point in the history
  • Loading branch information
wumpz committed Aug 30, 2023
2 parents 39ec3c8 + 994e6c6 commit ce21e8a
Show file tree
Hide file tree
Showing 231 changed files with 12,279 additions and 9,492 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/sql-parser-error.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ assignees: ''

---

Always check against the **Latest SNAPSHOT of JSQLParser** and the [Syntax Diagram](https://jsqlparser.github.io/JSqlParser/syntax.html)
Always check against the **Latest SNAPSHOT of JSQLParser** and the [Syntax Diagram](https://jsqlparser.github.io/JSqlParser/syntax_snapshot.html)

### Failing SQL Feature:
- Brief description of the failing SQL feature
Expand All @@ -27,5 +27,5 @@ Always check against the **Latest SNAPSHOT of JSQLParser** and the [Syntax Diagr

### Tips:
Please write in English and avoid Screenshots (as we can't copy and paste content from it).
[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.
[Try your example online with the latest JSQLParser](http://jsqlformatter.manticore-projects.com) and share the link in the error report.
Do provide Links or References to the specific Grammar and Syntax you are trying to use.
38 changes: 38 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: build check
# arguments: build check publish
env:
ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
ossrhPassword: ${{ secrets.OSSRH_TOKEN }}
11 changes: 8 additions & 3 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Sphinx Pages
on: [push, workflow_dispatch]
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions: write-all
jobs:
docs:
Expand All @@ -9,7 +14,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 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 All @@ -18,7 +23,7 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Run build with Gradle Wrapper
run: gradle sphinx
run: gradle --no-build-cache clean xmldoc sphinx
- name: Deploy
uses: actions/configure-pages@v2
- name: Upload artifact
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

# Exclude the Auto-generated Changelog
/src/site/sphinx/changelog.rst
/src/site/sphinx/javadoc_stable.rst
/src/site/sphinx/syntax_stable.rst

# Generated by javacc-maven-plugin
/bin
Expand All @@ -27,3 +29,5 @@
/nbproject/

/.gradle
/src/site/sphinx/javadoc_snapshot.rst
/src/site/sphinx/syntax_snapshot.rst
41 changes: 23 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,35 @@ SELECT 1 FROM dual WHERE a = b
```

```text
SQL Text
└─Statements: net.sf.jsqlparser.statement.select.PlainSelect
├─selectItems -> Collection<SelectExpressionItem>
│ └─selectItems: net.sf.jsqlparser.statement.select.SelectExpressionItem
│ └─LongValue: 1
├─Table: dual
└─where: net.sf.jsqlparser.expression.operators.relational.EqualsTo
├─Column: a
└─Column: b
SQL Text
└─Statements: statement.select.PlainSelect
├─selectItems: statement.select.SelectItem
│ └─LongValue: 1
├─Table: dual
└─where: expression.operators.relational.EqualsTo
├─Column: a
└─Column: b
```

```java
Statement statement = CCJSqlParserUtil.parse(sqlStr);
if (statement instanceof PlainSelect) {
PlainSelect plainSelect = (PlainSelect) statement;
String sqlStr = "select 1 from dual where a=b";

SelectExpressionItem selectExpressionItem =
(SelectExpressionItem) plainSelect.getSelectItems().get(0);
PlainSelect select = (PlainSelect) CCJSqlParserUtil.parse(sqlStr);

Table table = (Table) plainSelect.getFromItem();
SelectItem selectItem =
select.getSelectItems().get(0);
Assertions.assertEquals(
new LongValue(1)
, selectItem.getExpression());

EqualsTo equalsTo = (EqualsTo) plainSelect.getWhere();
Column a = (Column) equalsTo.getLeftExpression();
Column b = (Column) equalsTo.getRightExpression();
Table table = (Table) select.getFromItem();
Assertions.assertEquals("dual", table.getName());

EqualsTo equalsTo = (EqualsTo) select.getWhere();
Column a = (Column) equalsTo.getLeftExpression();
Column b = (Column) equalsTo.getRightExpression();
Assertions.assertEquals("a", a.getColumnName());
Assertions.assertEquals("b", b.getColumnName());
}
```

Expand Down
Loading

0 comments on commit ce21e8a

Please sign in to comment.