diff --git a/.codacy.yml b/.codacy.yml new file mode 100644 index 0000000000..cf0315d765 --- /dev/null +++ b/.codacy.yml @@ -0,0 +1,11 @@ +--- +engines: + tsqllint: + exclude_paths: + # These fixtures use PostgreSQL grammar, not Transact-SQL. + - "src/test/resources/postgresql/**" + # MATCH_RECOGNIZE fixtures use Oracle and BigQuery grammar. + - "src/test/resources/net/sf/jsqlparser/statement/select/match-recognize/**" + - "src/test/resources/net/sf/jsqlparser/statement/select/match-recognize-2350.sql" +exclude_paths: + - "site/**" diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000000..5926aa29f4 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: https://paypal.me/wumpz diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000000..e79696ec8b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,41 @@ +--- +name: @ SQL Parser Error +about: Create a report to help us improve +title: '[BUG] JSQLParser Version : RDBMS : failing feature description' +labels: 'Parser Error', 'Feature Request', 'Documentation', 'Java API', 'RDBMS support' +assignees: '' + +--- + + + +### Failing SQL Feature: + + +### SQL Example: + + +### Software Information: + + +### Tips: + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000000..9003b51e15 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,31 @@ +--- +name: Feature request +about: Suggest an unsupported Statement or Expression +title: "[FEATURE] missing feature description" +labels: '' +assignees: '' + +--- + +### Grammar or Syntax Description +- Brief description of the failing SQL feature and the EBNF +- Example: `WITH ROLLUP` clause is not supported yet + +### SQL Example +- Simplified Query Example, focusing on the failing feature + ```sql + -- Replace with your ACTUAL example + select 1 + from dual + ``` +- Please don't send screen shots + +### Additional context +The used JSQLParser Version (please test the latest SNAPSHOT version before submitting). +State the applicable RDBMS and version +Links to the reference documentation + +### Tips: + diff --git a/.github/ISSUE_TEMPLATE/sql-parser-error.md b/.github/ISSUE_TEMPLATE/sql-parser-error.md new file mode 100644 index 0000000000..2a5eaf28f1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/sql-parser-error.md @@ -0,0 +1,31 @@ +--- +name: SQL Parser Error +about: Report a Parser Error +title: "[BUG] JSQLParser Version : RDBMS : failing feature description" +labels: '' +assignees: '' + +--- + +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 +- Example: `WITH ROLLUP` can't be parsed + +### SQL Example: +- Simplified Query Example, focusing on the failing feature + ```sql + -- Replace with your ACTUAL example + select 1 + from dual + ``` + +### Software Information: +- JSqlParser version +- Database (e. g. Oracle, MS SQL Server, H2, PostgreSQL, IBM DB2 ) + +### 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://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. diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000000..b9134ea9a2 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,8 @@ +changelog: + categories: + - title: Bugs solved + labels: + - "bug" + - title: Changes and new Features + labels: + - "*" \ No newline at end of file diff --git a/.github/requirements-docs.txt b/.github/requirements-docs.txt new file mode 100644 index 0000000000..9130aea185 --- /dev/null +++ b/.github/requirements-docs.txt @@ -0,0 +1,14 @@ +# Python dependencies for the Sphinx documentation build (.github/workflows/ci.yml). +# Kept in the repository so actions/setup-python can key its pip cache on it. +# +# Deliberately NOT installed from apt: sphinx-common pulls python3-pil / python3-docutils +# from the runner's stale apt index and shadows this install on PATH. + +sphinx>=7,<9 +manticore_sphinx_theme +sphinx_javadoc_xml +myst_parser +sphinx_substitution_extensions +sphinx_issues +sphinx_inline_tabs +pygments diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..569d885551 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,219 @@ +name: CI Pipeline + +on: + push: + branches: [ "**" ] + pull_request: + branches: [ "**" ] + workflow_dispatch: + +# Least privilege by default; each job widens only what it needs. +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +env: + JAVA_VERSION: '17' + JAVA_DISTRIBUTION: 'temurin' + +jobs: + grammar_conflicts: + name: Grammar Choice Conflicts + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Set up JDK ${{ env.JAVA_VERSION }} + uses: actions/setup-java@v5 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + with: + cache-read-only: ${{ github.ref != 'refs/heads/master' }} + + # Re-runs JavaCC on the JJTree output and fails on any "Warning: Choice conflict ...". + # `check` already depends on this task, but a dedicated job gives a fast, separately + # named status check that can be made required in branch protection. + - name: Check for grammar ambiguities + run: ./gradlew checkGrammarAmbiguity --no-daemon + + - name: Upload grammar warning report + if: failure() + uses: actions/upload-artifact@v5 + with: + name: javacc-warnings + path: build/reports/grammar/ + retention-days: 7 + if-no-files-found: ignore + + gradle_check: + name: Gradle Check (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, windows-latest, macos-latest ] + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 # required by the git-changelog / version derivation + + - name: Set up JDK ${{ env.JAVA_VERSION }} + uses: actions/setup-java@v5 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + with: + cache-read-only: ${{ github.ref != 'refs/heads/master' }} + + - name: Run Gradle Check + run: ./gradlew check --no-daemon + + - name: Upload test reports + if: always() + uses: actions/upload-artifact@v5 + with: + name: test-reports-${{ matrix.os }} + path: | + build/reports/ + build/test-results/ + retention-days: 7 + if-no-files-found: ignore + + maven_verify: + name: Maven Verify (${{ matrix.os }}) + needs: gradle_check + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, windows-latest, macos-latest ] + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Set up JDK ${{ env.JAVA_VERSION }} + uses: actions/setup-java@v5 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + cache: 'maven' + + - name: Run Maven Verify + run: mvn --batch-mode --no-transfer-progress verify + + gradle_publish: + name: Gradle Publish (Maven Central) + needs: [ gradle_check, maven_verify ] + if: github.ref == 'refs/heads/master' && github.repository == 'JSQLParser/JSqlParser' + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Set up JDK ${{ env.JAVA_VERSION }} + uses: actions/setup-java@v5 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Publish with Gradle + # Gradle only picks up a secret as a project property when it is exported with the + # ORG_GRADLE_PROJECT_ prefix. Plain `ossrhUsername: ...` was an ordinary environment + # variable that nothing ever read. + # + # No RELEASE variable here on purpose: getVersion() then produces a -SNAPSHOT version and + # the plugin routes it to the Central Portal snapshot repository. Set RELEASE=true only + # when you actually intend to cut a release. + run: ./gradlew publishToMavenCentral --no-daemon + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.mavenCentralUsername }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.mavenCentralPassword }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.signingInMemoryKey }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.signingInMemoryKeyId }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.signingInMemoryKeyPassword }} + + deploy_docs: + name: Build & Deploy Sphinx Docs + needs: [ gradle_check, maven_verify ] + if: github.ref == 'refs/heads/master' && github.repository == 'JSQLParser/JSqlParser' + runs-on: ubuntu-latest + permissions: + contents: read + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 # gitChangelogTask needs full history + + - name: Set up JDK ${{ env.JAVA_VERSION }} + uses: actions/setup-java@v5 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + # cache: 'pip' needs a dependency file to key on. setup-python only looks for + # **/requirements.txt or **/pyproject.toml by default, neither of which exists in this + # repo — hence "No file ... matched". cache-dependency-path points it at the file we keep. + - uses: actions/setup-python@v6 + with: + python-version: '3.12' + cache: 'pip' + cache-dependency-path: '.github/requirements-docs.txt' + + # Only xsltproc comes from apt. `sphinx-common` used to be installed here as well; it + # pulled in python3-sphinx / python3-docutils / python3-pil from the runner's stale apt + # index (hence the 404 on python3-pil 10.2.0-1ubuntu1.2) and shadowed the pip-installed + # Sphinx that actually knows about manticore_sphinx_theme. `apt-get update` first, because + # the pre-baked index on the runner image is regularly older than the mirror. + - name: Install XSLT processor + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends xsltproc + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r .github/requirements-docs.txt + + - name: Build Sphinx documentation with Gradle + env: + FLOATING_TOC: 'false' + run: ./gradlew -DFLOATING_TOC=false --no-daemon gitChangelogTask renderRR xslt xmldoc sphinx + + - name: Configure GitHub Pages + uses: actions/configure-pages@v5 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v5 + with: + path: 'build/sphinx' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v5 \ No newline at end of file diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 index a42f8c90f0..bab2fa1408 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,17 @@ # Generated by maven /target +/build +/out + +# Sphinx Theme related stuff, which shall be downloaded separately +/src/site/sphinx/_themes + +# Exclude the Auto-generated Changelog +src/site/sphinx/changelog.rst +src/site/sphinx/syntax_stable.rst +src/site/sphinx/syntax_snapshot.rst +src/site/sphinx/javadoc_stable.xml +src/site/sphinx/javadoc_snapshot.xml # Generated by javacc-maven-plugin /bin @@ -15,4 +27,11 @@ *.iml *.jj~ -*.*~ +*.java~ +*.yml~ +/nbproject/ + +/.gradle + +# Mac +.DS_Store diff --git a/.mvn/jvm.config b/.mvn/jvm.config new file mode 100644 index 0000000000..7fecadb38e --- /dev/null +++ b/.mvn/jvm.config @@ -0,0 +1 @@ +-Dfile.encoding=UTF-8 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..581903065b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +language: java +jdk: + - openjdk8 + - openjdk11 + +after_success: + - mvn clean cobertura:cobertura coveralls:report + +cache: + directories: + - $HOME/.m2 + - $HOME/.gradle/caches/ + - $HOME/.gradle/wrapper/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000..4d354ae2ac --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12014 @@ +# JSqlParser changelog + +Changelog of JSqlParser. + +## jsqlparser-5.4 (2026-09-13) + +### Features + +- parse SQL large-object type names through shared column types (#2617) ([ed6c4](https://github.com/JSQLParser/JSqlParser/commit/ed6c499277b4343) Minjae Lee) +- preserve column default expressions in table definitions (#2616) ([2aa0d](https://github.com/JSQLParser/JSqlParser/commit/2aa0d8dab6e04ee) Minjae Lee) +- reuse table constraint grammar for PostgreSQL ALTER ADD (#2612) ([e4cf3](https://github.com/JSQLParser/JSqlParser/commit/e4cf31654c4b0e6) Minjae Lee) +- preserve ALTER COLUMN default expressions in the AST (#2611) ([08de1](https://github.com/JSQLParser/JSqlParser/commit/08de14159c1f775) Minjae Lee) +- **parser** support opt-in legacy MySQL GROUP BY ordering (#2595) ([7cc86](https://github.com/JSQLParser/JSqlParser/commit/7cc863863170c79) Minjae Lee) +- **parser** model PostgreSQL type domain and extension DDL (#2553) ([7e15a](https://github.com/JSQLParser/JSqlParser/commit/7e15aaedfb06558) Minjae Lee) +- **parser** model PostgreSQL schema DDL clauses (#2552) ([7b9d4](https://github.com/JSQLParser/JSqlParser/commit/7b9d4208d5e42ad) Minjae Lee) +- **parser** parse navigation chains after array subscripts (#2550) ([54a74](https://github.com/JSQLParser/JSqlParser/commit/54a7499579c6bbf) fudian) +- **statement** add StmtFeature classification via Statement#getFeatures() ([22023](https://github.com/JSQLParser/JSqlParser/commit/22023a48404140e) Andreas Reichel) +- **parser** enhance PostgreSQL CREATE POLICY support (#2549) ([ff2bc](https://github.com/JSQLParser/JSqlParser/commit/ff2bc8d29a00a8c) Minjae Lee) +- **parser** model MySQL CREATE TRIGGER (#2548) ([03b8f](https://github.com/JSQLParser/JSqlParser/commit/03b8fc407b32ca3) Minjae Lee) +- **parser** model MySQL event statements (#2547) ([b67a5](https://github.com/JSQLParser/JSqlParser/commit/b67a52d0f5e4531) Minjae Lee) +- **parser** model MySQL CREATE USER (#2546) ([628e3](https://github.com/JSQLParser/JSqlParser/commit/628e3c1d08fd62c) Minjae Lee) +- **parser** model MySQL schema options (#2544) ([897fb](https://github.com/JSQLParser/JSqlParser/commit/897fbd4c6549e3b) Minjae Lee) +- **parser** model ColDataType precision and scale as structured properties (#2539) ([c919a](https://github.com/JSQLParser/JSqlParser/commit/c919a0c9b316c8d) Minjae Lee) +- **parser** add column data type fragment parser (#2531) ([6413a](https://github.com/JSQLParser/JSqlParser/commit/6413a84724cc309) Minjae Lee) +- **parser** add BIGQUERY, DATABRICKS and SNOWFLAKE dialect presets (#2515) ([e7167](https://github.com/JSQLParser/JSqlParser/commit/e7167cc7dc15ce5) fudian) +- **parser** concatenate adjacent string literals behind adjacentStringLiterals (#2514) ([84d23](https://github.com/JSQLParser/JSqlParser/commit/84d23e7dfae5ac8) fudian) +- **parser** support double quoted string literals behind allowDoubleQuotedStrings (#2513) ([c86cf](https://github.com/JSQLParser/JSqlParser/commit/c86cf6ad2ce210b) fudian) +- **parser** turn on the dialect's lexer feature preset in withDialect (#2511) ([94c45](https://github.com/JSQLParser/JSqlParser/commit/94c4508bd381912) fudian) +- **parser** support MySQL # line comments behind allowHashLineComments (#2508) ([177db](https://github.com/JSQLParser/JSqlParser/commit/177dbd716f0a3c3) fudian) +- **parser** support DuckDB MAP literals and PIVOT queries (#2496) ([e1301](https://github.com/JSQLParser/JSqlParser/commit/e13019a393d9229) Liming Deng) +- **parser** support MySQL PROCEDURE ANALYSE clause (#2492) ([98bd0](https://github.com/JSQLParser/JSqlParser/commit/98bd01de38de073) Liming Deng) +- parse BigQuery JSON string literals as implicit casts (#2488) ([15e58](https://github.com/JSQLParser/JSqlParser/commit/15e58e92e1a9692) Hayssam Saleh) +- complete SQL Server OPTION query hint support (#2486) ([4c6a4](https://github.com/JSQLParser/JSqlParser/commit/4c6a4fb141db7db) fudian) +- **parser** add support for ClickHouse [LEFT] ARRAY JOIN syntax (#2482) ([5c868](https://github.com/JSQLParser/JSqlParser/commit/5c86877dfa8f3d3) Watashi00) +- support CREATE DATABASE statement (#2070) (#2471) ([7b648](https://github.com/JSQLParser/JSqlParser/commit/7b648250618299e) fudian) +- support SQL Server OPTION query hints (#161) (#2472) ([13894](https://github.com/JSQLParser/JSqlParser/commit/138947d6b1d0d28) fudian) +- add support for the XMLTABLE table function (#2458) ([d51ee](https://github.com/JSQLParser/JSqlParser/commit/d51ee1c166055d3) fudian) +- support MERGE ... WHEN NOT MATCHED BY TARGET / BY SOURCE (#2421) (#2453) ([25f30](https://github.com/JSQLParser/JSqlParser/commit/25f3040e3938fb3) fudian) +- add ForUpdateClause class with multi-table and ORDER BY support (#2426) ([2b141](https://github.com/JSQLParser/JSqlParser/commit/2b141568e8b76ed) Rogerio Robetti) +- Add bytecode size verification tests for generated parser classes ([9cfbe](https://github.com/JSQLParser/JSqlParser/commit/9cfbe681e36e638) manticore-projects) +- Optimize SimpleCharStream for SQL parsing hot path ([17448](https://github.com/JSQLParser/JSqlParser/commit/17448bb074e6371) manticore-projects) +- PRATT 7.1 ms/ops, no errors ([2d2ee](https://github.com/JSQLParser/JSqlParser/commit/2d2ee4b569e45df) manticore-projects) +- Pratt 8.5 ms/ops without failures ([36507](https://github.com/JSQLParser/JSqlParser/commit/365078db38dfa14) manticore-projects) +- Pratt 6.5 ms/ops with 14 failures ([53ca0](https://github.com/JSQLParser/JSqlParser/commit/53ca03861bb93b2) manticore-projects) +- rework tokens and preserved keywords ([08d0b](https://github.com/JSQLParser/JSqlParser/commit/08d0bcc9cb0efdf) manticore-projects) +- Allow more Function keyword arguments ([cd71a](https://github.com/JSQLParser/JSqlParser/commit/cd71aada3897745) manticore-projects) +- Fix GROUP_CONCAT SEPARATOR to accept expressions, not just string literals ([ff28f](https://github.com/JSQLParser/JSqlParser/commit/ff28f826bcf89c3) manticore-projects) +- support PostgreSQL 18 RETURNING OLD/NEW (#2398) ([f47a8](https://github.com/JSQLParser/JSqlParser/commit/f47a8b30b303e76) Liming Deng) +- support EXPLAIN for DML and simplify ExplainStatement (#2396) ([b19d5](https://github.com/JSQLParser/JSqlParser/commit/b19d556eb57f701) Liming Deng) +- add support for Oracle INSERT ALL/FIRST with WHEN branches (#2394) ([4f982](https://github.com/JSQLParser/JSqlParser/commit/4f982e74aee7f12) Liming Deng) +- add PostgreSQL Row Level Security (RLS) support (#2345) ([999cd](https://github.com/JSQLParser/JSqlParser/commit/999cdca2ac1be89) Eyal Gehasie) +- `DateUnitExpression` for parsing `HOUR`, `DAY`, `MONTH` etc. in Date Functions not as column ([4fdfa](https://github.com/JSQLParser/JSqlParser/commit/4fdfa785dcfd2d5) Andreas Reichel) +- normalised backtick quotes ([c60ff](https://github.com/JSQLParser/JSqlParser/commit/c60ff73909717be) Andreas Reichel) +- normalised backtick quotes ([619f8](https://github.com/JSQLParser/JSqlParser/commit/619f8dadb6ce942) Andreas Reichel) +- `TRY_CONVERT` and `SAFE_CONVERT` support ([9dfa0](https://github.com/JSQLParser/JSqlParser/commit/9dfa0d68af7abd3) Andreas Reichel) +- `SessionStatement` with options ([6c98f](https://github.com/JSQLParser/JSqlParser/commit/6c98f10f2d83342) Andreas Reichel) +- `SessionStatement` with options ([595d4](https://github.com/JSQLParser/JSqlParser/commit/595d4efa32f73b7) Andreas Reichel) +- `SessionStatement` with options ([55a6c](https://github.com/JSQLParser/JSqlParser/commit/55a6c465e49aeb2) Andreas Reichel) +- split catalog and schema ([4ff5c](https://github.com/JSQLParser/JSqlParser/commit/4ff5cc9830ef2e3) Andreas Reichel) +- split catalog and schema ([55201](https://github.com/JSQLParser/JSqlParser/commit/552019a56e30690) Andreas Reichel) +- `CREATE SCHEMA` with catalog ([ac46c](https://github.com/JSQLParser/JSqlParser/commit/ac46c4346eafcf8) Andreas Reichel) +- enable session with catalog ([30144](https://github.com/JSQLParser/JSqlParser/commit/30144e72ab38ccd) Andreas Reichel) +- **parser** allow COLLATE in ORDER BY clauses (issue #2245) (#2277) ([8810c](https://github.com/JSQLParser/JSqlParser/commit/8810c016c3c83ea) Sam Sovereign) +- Oracle hierarchical queries to except `Expression` in the operator ([624a7](https://github.com/JSQLParser/JSqlParser/commit/624a768b2eeae67) Andreas Reichel) +- `CORRESPONDING` modifier for `SetOperator` ([5fe93](https://github.com/JSQLParser/JSqlParser/commit/5fe938bc369a83b) Andreas Reichel) +- add support for DuckDB `CREATE TABLE` with `STRUCT(..)` columns ([0e171](https://github.com/JSQLParser/JSqlParser/commit/0e1715e9b07f293) Andreas Reichel) +- BigQuery `Historic Version` syntax ([5fa07](https://github.com/JSQLParser/JSqlParser/commit/5fa071ef240a82b) manticore-projects) +- Databricks `Temporal spec` syntax ([df5e6](https://github.com/JSQLParser/JSqlParser/commit/df5e6690ea24485) manticore-projects) +- Snowflake time travel syntax ([6f4c4](https://github.com/JSQLParser/JSqlParser/commit/6f4c4fb2dd441e4) manticore-projects) +- syntax sugar ([7c371](https://github.com/JSQLParser/JSqlParser/commit/7c371718678ee78) manticore-projects) +- more useful VisitorAdaptors ([7047c](https://github.com/JSQLParser/JSqlParser/commit/7047c187f85fcf1) manticore-projects) +- more useful VisitorAdaptors ([c6278](https://github.com/JSQLParser/JSqlParser/commit/c62781a3e16dafb) manticore-projects) +- make the various Visitor Adaptors more useful ([066e1](https://github.com/JSQLParser/JSqlParser/commit/066e1bbb7335aa2) manticore-projects) +- better defaults for `FromItemVisitorAdaptor` ([7feb3](https://github.com/JSQLParser/JSqlParser/commit/7feb3bc18a305f0) manticore-projects) +- support distinctrow keyword (#2238) ([e17cd](https://github.com/JSQLParser/JSqlParser/commit/e17cdef4275fa2b) Emily Ong) +- add Features for `dialect` and `allowedNestingDepth` ([296d0](https://github.com/JSQLParser/JSqlParser/commit/296d0321af58abc) manticore-projects) +- add fields holding the actual resolved table ([2500e](https://github.com/JSQLParser/JSqlParser/commit/2500e1ba72718a3) manticore-projects) +- `WITH ... AS NOT MATERIALIZED` ([2f6af](https://github.com/JSQLParser/JSqlParser/commit/2f6afbc3eb16d17) manticore-projects) +- SQL:2016 `BETWEEN [SYMMETRIC | ASYMMETRIC]` ([001ad](https://github.com/JSQLParser/JSqlParser/commit/001ad1c24c2a464) manticore-projects) +- Session Statement ([f0c09](https://github.com/JSQLParser/JSqlParser/commit/f0c098cec93656b) manticore-projects) +- Session Statement ([7d2e6](https://github.com/JSQLParser/JSqlParser/commit/7d2e6b65324ce57) manticore-projects) +- sync with Master ([e14d7](https://github.com/JSQLParser/JSqlParser/commit/e14d7eb1c4e9963) manticore-projects) +- JavaCC 8 keyword utils ([cfe2d](https://github.com/JSQLParser/JSqlParser/commit/cfe2d8ccaf7c76d) manticore-projects) +- Complete on JavaCC-8 ([1b7ed](https://github.com/JSQLParser/JSqlParser/commit/1b7ed2d7be000ce) manticore-projects) +- Optimise performance ([e91c4](https://github.com/JSQLParser/JSqlParser/commit/e91c480b0bbe0a9) manticore-projects) +- avoid looping through the tokens every single time ([b18fb](https://github.com/JSQLParser/JSqlParser/commit/b18fbca1f48e63e) manticore-projects) +- avoid looping through the tokens every single time ([7ac6c](https://github.com/JSQLParser/JSqlParser/commit/7ac6cd0fa08d713) manticore-projects) +- add proper JMH benchmarks ([21c98](https://github.com/JSQLParser/JSqlParser/commit/21c983fc1f4f3f2) manticore-projects) +- JavaCC-8 ([9d144](https://github.com/JSQLParser/JSqlParser/commit/9d1442e9a4800e2) manticore-projects) +- remove all semantic lookaheads ([5abca](https://github.com/JSQLParser/JSqlParser/commit/5abcaeaede27cfe) manticore-projects) + +### Bug Fixes + +- visit pipe expressions through shared deparser paths (#2618) ([537f3](https://github.com/JSQLParser/JSqlParser/commit/537f3a6dd1e35e7) Minjae Lee) +- span a binary condition's node from its left operand (#2615) ([0ecf0](https://github.com/JSQLParser/JSqlParser/commit/0ecf096d23acc1b) Knut Wannheden) +- preserve ordered table elements through legacy list edits (#2607) ([eb27c](https://github.com/JSQLParser/JSqlParser/commit/eb27c78bebccdb7) Minjae Lee) +- recognise set operation quantifiers written in any case (#2614) ([537c8](https://github.com/JSQLParser/JSqlParser/commit/537c8c1bee16907) Knut Wannheden) +- traverse and deparse structured table partitions (#2610) ([ef42d](https://github.com/JSQLParser/JSqlParser/commit/ef42d0b6ee91f65) Minjae Lee) +- share expression-aware table constraint rendering (#2609) ([9caed](https://github.com/JSQLParser/JSqlParser/commit/9caed4170713aed) Minjae Lee) +- preserve structured column options when editing specifications (#2608) ([fec4e](https://github.com/JSQLParser/JSqlParser/commit/fec4ec40e15ef53) Minjae Lee) +- keep CREATE TABLE option tokens in sync with typed options (#2606) ([d730b](https://github.com/JSQLParser/JSqlParser/commit/d730bf00fee62a0) Minjae Lee) +- **grammar** resolve JavaCC choice conflicts and gate the build against new ones ([8bb33](https://github.com/JSQLParser/JSqlParser/commit/8bb338572440cad) Andreas Reichel) +- **parser** preserve Oracle PRIOR position on all condition expressions (#2601) (#2602) ([37744](https://github.com/JSQLParser/JSqlParser/commit/3774451c3fa7f3e) fudian) +- **parser** parse Oracle outer join operator (+) after LIKE / SIMILAR TO operands (#2598) (#2600) ([35f84](https://github.com/JSQLParser/JSqlParser/commit/35f84d5a006c382) fudian) +- **parser** classify ODBC timestamp interval arguments (#2596) ([a7a5f](https://github.com/JSQLParser/JSqlParser/commit/a7a5fa5032447b2) Minjae Lee) +- **parser** resolve shadowed contextual keyword tokens (#2597) ([51e29](https://github.com/JSQLParser/JSqlParser/commit/51e29a042ce4a50) Minjae Lee) +- **parser** align empty statement input handling (#2594) ([1bef5](https://github.com/JSQLParser/JSqlParser/commit/1bef513f6f9fc7c) Minjae Lee) +- **parser** parse COMMENT ON ... IS NULL as comment removal (#2562) (#2563) ([b2115](https://github.com/JSQLParser/JSqlParser/commit/b2115ac8868dc8e) Paul_Kim) +- **parser** parse Oracle outer join operator (+) on BETWEEN operands (#672) (#2564) ([5bdd4](https://github.com/JSQLParser/JSqlParser/commit/5bdd4bf04ff884f) fudian) +- **parser** parse stacked NOT prefixes as nested NotExpression (#1170) (#2556) ([6c726](https://github.com/JSQLParser/JSqlParser/commit/6c726d8800ba1cc) fudian) +- **parser** parse INSERT ON CONFLICT after a join's trailing ON (#2551) ([ae37f](https://github.com/JSQLParser/JSqlParser/commit/ae37fd2aa06c324) fudian) +- **adapter** connect StatementVisitorAdapter sub-visitors and traverse DML CTEs ([1b57b](https://github.com/JSQLParser/JSqlParser/commit/1b57bfa41cef000) Andreas Reichel) +- **parser** support MySQL table rename variants (#2543) ([bb377](https://github.com/JSQLParser/JSqlParser/commit/bb377195dd622bd) Minjae Lee) +- **parser** model MySQL ALTER TABLE partition operations (#2540) ([80305](https://github.com/JSQLParser/JSqlParser/commit/80305c756fae362) Minjae Lee) +- **parser** model MySQL column type modifiers (#2537) ([bb2f2](https://github.com/JSQLParser/JSqlParser/commit/bb2f269e3b7489e) Minjae Lee) +- **parser** preserve unique index comments in ALTER TABLE (#2533) ([2243e](https://github.com/JSQLParser/JSqlParser/commit/2243e2ba78aa3d0) Minjae Lee) +- **parser** distinguish MySQL constraint and index names (#2534) ([bc9ca](https://github.com/JSQLParser/JSqlParser/commit/bc9ca85ecf1fd30) Minjae Lee) +- **parser** model PostgreSQL CREATE INDEX clauses (#2536) ([3ba25](https://github.com/JSQLParser/JSqlParser/commit/3ba25467ab9d14c) Minjae Lee) +- **parser** model PostgreSQL declarative partitions (#2535) ([c77bb](https://github.com/JSQLParser/JSqlParser/commit/c77bb0f0aa2c8d0) Minjae Lee) +- **parser** model ALTER COLUMN nullability actions (#2529) ([8397d](https://github.com/JSQLParser/JSqlParser/commit/8397d3a225e3fb3) Minjae Lee) +- **parser** allow VERSION in ALTER column clauses (#2530) ([a6da4](https://github.com/JSQLParser/JSqlParser/commit/a6da40051291b3c) Minjae Lee) +- memoize long-chain predicate walks behind a size threshold (#2520) ([33b03](https://github.com/JSQLParser/JSqlParser/commit/33b03e80b3bcd8e) fudian) +- prevent bare partition columns from inheriting the previous item's value (#2518) ([9a32f](https://github.com/JSQLParser/JSqlParser/commit/9a32ff568f58017) fudian) +- collect tables from all SELECT and DML trailing clauses in TablesNamesFinder (#2517) ([86418](https://github.com/JSQLParser/JSqlParser/commit/864181b74e42e8b) fudian) +- **parser** grammar ambiguities ([9c765](https://github.com/JSQLParser/JSqlParser/commit/9c76556d9b5910b) Andreas Reichel) +- **parser** parse qualified columns in GROUP BY (#2504) ([dff72](https://github.com/JSQLParser/JSqlParser/commit/dff722b593ed4e4) Chen Jianjin) +- **parser** support CAST to an array type for MySQL multi-valued indexes (#2506) ([e781b](https://github.com/JSQLParser/JSqlParser/commit/e781b3f27720347) Minjae Lee) +- **parser** support PostgreSQL # binary operator (bitwise XOR / geometric intersection) (#2507) ([d8d05](https://github.com/JSQLParser/JSqlParser/commit/d8d054aa6038a47) fudian) +- **parser** support MySQL index options and prefix-length key parts in index DDL (#2505) ([9fc38](https://github.com/JSQLParser/JSqlParser/commit/9fc38bd13bdaa7b) Minjae Lee) +- **parser** support leading CONTENT/DOCUMENT keyword in XMLPARSE (#2501) ([46584](https://github.com/JSQLParser/JSqlParser/commit/46584159b957706) Liming Deng) +- **parser** support CHARACTER SET in CAST CHAR types (#2497) ([1e4e9](https://github.com/JSQLParser/JSqlParser/commit/1e4e92bafdfd0fa) Liming Deng) +- **parser** support Oracle USING INDEX TABLESPACE in ALTER TABLE ADD CONSTRAINT (#2498) ([aa7df](https://github.com/JSQLParser/JSqlParser/commit/aa7df62608b6a88) Liming Deng) +- **parser** support IF EXISTS in ALTER TABLE MODIFY COLUMN (#2494) ([44c0f](https://github.com/JSQLParser/JSqlParser/commit/44c0fe50747fbe6) Liming Deng) +- support character set introduced string literals (#2493) ([158b5](https://github.com/JSQLParser/JSqlParser/commit/158b5800b4fd370) Liming Deng) +- support Oracle inline constraint states in CREATE TABLE (#2491) ([f5ecb](https://github.com/JSQLParser/JSqlParser/commit/f5ecba7dc51fab7) Liming Deng) +- keep all clauses when deparsing SELECT without FROM (#2483) (#2484) ([70139](https://github.com/JSQLParser/JSqlParser/commit/70139091d9d78f2) fudian) +- complete TablesNamesFinder traversal for piped queries, DML side clauses and analytic functions (#2478) (#2479) ([ad69e](https://github.com/JSQLParser/JSqlParser/commit/ad69eccc9928b92) fudian) +- reject illegal MERGE WHEN NOT MATCHED clause pairings (#2480) (#2481) ([a8cb4](https://github.com/JSQLParser/JSqlParser/commit/a8cb410ad118e78) fudian) +- treat a positional parameter '?' as a valid end of the ternary then-branch (#2477) ([f41c0](https://github.com/JSQLParser/JSqlParser/commit/f41c0b8aa29cd22) fudian) +- do not treat a named parameter ':' as the ternary else separator (#2476) ([5080d](https://github.com/JSQLParser/JSqlParser/commit/5080d19fab90463) fudian) +- allow GROUPS as identifier by making it a non-reserved keyword (#2473) (#2474) ([edfbb](https://github.com/JSQLParser/JSqlParser/commit/edfbb0ac050afa0) fudian) +- support ClickHouse ORDER BY WITH FILL and INTERPOLATE (#2467) (#2469) ([406a4](https://github.com/JSQLParser/JSqlParser/commit/406a4d41341d30f) fudian) +- support ClickHouse C-style ternary operator (? :) in expressions (#2436) (#2466) ([60b08](https://github.com/JSQLParser/JSqlParser/commit/60b0875abc1b2a5) fudian) +- allow scalar subquery as LIMIT row count (#2359) (#2464) ([2989c](https://github.com/JSQLParser/JSqlParser/commit/2989cb1d9c76774) fudian) +- support PostgreSQL composite row expansion (function()).* (#2463) ([7ced3](https://github.com/JSQLParser/JSqlParser/commit/7ced34d2bdee536) fudian) +- support SQL Server CREATE INDEX INCLUDE columns (#2462) ([b5adb](https://github.com/JSQLParser/JSqlParser/commit/b5adb60628ea504) Chen Jianjin) +- model interval qualifier as a structured property (#1728) (#2456) ([c9930](https://github.com/JSQLParser/JSqlParser/commit/c9930e36804d639) fudian) +- support PostgreSQL GROUPS window frames (#2460) ([d92f4](https://github.com/JSQLParser/JSqlParser/commit/d92f4074d3e1267) Chen Jianjin) +- **parser** keep parenthesized multi-param lambda as first function arg (#2455) ([b444b](https://github.com/JSQLParser/JSqlParser/commit/b444bc2a894dbdb) Ivan Clark) +- allow UNIQUE INDEX in CREATE TABLE (#2457) ([32a79](https://github.com/JSQLParser/JSqlParser/commit/32a79495a752f06) fudian) +- support ClickHouse tuple positional access (#2454) ([5bec7](https://github.com/JSQLParser/JSqlParser/commit/5bec712642fd267) Chen Jianjin) +- stop 0x hex literal from swallowing trailing whitespace (#2435) (#2450) ([18b12](https://github.com/JSQLParser/JSqlParser/commit/18b12f1864de80a) fudian) +- allow arbitrary column aliases in LATERAL VIEW (#2452) ([f92f5](https://github.com/JSQLParser/JSqlParser/commit/f92f5e5afd7d8b0) fudian) +- accept VISIBLE/INVISIBLE index and column attributes in CREATE TABLE and CREATE INDEX (#2449) ([aa542](https://github.com/JSQLParser/JSqlParser/commit/aa542c0822e8d00) Armand Parajon) +- support nested parametric data types as CAST target (#2451) ([3997b](https://github.com/JSQLParser/JSqlParser/commit/3997ba4347981e7) fudian) +- add 'K_TYPE' to KeywordOrIdentifier to allow 'type' as a column name (#2448) ([f0ba1](https://github.com/JSQLParser/JSqlParser/commit/f0ba1235028f37a) Minjae Lee) +- **parser** consume nested block comments in a MORE action ([83d7b](https://github.com/JSQLParser/JSqlParser/commit/83d7b5ac46b812c) Andreas Reichel) +- **test** resolve classes dir via CodeSource URI to unbreak Windows ([49622](https://github.com/JSQLParser/JSqlParser/commit/496221a653af093) Andreas Reichel) +- **grammar** use `TokenMgrException` instead of old `TokenMgrError` ([850fb](https://github.com/JSQLParser/JSqlParser/commit/850fb70d08de3c7) Andreas Reichel) +- **grammar** parse bracketed operands in function arguments and expression lists ([ca2b3](https://github.com/JSQLParser/JSqlParser/commit/ca2b3d71a870385) Andreas Reichel) +- split CCJSqlParserTokenManager static initializers to avoid 64KB method limit (#2425) ([cf5bb](https://github.com/JSQLParser/JSqlParser/commit/cf5bbc9a6216315) Hayssam Saleh) +- exponential backtracking on deeply nested bracketed expressions ([fff8a](https://github.com/JSQLParser/JSqlParser/commit/fff8a081e43d9b5) manticore-projects) +- **parser** pass modifier to ExceptOp/MinusOp constructors (#2419) (#2420) ([7fc30](https://github.com/JSQLParser/JSqlParser/commit/7fc300f7b0968ec) Alex Towell) +- **parser** parse mysql fulltext AGAINST concat expression (#2413) ([5788c](https://github.com/JSQLParser/JSqlParser/commit/5788ca067abf76a) Liming Deng) +- **parser** support KEY-prefixed expressions like KEY chain.entity (#2409) ([bfcb8](https://github.com/JSQLParser/JSqlParser/commit/bfcb8b752539ab3) Liming Deng) +- reduce timeout since we are too fast now :-D ([126c1](https://github.com/JSQLParser/JSqlParser/commit/126c1a16abaab2f) manticore-projects) +- improve performance by refactoring `Condition`, `RegularCondition`, `AndExpression` ([6c5d7](https://github.com/JSQLParser/JSqlParser/commit/6c5d7ef60351a49) manticore-projects) +- restore GENERATED ALWAYS AS IDENTITY parsing (#2397) ([bd3ce](https://github.com/JSQLParser/JSqlParser/commit/bd3ce05f356dac2) Liming Deng) +- **parser** resolve grammar LOOKAHEAD conflicts (#2399) ([59dfc](https://github.com/JSQLParser/JSqlParser/commit/59dfc3b0e7167eb) Liming Deng) +- **clickhouse** support SELECT ... SETTINGS (#2395) ([a34db](https://github.com/JSQLParser/JSqlParser/commit/a34db0ce68fe6ac) Liming Deng) +- support ClickHouse parametric aggregate calls (#2393) ([64542](https://github.com/JSQLParser/JSqlParser/commit/64542c863a1325d) Liming Deng) +- support SQL Server ORDER BY ... FOR XML PATH parsing in subqueries (#2392) ([9de70](https://github.com/JSQLParser/JSqlParser/commit/9de70747b94e575) Liming Deng) +- ALTER TABLE with a USING INDEX clause (#2384) ([c7b3b](https://github.com/JSQLParser/JSqlParser/commit/c7b3bdbd00cf96e) Liming Deng) +- remove obsolete Grammar option ([93515](https://github.com/JSQLParser/JSqlParser/commit/935151493cc9db9) manticore-projects) +- module-info.java ([484ea](https://github.com/JSQLParser/JSqlParser/commit/484eaa1c0f623cc) Andreas Reichel) +- DuckDB `STRUCT` ([297ef](https://github.com/JSQLParser/JSqlParser/commit/297ef84673521fd) Andreas Reichel) +- parsing `STRUCT` data types ([aaebe](https://github.com/JSQLParser/JSqlParser/commit/aaebe591001a164) Andreas Reichel) +- add some LOOKAHEAD ([2d739](https://github.com/JSQLParser/JSqlParser/commit/2d7393499e4d987) Andreas Reichel) +- avoid visiting twice ([49958](https://github.com/JSQLParser/JSqlParser/commit/49958b6ba96898f) Andreas Reichel) +- avoid NPE and expose `modifier` ([eeb04](https://github.com/JSQLParser/JSqlParser/commit/eeb04004da797c6) Andreas Reichel) +- return Dollar quoted text as `StringValue` ([95ebd](https://github.com/JSQLParser/JSqlParser/commit/95ebda5a6112cd7) manticore-projects) +- avoid NPE ([12600](https://github.com/JSQLParser/JSqlParser/commit/12600fb41957205) manticore-projects) +- possible NPE ([915aa](https://github.com/JSQLParser/JSqlParser/commit/915aa35d696b70b) manticore-projects) +- possible NPE ([dd05e](https://github.com/JSQLParser/JSqlParser/commit/dd05e11ae6dbe89) manticore-projects) +- `FromItemVisitorAdaptor` also needs a `SelectVisitor` ([178ca](https://github.com/JSQLParser/JSqlParser/commit/178ca057be78c00) manticore-projects) +- resolved physical tables must be clones, not references ([96321](https://github.com/JSQLParser/JSqlParser/commit/963217f48732426) manticore-projects) +- GroupByElement::getGroupByExpressionList shall not return raw ExpressionList ([f14c6](https://github.com/JSQLParser/JSqlParser/commit/f14c6115bd3e715) manticore-projects) +- increase Max. Nesting Depth to 16 (from 10) ([b8c0e](https://github.com/JSQLParser/JSqlParser/commit/b8c0ed58f3ee572) manticore-projects) +- date/time functions colliding with implicit casts ([6e91c](https://github.com/JSQLParser/JSqlParser/commit/6e91c3e1e3c94b3) manticore-projects) +- precedence of the `InExpression` ([0f9e4](https://github.com/JSQLParser/JSqlParser/commit/0f9e477944332c4) manticore-projects) +- revert to Semantic LOOKAHEAD for `SubSelect` in `PrimaryExpression` ([7f068](https://github.com/JSQLParser/JSqlParser/commit/7f068f6bd09623e) manticore-projects) +- bring back `SYNTACTIC LOOKAHEAD` where it makes sense ([b3c5b](https://github.com/JSQLParser/JSqlParser/commit/b3c5b63344de193) manticore-projects) +- the Quotes Token manipulation ([bad81](https://github.com/JSQLParser/JSqlParser/commit/bad818e0b872c6a) manticore-projects) + +### Other changes + +**Clarify PostgreSQL DO support and verify the reported block (#2633)** + +* Clarify PostgreSQL DO support and verify the reported block +* Keep DO round-trip assertions independent of fixture license comments + +[02b9d](https://github.com/JSQLParser/JSqlParser/commit/02b9d94072196b9) Minjae Lee *2026-09-13 12:10:51* + +**Render DML source clauses through shared visitor paths (#2630)** + + +[4b88a](https://github.com/JSQLParser/JSqlParser/commit/4b88a445419c846) Minjae Lee *2026-09-13 10:11:39* + +**Fix benchmark configuration and isolated parser class loading (#2629)** + + +[95140](https://github.com/JSQLParser/JSqlParser/commit/95140c895d836c5) Minjae Lee *2026-09-13 10:10:03* + +**Keep ALTER key accessors connected to structured index state (#2628)** + +* Keep ALTER key accessors connected to structured index state +* Clarify ALTER key element type for static analysis +* Make remaining ALTER key element types explicit +* Simplify ALTER key adapters and document replacement semantics + +[7739c](https://github.com/JSQLParser/JSqlParser/commit/7739c08181110e8) Minjae Lee *2026-09-13 10:07:36* + +**Protect shared dialect presets from external mutation (#2627)** + + +[b3b20](https://github.com/JSQLParser/JSqlParser/commit/b3b208489a19e7c) Minjae Lee *2026-09-13 10:03:57* + +**Share parser execution and preserve cancellation signals (#2626)** + + +[35105](https://github.com/JSQLParser/JSqlParser/commit/35105a0e18b2d9f) Minjae Lee *2026-09-13 09:59:42* + +**Reuse common JOIN traversal when discovering UPDATE tables (#2625)** + + +[a2baa](https://github.com/JSQLParser/JSqlParser/commit/a2baa18d7ce1589) Minjae Lee *2026-09-13 09:55:54* + +**Render DML RETURNING expressions through shared visitor handling (#2624)** + + +[38224](https://github.com/JSQLParser/JSqlParser/commit/3822466957f69f9) Minjae Lee *2026-09-13 09:54:53* + +**Validate every UPDATE assignment through shared UpdateSet traversal (#2623)** + + +[c314d](https://github.com/JSQLParser/JSqlParser/commit/c314df2b32c6fac) Minjae Lee *2026-09-13 09:53:02* + +**Structure FOR PORTION intervals in UPDATE and DELETE (#2622)** + + +[33c40](https://github.com/JSQLParser/JSqlParser/commit/33c4030433a3df2) Minjae Lee *2026-09-13 09:51:36* + +**Preserve ASOF joins through shared join rendering (#2621)** + + +[68608](https://github.com/JSQLParser/JSqlParser/commit/6860852112d6403) Minjae Lee *2026-09-13 09:49:48* + +**Support structured XMLFOREST arguments with aliases (#2619)** + + +[73bd3](https://github.com/JSQLParser/JSqlParser/commit/73bd3c498eed103) Minjae Lee *2026-09-13 09:41:15* + +**Support SQL Server SET IDENTITY_INSERT with a structured table target (#2605)** + + +[894ab](https://github.com/JSQLParser/JSqlParser/commit/894ab4d7e03717b) Minjae Lee *2026-09-12 00:35:38* + +**Support SQL Server boolean SET options with shared statement rendering (#2604)** + +* Co-authored-by: manticore-projects <andreas@manticore-projects.com> + +[f473c](https://github.com/JSQLParser/JSqlParser/commit/f473ccfd5f032c1) Minjae Lee *2026-09-12 00:34:26* + +**Support SQL Server INSERT BULK declarations (#2591)** + + +[bf2c9](https://github.com/JSQLParser/JSqlParser/commit/bf2c9ac773e8521) Minjae Lee *2026-09-11 21:41:04* + +**Support SQL Server XML methods on subquery results (#2590)** + +* Co-authored-by: manticore-projects <andreas@manticore-projects.com> + +[15156](https://github.com/JSQLParser/JSqlParser/commit/1515637c08a461a) Minjae Lee *2026-09-11 16:15:55* + +**Support PostgreSQL DO wrappers with preserved routine body literals (#2589)** + +* Co-authored-by: manticore-projects <andreas@manticore-projects.com> + +[1bc94](https://github.com/JSQLParser/JSqlParser/commit/1bc942422801523) Minjae Lee *2026-09-11 16:12:59* + +**Accept SQL Server CREATE TABLE trailing commas with shared element parsing (#2603)** + + +[179ee](https://github.com/JSQLParser/JSqlParser/commit/179ee11e17780a4) Minjae Lee *2026-09-11 16:10:39* + +**Split PostgreSQL hash operators from adjacent identifiers (#2588)** + + +[a946e](https://github.com/JSQLParser/JSqlParser/commit/a946e7715dec34d) Minjae Lee *2026-09-11 16:05:53* + +**Support Teradata UPDATE FROM before SET with shared clause rendering (#2587)** + +* Co-authored-by: mj <mj@mjui-MacBookPro.local> + +[a206b](https://github.com/JSQLParser/JSqlParser/commit/a206b861da4ff68) Minjae Lee *2026-09-11 15:20:17* + +**Structure SQL Server routine operations and table return types (#2593)** + +* Co-authored-by: mj <mj@mjui-MacBookPro.local> + +[d18de](https://github.com/JSQLParser/JSqlParser/commit/d18de825e152d05) Minjae Lee *2026-09-11 14:50:16* + +**Support CockroachDB ALTER PRIMARY KEY with structured hash options (#2585)** + +* Co-authored-by: mj <mj@mjui-MacBookPro.local> + +[7c6a9](https://github.com/JSQLParser/JSqlParser/commit/7c6a9fcbf5bd7bd) Minjae Lee *2026-09-11 14:47:57* + +**Support Doris distribution hints and share join keyword rendering (#2584)** + + +[78cff](https://github.com/JSQLParser/JSqlParser/commit/78cff6b34be54ca) Minjae Lee *2026-09-11 09:47:52* + +**Support Oracle anonymous blocks and implicit procedure calls (#2592)** + + +[17f03](https://github.com/JSQLParser/JSqlParser/commit/17f033df04e3b10) Minjae Lee *2026-09-11 09:08:42* + +**Support dialect-specific CREATE INDEX definitions (#2586)** + + +[4be19](https://github.com/JSQLParser/JSqlParser/commit/4be195b1e44d9b0) Minjae Lee *2026-09-11 09:06:37* + +**Support MySQL SELECT INTO user variables with explicit dialect (#2583)** + + +[588bf](https://github.com/JSQLParser/JSqlParser/commit/588bf070e9341e2) Minjae Lee *2026-09-11 09:05:22* + +**Support recursive CTE CYCLE clauses with shared recursive clause rendering (#2566)** + + +[eddb1](https://github.com/JSQLParser/JSqlParser/commit/eddb1fb5bb5f6ef) Minjae Lee *2026-09-11 04:37:17* + +**Support SQL Server constraint clustering with explicit dialect (#2582)** + + +[c1a61](https://github.com/JSQLParser/JSqlParser/commit/c1a611db8aa3f93) Minjae Lee *2026-09-11 04:30:55* + +**Support Informix trailing constraint names and share constraint rendering (#2570)** + +* Support Informix trailing constraint names and share constraint rendering +* fix(parser): gate Informix constraints on dialect selection + +[329ee](https://github.com/JSQLParser/JSqlParser/commit/329ee6b6465aa7e) Minjae Lee *2026-09-11 03:26:45* + +**Support PostgreSQL tagged dollar strings and preserve literal bodies (#2572)** + +* Support PostgreSQL tagged dollar strings and preserve literal bodies +* fix(parser): enable tagged dollar strings through PostgreSQL dialect + +[8ff4f](https://github.com/JSQLParser/JSqlParser/commit/8ff4f6488c7cf60) Minjae Lee *2026-09-11 03:12:26* + +**Support ksqlDB window grace periods and EMIT FINAL (#2571)** + +* Support ksqlDB window grace periods and EMIT FINAL +* Group ksqlDB window support with queries in the support table + +[e8479](https://github.com/JSQLParser/JSqlParser/commit/e8479ca3d93c6c8) Minjae Lee *2026-09-11 02:57:08* + +**Complete MySQL index options and share CREATE INDEX rendering (#2567)** + +* Complete MySQL index algorithm and lock options and share CREATE INDEX rendering +* Split shared index rendering into focused helpers +* Compare median monotonic durations in bracket growth regression checks + +[381d1](https://github.com/JSQLParser/JSqlParser/commit/381d1a9de236bd1) Minjae Lee *2026-09-11 02:48:19* + +**Support PostgreSQL conflict index elements, OVERRIDING USER and MERGE RETURNING (#2569)** + +* Support PostgreSQL conflict index elements, OVERRIDING USER and MERGE RETURNING +* Preserve bulk additions through the conflict column view + +[ba4dc](https://github.com/JSQLParser/JSqlParser/commit/ba4dce9d26016f2) Minjae Lee *2026-09-11 02:46:04* + +**Preserve EXEC bind arguments and support OUTPUT parameters (#2580)** + + +[2de24](https://github.com/JSQLParser/JSqlParser/commit/2de24179541d6c8) Minjae Lee *2026-09-11 02:44:11* + +**Support SQL Server table variables through shared table references (#2581)** + + +[7bb6e](https://github.com/JSQLParser/JSqlParser/commit/7bb6e1c4440f1fa) Minjae Lee *2026-09-11 02:41:51* + +**Fix parseStatements failure propagation and executor cleanup (#2568)** + + +[d9109](https://github.com/JSQLParser/JSqlParser/commit/d9109134703cb11) Minjae Lee *2026-09-11 02:40:33* + +**Validate CTE bodies through the existing statement dispatch (#2578)** + + +[72521](https://github.com/JSQLParser/JSqlParser/commit/7252121652154c6) Minjae Lee *2026-09-11 02:30:36* + +**Analyse analytic and conversion functions with complete window traversal (#2579)** + + +[01d7c](https://github.com/JSQLParser/JSqlParser/commit/01d7c3eea2d5e98) Minjae Lee *2026-09-11 02:27:12* + +**Fix DISTINCT traversal and share optional select-item visits (#2577)** + +* Visit optional DISTINCT ON items without changing the AST +* Verify plain DISTINCT retains unproven function analysis + +[db61f](https://github.com/JSQLParser/JSqlParser/commit/db61f4bc04a7613) Minjae Lee *2026-09-11 02:24:16* + +**Support structured PostgreSQL role, privilege and trigger DDL (#2555)** + +* Support structured PostgreSQL role privilege and trigger DDL +* Align access DDL field layout and simplify trigger rendering + +[01768](https://github.com/JSQLParser/JSqlParser/commit/01768813eb60295) Minjae Lee *2026-09-10 09:50:05* + +**Support structured PostgreSQL publication and subscription DDL (#2554)** + +* Support structured PostgreSQL logical replication DDL +* Exclude PostgreSQL fixtures from Transact-SQL linting + +[bc18f](https://github.com/JSQLParser/JSqlParser/commit/bc18fdf99b52b4b) Minjae Lee *2026-09-10 09:39:51* + +**Support SQL Server ALTER TABLE ADD DEFAULT constraints (#2561)** + + +[d45f7](https://github.com/JSQLParser/JSqlParser/commit/d45f79699d43bc0) Minjae Lee *2026-09-10 08:34:43* + +**Support Oracle XMLSERIALIZE CONTENT and DOCUMENT forms (#2560)** + + +[8ecff](https://github.com/JSQLParser/JSqlParser/commit/8ecff15fecbc8bf) Minjae Lee *2026-09-10 08:32:34* + +**Support SQL Server typed XML schema collections (#2559)** + +* Support SQL Server typed XML schema collections +* Keep XML type lookahead independent of EXPLAIN additions + +[b2c84](https://github.com/JSQLParser/JSqlParser/commit/b2c84f98e6992a6) Minjae Lee *2026-09-10 08:31:04* + +**Support Redshift materialized view BACKUP clauses (#2557)** + + +[b5595](https://github.com/JSQLParser/JSqlParser/commit/b55956b649a06f5) Minjae Lee *2026-09-10 08:30:02* + +**Support PostgreSQL parenthesized EXPLAIN options (#2558)** + + +[4c8f5](https://github.com/JSQLParser/JSqlParser/commit/4c8f593e73948df) Minjae Lee *2026-09-10 08:29:01* + +**Model MySQL DROP object lists (#2545)** + +* feat(parser): model MySQL DROP object lists +* test: keep DROP assertions Java 11 compatible + +[5c59b](https://github.com/JSQLParser/JSqlParser/commit/5c59b7bc24a1af8) Minjae Lee *2026-09-05 00:15:16* + +**Model MySQL ANALYZE TABLE statements (#2542)** + +* feat(parser): model MySQL ANALYZE TABLE +* test: keep ANALYZE assertions Java 11 compatible + +[53200](https://github.com/JSQLParser/JSqlParser/commit/5320066eb287807) Minjae Lee *2026-09-05 00:12:03* + +**Support structured MySQL table definitions (#2541)** + +* refactor(ast): model structured table definitions +* fix(parser): unify MySQL table definitions +* fix(parser): model common MySQL table options +* fix(ast): initialize check constraint kind + +[a6450](https://github.com/JSQLParser/JSqlParser/commit/a64505266ffce63) Minjae Lee *2026-09-05 00:10:27* + +**corrected missing licence headers** + + +[495da](https://github.com/JSQLParser/JSqlParser/commit/495dafec9e37e22) tw *2026-09-04 22:12:41* + +**Update ci.yml** + + +[4b89a](https://github.com/JSQLParser/JSqlParser/commit/4b89a35da568df5) manticore-projects *2026-09-04 07:24:50* + +**Create requirements-docs.txt** + + +[fd59b](https://github.com/JSQLParser/JSqlParser/commit/fd59b5267ed77f7) manticore-projects *2026-09-04 07:24:28* + +**Update ci.yml** + +* Fix workflow + +[8186f](https://github.com/JSQLParser/JSqlParser/commit/8186f38e3d8b345) manticore-projects *2026-09-04 07:10:25* + +**Support MySQL CHECK constraint enforcement (#2528)** + + +[125de](https://github.com/JSQLParser/JSqlParser/commit/125de36c05b6dd7) Minjae Lee *2026-09-03 06:40:12* + +**Support PostgreSQL CREATE INDEX header options (#2527)** + + +[43314](https://github.com/JSQLParser/JSqlParser/commit/433143e4aaacfb5) Minjae Lee *2026-09-03 06:39:21* + +**Add MySQL CREATE TABLE partition parsing (#2521)** + + +[536fe](https://github.com/JSQLParser/JSqlParser/commit/536fe3b62de6e43) Minjae Lee *2026-09-03 06:38:22* + +**anchor oracle hint pattern to avoid quadratic backtracking (#2495)** + + +[a5765](https://github.com/JSQLParser/JSqlParser/commit/a5765f3f905d41a) Javid Khan *2026-08-22 12:45:11* + +**avoid quadratic backtracking in Server name pattern (#2489)** + + +[edd5b](https://github.com/JSQLParser/JSqlParser/commit/edd5bfc1a513f01) Javid Khan *2026-08-22 02:41:56* + +**Separate JSON operators with spaces so #> deparses correctly (#2487)** + +* JsonExpression.toString glued each operator directly onto its operand, so +* a #> ... deparsed as a#>... . Because # is a legal identifier character, that +* re-parses as a# > ... -- a GreaterThan, a different tree from the original +* JsonExpression. Emit a space on each side of the operator, matching the +* JsonOperator visitor. + +[55b23](https://github.com/JSQLParser/JSqlParser/commit/55b23637604ea24) Denis Gregor *2026-08-19 03:25:49* + +**Update changelog** + + +[fa731](https://github.com/JSQLParser/JSqlParser/commit/fa731f9b1b9d5fd) Andreas Reichel *2026-08-18 01:18:54* + +**Update Gradle wrapper** + + +[37e17](https://github.com/JSQLParser/JSqlParser/commit/37e17a09a0b7cfd) Andreas Reichel *2026-08-17 01:32:56* + +**Update changelog** + + +[0944d](https://github.com/JSQLParser/JSqlParser/commit/0944d553e5b7fde) Andreas Reichel *2026-08-13 14:31:54* + +**Add support PostgreSQL ROWS FROM table functions (#2416)** + + +[14db8](https://github.com/JSQLParser/JSqlParser/commit/14db886f5a23e56) Liming Deng *2026-07-30 03:07:55* + +**use Locale.ROOT for case-insensitive keyword normalisation (#2437)** + +* Signed-off-by: dxbjavid <dxbjavid@gmail.com> + +[82b7c](https://github.com/JSQLParser/JSqlParser/commit/82b7c26334df876) Javid Khan *2026-07-30 03:06:47* + +**[Fix] #2443 - NPE In TableNamesFinder with AnalyticExpression (#2444)** + +* [Fix] #2443 - NPE In TableNamesFinder with AnalyticExpression +* If you attempt to tree walk an AnalyticExpression in TableNamesFinder with an SQL that has a window function without a range and without an offset, such as `SELECT c, SUM(COUNT(*)) OVER (ORDER BY c ASC ROWS UNBOUNDED PRECEDING) FROM tbl GROUP BY c`, an NPE is thrown. This adds defensive checks around the range and offset expressions being null. +* More aggressive NPE protection +* --------- +* Co-authored-by: David Hayes <dhayes@adobe.com> + +[56468](https://github.com/JSQLParser/JSqlParser/commit/5646842a0b1c37a) David Hayes *2026-07-25 02:34:37* + +**[feat] Support for JSON_TABLE (#2328)** + +* [feat] Initial support for JSON_TABLE +* [feat] Additional support for JSON_TABLE +* [chore] Code Review +* [chore] Started to add oracle JSON_TABLE features +* [feat] Fixed onError for Oracle, added onEmptyClause, addedParsingType, formatJson for Body +* [feat] Added EXISTS keyword +* [chore] spotless +* [chore] cleanup +* [bugfix] Fixed token limit again... +* [chore] One more test, code cleanup + +[c5e2f](https://github.com/JSQLParser/JSqlParser/commit/c5e2fdcd40e81fa) Andreas Neumann *2026-04-02 16:42:55* + +**Add support MySQL SELECT INTO OUTFILE/DUMPFILE (#2418)** + +* Add support MySQL SELECT INTO OUTFILE/DUMPFILE +* fix + +[c0e1d](https://github.com/JSQLParser/JSqlParser/commit/c0e1d0528a9b114) Liming Deng *2026-03-22 07:31:33* + +**Fix dollar-quoted CREATE FUNCTION statement splitting (#2410)** + +* Fix dollar-quoted CREATE FUNCTION statement splitting +* Fix exception + +[c5b85](https://github.com/JSQLParser/JSqlParser/commit/c5b85abffdb00ae) Liming Deng *2026-03-14 18:09:38* + +**Add support MySQL functional index key parts in ALTER/CREATE INDEX (#2405)** + + +[7b87d](https://github.com/JSQLParser/JSqlParser/commit/7b87d0816dea41e) Liming Deng *2026-03-08 15:53:07* + +**Fix nested PostgreSQL composite field access after cast (#2404)** + + +[5b5fe](https://github.com/JSQLParser/JSqlParser/commit/5b5fe6c2a7e2908) Liming Deng *2026-03-08 15:50:58* + +**Add support parse SEARCH BREADTH/DEPTH FIRST in recursive CTEs (#2402)** + +* fix(parser): parse SEARCH BREADTH/DEPTH FIRST in recursive CTEs +* fix + +[1ee36](https://github.com/JSQLParser/JSqlParser/commit/1ee36829fbce7ef) Liming Deng *2026-03-08 08:31:28* + +**Update README.md to remove General SQL Parser mention** + +* Removed a comparison of General SQL Parser from alternatives section. + +[c3b15](https://github.com/JSQLParser/JSqlParser/commit/c3b1531150b0a03) Tobias *2026-03-07 21:12:26* + +**Add support CREATE SEQUENCE AS data type (#2400)** + +* Add support CREATE SEQUENCE AS data type +* format cod + +[22da3](https://github.com/JSQLParser/JSqlParser/commit/22da32654622925) Liming Deng *2026-03-06 16:09:41* + +**Add support MySQL named UNIQUE index in ALTER TABLE (#2391)** + + +[fb36c](https://github.com/JSQLParser/JSqlParser/commit/fb36cc6a2ec46ba) Liming Deng *2026-03-01 14:58:01* + +**Add support SELECT SAMPLE 0.1/OFFSET and CREATE TABLE SAMPLE BY (#2390)** + +* fix(clickhouse): support SELECT SAMPLE 0.1/OFFSET and CREATE TABLE SAMPLE BY +* fix(clickhouse): support SELECT SAMPLE 0.1/OFFSET and CREATE TABLE SAMPLE BY + +[e1620](https://github.com/JSQLParser/JSqlParser/commit/e16202441dd91c1) Liming Deng *2026-03-01 10:31:28* + +**Fix broken maven central svg url (#2389)** + + +[ecaa2](https://github.com/JSQLParser/JSqlParser/commit/ecaa26d3e0e1bbd) Liming Deng *2026-02-28 08:53:26* + +**Add support MySQL SPATIAL KEY (#2388)** + + +[a019a](https://github.com/JSQLParser/JSqlParser/commit/a019aa01085f110) Liming Deng *2026-02-25 16:39:25* + +**Fix alter table index descending (#2387)** + + +[763e9](https://github.com/JSQLParser/JSqlParser/commit/763e92d71d728de) Liming Deng *2026-02-24 13:00:47* + +**Add support for multiple Trino JSON functions (#2382)** + +* Adding support for clauses in JSON Functions. Fixes #2368 +* Adds support for the extra clauses found in Trino's JSON functions https://trino.io/docs/current/functions/json.html#json-exists, and includes test cases for these extra functions directly taken from the documentations. +* Before: +* Result "net.sf.jsqlparser.benchmark.JSQLParserBenchmark.parseSQLStatements": +* 34.858 ±(99.9%) 1.724 ms/op [Average] +* (min, avg, max) = (32.578, 34.858, 38.383), stdev = 2.302 +* CI (99.9%): [33.133, 36.582] (assumes normal distribution) +* After: +* Result "net.sf.jsqlparser.benchmark.JSQLParserBenchmark.parseSQLStatements": +* 36.154 ±(99.9%) 1.701 ms/op [Average] +* (min, avg, max) = (33.100, 36.154, 38.353), stdev = 2.271 +* CI (99.9%): [34.453, 37.855] (assumes normal distribution) +* Co-authored-by: David Hayes <dhayes@adobe.com> + +[d33d6](https://github.com/JSQLParser/JSqlParser/commit/d33d61a882d17ef) David Hayes *2026-02-24 12:23:52* + +**Fix oracle outer join case with nvl/coalesce (#2386)** + + +[834af](https://github.com/JSQLParser/JSqlParser/commit/834afe188e7ff46) Liming Deng *2026-02-24 12:15:14* + +**Add support clickhouse GLOBAL ANY/ALL JOIN syntax variants (#2385)** + + +[865a3](https://github.com/JSQLParser/JSqlParser/commit/865a3bf00d7a58d) Liming Deng *2026-02-23 13:38:22* + +**Add support for insert as row_alias (#2383)** + +* Add support for insert as row_alias +* format code + +[4e3d7](https://github.com/JSQLParser/JSqlParser/commit/4e3d7a56fdd4460) Liming Deng *2026-02-22 16:16:52* + +**[feat] Support for the legacy Postgres named parameter (#2374)** + +* feat: add postgresql named parameters support +* modify: PostgresNamedFunctionParameterTest.java +* refactor: code formatting +* --------- +* Co-authored-by: youngjoonkim <youngjoonkim@seowoninfo.com> + +[7c52e](https://github.com/JSQLParser/JSqlParser/commit/7c52e7fe8df21a2) youngjoon *2026-02-15 09:09:33* + +**Add support for ClickHouse PREWHERE clause (#2378)** + + +[8453c](https://github.com/JSQLParser/JSqlParser/commit/8453ca0fe7ce1a0) Liming Deng *2026-02-15 09:08:55* + +**Add support for ClickHouse MATERIALIZED column in CREATE TABLE (#2377)** + +* - allow `MATERIALIZED` in column specs +* - allow `ORDER BY` in table options +* - add regression test for `ENGINE = MergeTree() ORDER BY tuple()` + +[ededd](https://github.com/JSQLParser/JSqlParser/commit/ededd864b81b33a) Liming Deng *2026-02-13 17:12:48* + +**Delete .github/dependabot.yml** + + +[38c96](https://github.com/JSQLParser/JSqlParser/commit/38c963d6464eef4) manticore-projects *2026-02-12 08:26:46* + +**Add support for JOIN FETCH (#2375)** + + +[091ef](https://github.com/JSQLParser/JSqlParser/commit/091ef964eaa0822) Liming Deng *2026-02-12 08:06:12* + +**Support PostgreSQL-specific [CREATE SEQUENCE name START n ...] (#2348)** + +* Support PostgreSQL-specific [CREATE SEQUENCE name START n ...] +* I.e. no `START WITH` +* Fixes #2347 +* Support PostgreSQL-specific [CREATE SEQUENCE … INCREMENT n ...] +* I.e. no `INCREMENT BY` +* Fixes #2347 + +[40ccf](https://github.com/JSQLParser/JSqlParser/commit/40ccf4b87171494) mjog *2025-11-21 07:21:30* + +**[feat] Add 'K_DATA' to KeywordOrIdentifier to allow usages of 'data' as an identifier (#2340)** + +* Allows for support of data as a column name when changing or dropping a column in an alter table statement + +[2d83c](https://github.com/JSQLParser/JSqlParser/commit/2d83cea9ba65a7c) Will Needham *2025-11-21 02:18:54* + +**[fix] Enable qualified table name for DROP INDEX command (#2344)** + +* Thank you for your contribution. + +[8d967](https://github.com/JSQLParser/JSqlParser/commit/8d967803c780f5f) Ton Huisman *2025-11-21 02:17:13* + +**Update README.md (#2331)** + + +[01034](https://github.com/JSQLParser/JSqlParser/commit/01034cd08c3e9d7) Hayssam Saleh *2025-10-28 11:48:22* + +**[feat/refactor] AllColumns and AllTableColumns-Support for JSON_OBJECT (#2323)** + +* [feat] JSON_OBJECT support for AllColumns and AllTableColumns +* [feat] JSON_OBJECT support for AllColumns and AllTableColumns +* [feat] JSON_OBJECT support for AllColumns and AllTableColumns +* [feat] Split the parser syntax for JsonFunction, added more Tests, added Feature to disable Commas as key value separators +* [feat] Disable Expression as JSON_OBJECT key value via feature flag +* [chore] spotlessApply +* [feat] Use append method from JsonKeyValuePair + +[e8d60](https://github.com/JSQLParser/JSqlParser/commit/e8d605854ae9148) Andreas Neumann *2025-10-12 11:06:19* + +**[feat] Support for FOR READ ONLY/FOR FETCH ONLY (#2325)** + +* [feat] Support for FOR READ ONLY/FOR FETCH ONLY +* [chore] Spotless + +[e4004](https://github.com/JSQLParser/JSqlParser/commit/e400444402c7a6e) Andreas Neumann *2025-10-10 11:01:28* + +**[feat] Support for LOCK-Statements (#2321)** + +* Add support for LOCK-Statements +* Fixed comments +* ran updateKeywords +* Added test +* Checkstyle & Spotless +* Adjusted NOWAIT and WAIT-Setter + +[6697c](https://github.com/JSQLParser/JSqlParser/commit/6697c063493cac2) Andreas Neumann *2025-10-07 23:32:53* + +**Added new features to support the complete delete using syntax of pg database, such as subqueries, etc. (#2316)** + +* Co-authored-by: zhangkenan <zhangkenan@hexadb.com> + +[15798](https://github.com/JSQLParser/JSqlParser/commit/157988d1c5f6816) ConanZhang *2025-09-24 02:06:46* + +**Fix[2312] - Fixes issue with array in function declaration (#2313)** + +* Fix[2312] - Fixes issue with array<double> in function declaration +* ```sql +* WITH +* FUNCTION takesArray(x array<double>) +* RETURNS double +* RETURN x[1] + x[2] + x[3] +* SELECT takesArray(array[1.0, 2.0, 3.0]); +* ``` +* Is unable to be parsed as we're not able to capture the array<double> correctly. This PR fixes that, as well as some missing visitor changes from my previous PR. +* Fix spotlessJavaCheck +* --------- +* Co-authored-by: David Hayes <dhayes@adobe.com> + +[528dd](https://github.com/JSQLParser/JSqlParser/commit/528dd7227401d07) David Hayes *2025-09-17 01:20:36* + +**Fix[2306] - Adds support for Trino UDF (#2307)** + +* Fix[2306] - Adds support for Trino UDF +* Trino SQL allows you to specify User Defined functions in the WITH clause ahead of a statement. This adds support for this type of statement. +* Fix[2306] - Adds support for Trino UDF +* Trino SQL allows you to specify User Defined functions in the WITH clause ahead of a statement. This adds support for this type of statement. +* --------- +* Co-authored-by: David Hayes <dhayes@adobe.com> + +[6ce95](https://github.com/JSQLParser/JSqlParser/commit/6ce95d54378a2f6) David Hayes *2025-09-13 23:29:04* + +**support opengauss "on duplicate key update nothing" grammar (#2303)** + +* support opengauss "on duplicate key nothing" grammar +* use import single classes instead of wildcard imports in Insert class. +* use import single classes instead of wildcard imports in Insert class. +* use './gradlew :spotlessApply' adjust code format. +* --------- +* Co-authored-by: zhangkenan <zhangkenan@hexadb.com> + +[468ae](https://github.com/JSQLParser/JSqlParser/commit/468aefae04b0204) ConanZhang *2025-08-28 12:15:36* + +**Fix[2290] - Fix overeager lambda function parsing (#2293)** + +* `SELECT DATE_TRUNC('week',("schema"."tbl"."column" + INTERVAL '1 day')) FROM "schema"."tbl";` +* is parsing the `("schema"."tbl"."column" + INTERVAL '1 day')` as a LambdaFunction incorrectly, and crashes out. Increasing the lookahead depth by 1 ensures it fails to match on the `->` keyword (I believe), and falls into a simple expression instead. +* JMH +* ``` +* jmh { +* includes = ['.*JSQLParserBenchmark.*'] +* warmupIterations = 2 +* fork = 5 +* iterations = 5 +* timeOnIteration = '5s' +* } +* ``` +* After: +* ``` +* 33.970 ±(99.9%) 1.773 ms/op [Average] +* (min, avg, max) = (31.405, 33.970, 37.302), stdev = 2.367 +* CI (99.9%): [32.197, 35.743] (assumes normal distribution) +* ``` +* Before: +* ``` +* 34.882 ±(99.9%) 1.923 ms/op [Average] +* (min, avg, max) = (31.191, 34.882, 37.406), stdev = 2.567 +* CI (99.9%): [32.959, 36.805] (assumes normal distribution) +* ``` +* Co-authored-by: David Hayes <dhayes@adobe.com> + +[12489](https://github.com/JSQLParser/JSqlParser/commit/12489af67cb82dc) David Hayes *2025-08-11 22:49:52* + +**Fix[2288] - Support parenthesed expressions within Between (#2289)** + +* Supports the SQL of the form: +* ```sql +* SELECT * FROM tbl WHERE +* day BETWEEN +* CAST(CAST((NOW() + INTERVAL '-30 day') AS date) AS timestamptz) +* AND +* CAST(CAST((NOW() + INTERVAL '-1 day') AS date) AS timestamptz); +* ``` +* Co-authored-by: David Hayes <dhayes@adobe.com> + +[f10b5](https://github.com/JSQLParser/JSqlParser/commit/f10b52eda68da22) David Hayes *2025-08-05 14:57:46* + +**Fix[2283] - Fix broken ParserKeywordsUtilsTest (#2286)** + +* Javacc java generator was only being included as a pom artefact in test, but the jar is required for the ParserKeywordsUtilsTest to succeed. +* Co-authored-by: David Hayes <dhayes@adobe.com> + +[2ff73](https://github.com/JSQLParser/JSqlParser/commit/2ff7342dfe41435) David Hayes *2025-08-01 09:39:30* + +**Add pluginRepositories to pom.xml (#2284)** + +* Adds pluginRepositories to the pom.xml to allow the javacc plugin to not download from insecure repositories (https vs http). +* Also adds missing copyrights which were added by maven. +* Co-authored-by: David Hayes <dhayes@adobe.com> + +[f10e5](https://github.com/JSQLParser/JSqlParser/commit/f10e5bdd4fdd31c) David Hayes *2025-07-31 13:16:04* + +**added new maven central deployer** + + +[50e75](https://github.com/JSQLParser/JSqlParser/commit/50e75d6d64958b3) tw *2025-07-10 23:38:15* + +**added new maven central deployer** + + +[afc7b](https://github.com/JSQLParser/JSqlParser/commit/afc7bdb26eb53e7) tw *2025-07-10 23:04:43* + + +## jsqlparser-5.3 (2025-05-17) + +### Features + +- eliminate another expensive syntactic lookahead ([6049f](https://github.com/JSQLParser/JSqlParser/commit/6049fd729ec4073) manticore-projects) +- avoid looping through the tokens every single time ([ac175](https://github.com/JSQLParser/JSqlParser/commit/ac175138405726b) manticore-projects) +- adopt proper JMH based benchmark ([fe860](https://github.com/JSQLParser/JSqlParser/commit/fe860ddd18f28f8) manticore-projects) +- Optimise performance ([7d42f](https://github.com/JSQLParser/JSqlParser/commit/7d42ff614bd2cca) manticore-projects) + +### Other changes + + +## jsqlparser-5.2 (2025-05-04) + +### Features + +- enhance ALTER TABLE support with UNIQUE KEY and INVISIBLE index (#2234) ([78318](https://github.com/JSQLParser/JSqlParser/commit/78318bb64bcfc96) Minjae Lee) +- link all Expression AST Nodes ([98e03](https://github.com/JSQLParser/JSqlParser/commit/98e03d4c5e5f659) manticore-projects) +- add support for parsing MySQL ALTER TABLE statements with new options (#2223) ([9a36a](https://github.com/JSQLParser/JSqlParser/commit/9a36a48087eb311) Minjae Lee) +- support MySQL ALTER TABLE ... PARTITION BY syntax (#2210) ([d60c7](https://github.com/JSQLParser/JSqlParser/commit/d60c762f1d71c9f) Minjae Lee) +- add support SELECT all columns from function result (#2207) ([30cf5](https://github.com/JSQLParser/JSqlParser/commit/30cf5d7b930ae0a) Lian Hu) +- `WithItem` must accept statements too for supporting `Delete`, `Insert`, `Update` with `Returning` ([585b6](https://github.com/JSQLParser/JSqlParser/commit/585b69c9149d418) manticore-projects) +- allow simple expressions for `JsonExpression` ([eef8e](https://github.com/JSQLParser/JSqlParser/commit/eef8e6e08ac39c9) Andreas Reichel) +- System.getProperty("SPLIT_NAMES_ON_DELIMITER") for allowing `.` dots in Table Names ([1d37e](https://github.com/JSQLParser/JSqlParser/commit/1d37eb0b94effdb) Andreas Reichel) +- Nested `WithItem` allows `FromQuery` ([0f749](https://github.com/JSQLParser/JSqlParser/commit/0f7493fa3d63af8) Andreas Reichel) +- add Order Suffixes to `AggregatePipeOperator` and support some weird BigQuery Syntax ([f932b](https://github.com/JSQLParser/JSqlParser/commit/f932b8f9807530c) Andreas Reichel) +- More lenient `FromQuery` allowing for `Join` and `WithItem` ([bcac0](https://github.com/JSQLParser/JSqlParser/commit/bcac023a5e43297) Andreas Reichel) +- More lenient `FromQuery` allowing for `Join` and `WithItem` ([5c2a4](https://github.com/JSQLParser/JSqlParser/commit/5c2a4537506a632) Andreas Reichel) +- `SELECT` piper operator to support `ALL | DISTINCT` ([5b209](https://github.com/JSQLParser/JSqlParser/commit/5b209f5477464ec) Andreas Reichel) +- improve TableSample Operator ([19f0a](https://github.com/JSQLParser/JSqlParser/commit/19f0aa4762667d0) Andreas Reichel) +- rewrite Piped SQL, WIP ([47583](https://github.com/JSQLParser/JSqlParser/commit/47583dea7e23992) Andreas Reichel) +- rewrite Piped SQL, WIP ([519b0](https://github.com/JSQLParser/JSqlParser/commit/519b02040af3ad6) Andreas Reichel) +- rewrite Piped SQL, WIP ([1cb26](https://github.com/JSQLParser/JSqlParser/commit/1cb26a731efae14) Andreas Reichel) +- rewrite Piped SQL, WIP ([0e488](https://github.com/JSQLParser/JSqlParser/commit/0e488b05159745b) Andreas Reichel) +- `ParenthesedSelect` can have `Alias` ([b5b24](https://github.com/JSQLParser/JSqlParser/commit/b5b242a3f6648ce) Andreas Reichel) +- `ParenthesedSelect` can have `Alias` ([a510f](https://github.com/JSQLParser/JSqlParser/commit/a510f135d50964e) Andreas Reichel) +- rework the Visitors ([8c051](https://github.com/JSQLParser/JSqlParser/commit/8c05188d74f50c0) Andreas Reichel) +- rework the Visitors ([d8162](https://github.com/JSQLParser/JSqlParser/commit/d816220f155d5a3) Andreas Reichel) +- rework the Visitors ([13879](https://github.com/JSQLParser/JSqlParser/commit/1387986effd76f3) Andreas Reichel) +- parsing Piped SQL, complete all Operators ([48cc2](https://github.com/JSQLParser/JSqlParser/commit/48cc2f748eb5685) Andreas Reichel) +- parsing Piped SQL ([f687f](https://github.com/JSQLParser/JSqlParser/commit/f687f77d38e9328) Andreas Reichel) +- Support not equals operator with a hat (#2153) ([3fee9](https://github.com/JSQLParser/JSqlParser/commit/3fee9aa9a2d621d) Stefan Steinhauser) +- Support unknown keyword (#2141) ([9ab1e](https://github.com/JSQLParser/JSqlParser/commit/9ab1ebded5fa493) Emily Ong) +- serialize `WithItem` ([df665](https://github.com/JSQLParser/JSqlParser/commit/df66569a87ce6fb) manticore-projects) +- Adding coverage for Postgres "OVERRIDING SYSTEM VALUE" (#2142) ([0ab13](https://github.com/JSQLParser/JSqlParser/commit/0ab131922d972aa) nicky6s) +- Piped SQL and FROM queries (WIP) ([01dc5](https://github.com/JSQLParser/JSqlParser/commit/01dc5f3472ce5ec) manticore-projects) +- Piped SQL and FROM queries (WIP) ([abf13](https://github.com/JSQLParser/JSqlParser/commit/abf137e04ca765d) manticore-projects) +- Piped SQL and FROM queries (WIP) ([f25e2](https://github.com/JSQLParser/JSqlParser/commit/f25e28bff4c96cb) manticore-projects) + +### Bug Fixes + +- `GRANT` to `PUBLIC` (allow keyword) ([4c4ff](https://github.com/JSQLParser/JSqlParser/commit/4c4ff286434f35e) manticore-projects) +- Oracle Hierarchical Expression shall allow XOR (not AND only) ([c9c84](https://github.com/JSQLParser/JSqlParser/commit/c9c844aa22d1bbc) manticore-projects) +- grammar ambiguities from #2217 ([b409c](https://github.com/JSQLParser/JSqlParser/commit/b409ceb5aa2c9d6) Andreas Reichel) +- SelectItem generics ([b73ce](https://github.com/JSQLParser/JSqlParser/commit/b73cee65cd74710) Andreas Reichel) +- add some public getters ([09f3d](https://github.com/JSQLParser/JSqlParser/commit/09f3dbcd1d8ad44) Andreas Reichel) +- avoid NPE on empty Window Element properties ([16685](https://github.com/JSQLParser/JSqlParser/commit/16685289d7d5879) Andreas Reichel) +- `IntervalExpression` supports complex expressions ([e30f3](https://github.com/JSQLParser/JSqlParser/commit/e30f30d27b58325) Andreas Reichel) +- avoid one JavaCC ambiguity warning ([0c092](https://github.com/JSQLParser/JSqlParser/commit/0c092afff549d52) Andreas Reichel) +- avoid NPE ([9714f](https://github.com/JSQLParser/JSqlParser/commit/9714f940d249af9) Andreas Reichel) +- Remove unneeded `LOOKAHEAD` ([fb978](https://github.com/JSQLParser/JSqlParser/commit/fb978ce11a81655) Andreas Reichel) +- `Like`, better use `SimpleExpression` only else there are precedence issues ([1d594](https://github.com/JSQLParser/JSqlParser/commit/1d59430eeeaf67e) Andreas Reichel) +- `Like` Expression accepts Complex Expressions including `BY PRIOR` ([9b92c](https://github.com/JSQLParser/JSqlParser/commit/9b92cdfcec7206c) Andreas Reichel) +- use `SelectItem` for `UnPivot` ([b1b86](https://github.com/JSQLParser/JSqlParser/commit/b1b86f549529ab6) Andreas Reichel) +- move `Pivot` and `UnPivot` before `OrderBy` ([9c37f](https://github.com/JSQLParser/JSqlParser/commit/9c37fe8eb8f3d42) Andreas Reichel) +- move `Pivot` and `UnPivot` before `OrderBy` ([2ca16](https://github.com/JSQLParser/JSqlParser/commit/2ca167a90f59c6c) Andreas Reichel) +- use `Function` and `SelectItem` ([931d3](https://github.com/JSQLParser/JSqlParser/commit/931d376ed9adc2a) Andreas Reichel) +- use `Function` and `SelectItem` ([db008](https://github.com/JSQLParser/JSqlParser/commit/db0081d18ba4b19) Andreas Reichel) +- `AllColumns` replace rewrite ([b366f](https://github.com/JSQLParser/JSqlParser/commit/b366f2b0a4e6ab6) Andreas Reichel) +- use proper tokens `..` and `...` in multi-part names for correct white space handling ([38d0e](https://github.com/JSQLParser/JSqlParser/commit/38d0e36e3335dab) Andreas Reichel) +- `AllColumns` replace takes expressions ([a2f40](https://github.com/JSQLParser/JSqlParser/commit/a2f40dd5f79fdef) Andreas Reichel) +- allowing skyline keywords as columns, tables, etc. (#2137) ([f9b1c](https://github.com/JSQLParser/JSqlParser/commit/f9b1cbd8a8e1c8d) nicky6s) + +### Other changes + +**added more stackmemory to compiler** + + +[a3d5f](https://github.com/JSQLParser/JSqlParser/commit/a3d5f908bdc704f) tw *2025-05-04 22:05:13* + +**reintroduced forked compiling** + + +[560e4](https://github.com/JSQLParser/JSqlParser/commit/560e4076f70a97b) tw *2025-05-04 21:43:23* + +**reset to fixed dependency versions** + + +[57941](https://github.com/JSQLParser/JSqlParser/commit/57941c28b320a40) tw *2025-05-04 21:22:16* + +**Add support for TableFunction [WITH OFFSET|ORDINALITY] (#2219)** + +* Add support for TableFunction [WITH OFFSET|ORDINALITY] +* This PR fixes #2218, by adding a new `withClause` to a TableFunction, which allows for support of SQL-99's `UNNEST(...) WITH ORDINALITY` or GoogleSQL's `UNNEST(...) WITH OFFSET`. +* Currently, this is a feeler PR, as I'm getting a test failure, as the output of the parsing differs in my tests: +* ``` +* org.opentest4j.AssertionFailedError: Output from Deparser does not match. ==> +* Expected :select*from unnest(array[1,2,3])with offset as t(a,b) +* Actual :select*from unnest(array[1,2,3])as t(a,b) +* <Click to see difference> +* at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151) +* at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132) +* at org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197) +* at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182) +* at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1156) +* at net.sf.jsqlparser@5.2-SNAPSHOT/net.sf.jsqlparser.test.TestUtils.assertStatementCanBeDeparsedAs(TestUtils.java:126) +* at net.sf.jsqlparser@5.2-SNAPSHOT/net.sf.jsqlparser.test.TestUtils.assertSqlCanBeParsedAndDeparsed(TestUtils.java:99) +* at net.sf.jsqlparser@5.2-SNAPSHOT/net.sf.jsqlparser.test.TestUtils.assertSqlCanBeParsedAndDeparsed(TestUtils.java:85) +* at net.sf.jsqlparser@5.2-SNAPSHOT/net.sf.jsqlparser.statement.select.TableFunctionTest.testTableFunctionWithSupportedWithClauses(TableFunctionTest.java:60) +* at java.base/java.lang.reflect.Method.invoke(Method.java:580) +* at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) +* at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) +* at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) +* at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) +* at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) +* at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) +* at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) +* at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) +* at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) +* at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024) +* at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) +* at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) +* at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) +* at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) +* at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) +* at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) +* at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276) +* at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708) +* at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) +* at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) +* at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) +* at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) +* at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) +* at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) +* at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276) +* at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) +* at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) +* at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) +* at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708) +* at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) +* at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) +* at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) +* at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) +* at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) +* at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) +* at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276) +* at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708) +* at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) +* at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) +* at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) +* at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) +* at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) +* at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) +* ``` +* rename clause -> withClause +* Resolving test failure, and modifying the SelectDeParser to add the withClause where present +* Addressing PR Review comments. Using existing WITH and OFFSET keywords, adding ORDINALITY keyword. +* Removing ORDINALITY from the reserved keywords list in ParserKeywordsUtils, and updating pushing the result of `gradle updateKeywords` +* --------- +* Co-authored-by: David Hayes <dhayes@adobe.com> + +[e5fa0](https://github.com/JSQLParser/JSqlParser/commit/e5fa004cdffdcc8) David Hayes *2025-04-08 09:22:59* + +**fix warning (#2217)** + + +[f7782](https://github.com/JSQLParser/JSqlParser/commit/f77825fb1d736d8) Minjae Lee *2025-04-08 01:43:34* + +**Add MySQL Index Parsing Support for ALTER TABLE Statements (#2215)** + +* add spatial, fulltext index +* add complex spatial index case +* fix Reflection test +* add test case about add index +* fix for passing test + +[090bb](https://github.com/JSQLParser/JSqlParser/commit/090bb60da58c3f4) Minjae Lee *2025-04-04 12:32:44* + +**Add test case for ALTER TABLE with KEY_BLOCK_SIZE (#2213)** + + +[1ffec](https://github.com/JSQLParser/JSqlParser/commit/1ffec41a83eebde) Minjae Lee *2025-04-03 07:22:54* + +**Add support for MySQL ALTER TABLE partition options in parser (#2211)** + + +[98e7b](https://github.com/JSQLParser/JSqlParser/commit/98e7bf6cfeccd86) Minjae Lee *2025-04-02 13:24:31* + +**Add parsing for ALTER TABLE tbl_name {DISABLE | ENABLE} KEYS (#2205)** + + +[1c7c3](https://github.com/JSQLParser/JSqlParser/commit/1c7c3438e14ca9b) Minjae Lee *2025-03-25 06:19:30* + +**Add support for ALTER TABLE ... [DEFAULT] COLLATE [=] collation_name syntax (#2204)** + + +[48d19](https://github.com/JSQLParser/JSqlParser/commit/48d195b1c12d759) Minjae Lee *2025-03-25 03:34:02* + +**Add KeywordOrIdentifier rule to support keywords as identifiers (#2203)** + + +[a068d](https://github.com/JSQLParser/JSqlParser/commit/a068dd4c70661dc) Minjae Lee *2025-03-24 07:45:05* + +**Add support for AllTableColumns in primary expression (#2197)** + + +[9fd3b](https://github.com/JSQLParser/JSqlParser/commit/9fd3b9f305897c6) Tomer Shay *2025-03-21 23:38:45* + +**Add support for parsing MySQL DISCARD and IMPORT TABLESPACE DDL statements (#2198)** + +* Add support for parsing MySQL DISCARD and IMPORT TABLESPACE DDL statements +* fix code formatting +* --------- +* Co-authored-by: mj-db <mj.db@kakaocorp.com> + +[8e651](https://github.com/JSQLParser/JSqlParser/commit/8e651ff232171eb) Minjae Lee *2025-03-20 23:44:30* + +**IsNullExpression and IsBooleanExpression children are not visited in TablesNamesFinder (#2180)** + +* IsNullExpression and IsBooleanExpression children are not visited in TablesNamesFinder + +[ad575](https://github.com/JSQLParser/JSqlParser/commit/ad5758048f06462) SuperPat *2025-03-04 14:07:39* + +**Add more tests to TablesNamesFinderTest for SubqueryAliasesIssue1987 (#2154)** + + +[97005](https://github.com/JSQLParser/JSqlParser/commit/97005cab8d31d12) pinkfloyda *2025-02-07 23:42:36* + +**added support for minus all; except all; intersect all; (#2081)** + +* Co-authored-by: sunanda-vs <22m2107@iitb.ac.in> + +[4492e](https://github.com/JSQLParser/JSqlParser/commit/4492e74fd36f8a4) Sunanda Somwase *2025-02-07 23:42:00* + +**#2119 add support INSERT OVERWRITE PARTITION (#2135)** + +* #2119 add support INSERT OVERWRITE PARTITION +* #2119 fix test case +* #2119 add reserved keyword +* run spotlessApply + +[f1dee](https://github.com/JSQLParser/JSqlParser/commit/f1dee4c43a9a300) tt20061904 *2025-01-06 06:07:23* + + +## jsqlparser-5.1 (2025-01-01) + +### Features + +- allow file names as `Table` supporting CSV or Parquet files ([b2877](https://github.com/JSQLParser/JSqlParser/commit/b287779823e338b) manticore-projects) +- add support MATCH_ANY MATCH_ALL MATCH_PHRASE MATCH_PHRASE_PREFIX MATCH_REGEXP (#2132) ([f6c3c](https://github.com/JSQLParser/JSqlParser/commit/f6c3c7dc2a1b4ff) Liming Deng) +- syntax sugar for table functions ([e8ff9](https://github.com/JSQLParser/JSqlParser/commit/e8ff9fb98d299dc) manticore-projects) +- functions with extra keywords, like BigQuery Timeseries functions ([b0b0f](https://github.com/JSQLParser/JSqlParser/commit/b0b0f4d6178918b) manticore-projects) +- add JSON to the list of data types ([92bbd](https://github.com/JSQLParser/JSqlParser/commit/92bbd90e8755d8d) Andreas Reichel) +- proper `:` JSon operator ([f8080](https://github.com/JSQLParser/JSqlParser/commit/f80800ca5294e89) Andreas Reichel) +- Snowflake `GET` operator `:` ([6eb58](https://github.com/JSQLParser/JSqlParser/commit/6eb588752f0f780) Andreas Reichel) +- `LATERAL VIEW` supports multiple alias columns ([4814c](https://github.com/JSQLParser/JSqlParser/commit/4814ccdd35b4277) Andreas Reichel) +- `ON OVERFLOW` support for the `ListAgg` function (Oracle, DB2) ([5cf28](https://github.com/JSQLParser/JSqlParser/commit/5cf281f1de4f9d3) Andreas Reichel) +- `JsonExpression` supports Expressions rather than Char/Long only ([3d488](https://github.com/JSQLParser/JSqlParser/commit/3d4883523e255e9) Andreas Reichel) +- `CosineSimilarity` Expression ([90adf](https://github.com/JSQLParser/JSqlParser/commit/90adf829153e00f) Andreas Reichel) +- add syntax sugar for accessing name parts easier ([25b08](https://github.com/JSQLParser/JSqlParser/commit/25b08b15e3cc670) manticore-projects) +- add Oracle/H2 `EXPLAIN PLAN [FOR] select` ([d837b](https://github.com/JSQLParser/JSqlParser/commit/d837b677add70ef) manticore-projects) +- add DuckDB `SUMMARIZE table | select` ([ad132](https://github.com/JSQLParser/JSqlParser/commit/ad132ee298d7bfe) manticore-projects) +- methods for returning unquoted names and identifiers ([7e7ac](https://github.com/JSQLParser/JSqlParser/commit/7e7acba1b7d8e54) manticore-projects) +- methods for returning unquoted names and identifiers ([728b2](https://github.com/JSQLParser/JSqlParser/commit/728b286f0948aba) manticore-projects) +- `CREATE SCHEMA IF NOT EXISTS ...` ([d7bf2](https://github.com/JSQLParser/JSqlParser/commit/d7bf249b94c97ff) manticore-projects) +- improve the Expression Visitor Adapter ([e8bc4](https://github.com/JSQLParser/JSqlParser/commit/e8bc4463f907b75) Andreas Reichel) +- improve Visitors ([8a662](https://github.com/JSQLParser/JSqlParser/commit/8a662af8109b650) Andreas Reichel) +- syntax sugar ([13572](https://github.com/JSQLParser/JSqlParser/commit/13572a83b703324) Andreas Reichel) +- improve String representation of `Table` and `Column` ([f3268](https://github.com/JSQLParser/JSqlParser/commit/f3268e73bdd0040) Andreas Reichel) +- improve usability of the `ExpressionVisitorAdapter` ([6a36b](https://github.com/JSQLParser/JSqlParser/commit/6a36b3fc6af5ae1) Andreas Reichel) + +### Bug Fixes + +- rewrite the production to make it comptaible with the Maven build ([785af](https://github.com/JSQLParser/JSqlParser/commit/785af163575f189) manticore-projects) +- [FEATURE] TablesNamesFinder does not support CREATE VIEW #2123 (#2124) ([8f843](https://github.com/JSQLParser/JSqlParser/commit/8f8439e485a412e) Cedric Dandoy) +- De-parse `TableFunction` ([e122b](https://github.com/JSQLParser/JSqlParser/commit/e122bcf7d7a01cf) manticore-projects) +- Alias of the ParenthesedSelect when FromItem is a TableFunction ([46919](https://github.com/JSQLParser/JSqlParser/commit/469190d03709254) manticore-projects) +- JSon functions with Column parameters ([82251](https://github.com/JSQLParser/JSqlParser/commit/822517899546f19) Andreas Reichel) +- Issue #2109 true and false value parsed as column instead of BooleanValue (#2110) ([7acf9](https://github.com/JSQLParser/JSqlParser/commit/7acf9d548edc854) lucarota) +- `CREATE TABLE` UNIQUE vs. UNIQUE KEY ([3030c](https://github.com/JSQLParser/JSqlParser/commit/3030c35d28ad3cf) Andreas Reichel) +- clean up minor issues around #2083 ([be8ff](https://github.com/JSQLParser/JSqlParser/commit/be8ff930ebc4fa0) Andreas Reichel) +- avoid NPE ([db4b0](https://github.com/JSQLParser/JSqlParser/commit/db4b04dd0b8ce28) manticore-projects) +- fix the Grammar so it builds with Maven ([d3d3a](https://github.com/JSQLParser/JSqlParser/commit/d3d3af9b5974fb5) manticore-projects) +- `TableNameFinder` for `Alter Table` ([33ba5](https://github.com/JSQLParser/JSqlParser/commit/33ba5eb521c4dae) manticore-projects) +- remove obsolete `SimpleFunction` ([cd068](https://github.com/JSQLParser/JSqlParser/commit/cd0689e0120fc8e) manticore-projects) +- license headers ([e842e](https://github.com/JSQLParser/JSqlParser/commit/e842e18511c65f5) Andreas Reichel) +- add needed LOOKAHEAD(2) ([421e2](https://github.com/JSQLParser/JSqlParser/commit/421e2894b226018) Andreas Reichel) +- TablesNamesFinder `UpdateSets` ([11ceb](https://github.com/JSQLParser/JSqlParser/commit/11cebcfd1220944) Andreas Reichel) +- Multi-Variable `LambdaExpression` ([e0ad7](https://github.com/JSQLParser/JSqlParser/commit/e0ad7c84b688c39) Andreas Reichel) +- `FromItem` alias must not shade an actual table (found before) ([d8207](https://github.com/JSQLParser/JSqlParser/commit/d8207aaf616f10e) Andreas Reichel) + +### Other changes + +**added one license header** + + +[5d1ef](https://github.com/JSQLParser/JSqlParser/commit/5d1efcee13e8351) tw *2024-12-31 00:37:47* + +**try working around github build issues** + + +[1ad52](https://github.com/JSQLParser/JSqlParser/commit/1ad52ff42cdf25f) manticore-projects *2024-12-30 13:02:38* + +**Update gradle wrapper** + + +[4ad00](https://github.com/JSQLParser/JSqlParser/commit/4ad0068e9a6b504) manticore-projects *2024-12-30 12:54:15* + +**Fix null exception in ExpressionVisitorAdapter with simple INTERVAL expression (#2133)** + + +[d9acb](https://github.com/JSQLParser/JSqlParser/commit/d9acb5f4a6a878a) Tomer Shay *2024-12-28 09:59:22* + +**add support for MATERIALIZED in WITH clause (#2128)** + + +[39004](https://github.com/JSQLParser/JSqlParser/commit/39004642b55ceac) Tomer Shay *2024-12-23 05:35:38* + +**feat mysql alter force,engine,algorithm,lock (#2121)** + +* Co-authored-by: mj-db <mj.db@kakaocorp.com> + +[18c1a](https://github.com/JSQLParser/JSqlParser/commit/18c1a2c63d9719b) Minjae Lee *2024-12-09 09:09:37* + +**increase gradle build memory** + + +[7ed3c](https://github.com/JSQLParser/JSqlParser/commit/7ed3ce92ce25f5c) Andreas Reichel *2024-11-26 06:18:28* + +**update Gradle wrapper** + + +[d5af1](https://github.com/JSQLParser/JSqlParser/commit/d5af1f1cf93d0ca) Andreas Reichel *2024-11-26 06:06:42* + +**Fix issue 2089: Enhance MySQL CONVERT Statement Parsing (#2117)** + +* fix convert toString +* fix mysql convert +* --------- +* Co-authored-by: mj-db <mj.db@kakaocorp.com> + +[8b414](https://github.com/JSQLParser/JSqlParser/commit/8b4149b3b7e9a35) Minjae Lee *2024-11-26 05:55:37* + +**Fix issue 2106: Add parsing functionality for MySQL ALTER Table option statements (#2115)** + +* add alter table option +* fix CreateParameter by adding auto_increment for passing test +* fix by updatekeywords +* test add assertSqlCanBeParsedAndDeparsed +* --------- +* Co-authored-by: mj-db <mj.db@kakaocorp.com> + +[fee2f](https://github.com/JSQLParser/JSqlParser/commit/fee2f90c0283b3e) Minjae Lee *2024-11-24 00:46:00* + +**Fix issue 2106: Add parsing functionality for MySQL ADD PARTITION and DROP PARTITION clauses in ALTER TABLE statements(2) (#2108)** + +* feat MySQL Alter add partition +* fix PartitionDefinition to Serializable +* add Engine variable to MySQL partition definition +* fix: Update parser to correctly handle ENGINE token and pass existing CREATE TABLE tests +* feat mysql alter drop partition +* refactor truncate partition +* fix codacy +* fix: add LOOKAHEADs +* Signed-off-by: Andreas Reichel <andreas@manticore-projects.com> +* doc: mention running `gradle check` +* Signed-off-by: Andreas Reichel <andreas@manticore-projects.com> +* style: add license header +* Signed-off-by: Andreas Reichel <andreas@manticore-projects.com> +* --------- +* Signed-off-by: Andreas Reichel <andreas@manticore-projects.com> +* Co-authored-by: mj-db <mj.db@kakaocorp.com> +* Co-authored-by: Andreas Reichel <andreas@manticore-projects.com> + +[12952](https://github.com/JSQLParser/JSqlParser/commit/12952d64f87bdef) Minjae Lee *2024-11-14 01:05:19* + +**Fix issue 2106: Add parsing functionality for MySQL `ADD PARTITION` and `DROP PARTITION` clauses in `ALTER TABLE` statements (#2107)** + +* feat MySQL Alter add partition +* fix PartitionDefinition to Serializable +* --------- +* Co-authored-by: mj-db <mj.db@kakaocorp.com> + +[7b0e4](https://github.com/JSQLParser/JSqlParser/commit/7b0e42f60a60153) Minjae Lee *2024-11-12 12:05:28* + +**Add parsing functionality for MySQL CONVERT TO statement (#2097)** + +* Co-authored-by: mj-db <mj.db@kakaocorp.com> + +[dc123](https://github.com/JSQLParser/JSqlParser/commit/dc123820f869803) Minjae Lee *2024-10-25 15:33:05* + +**Fix issue 2090: Correctly parse LOCK clause in ALTER TABLE statements (#2095)** + +* Add support for parsing LOCK clause in ALTER TABLE statements +* fix code formatting +* --------- +* Co-authored-by: mj-db <mj.db@kakaocorp.com> + +[f3f6b](https://github.com/JSQLParser/JSqlParser/commit/f3f6b72731d5c92) Minjae Lee *2024-10-24 12:20:58* + +**Fix parsing `ALTER TABLE ... ADD COLUMNS (...)` (#2087)** + +* The current behaviour fails when it encounters `ADD COLUMNS` and merges +* everything in the `()` into one string with no whitespace. +* So `ALTER TABLE catalog.table.name ADD COLUMNS (apples int)` becomes +* `ALTER TABLE catalog.table.name ADD COLUMNS (applesint)`. +* This commit adds an understanding of how `ADD COLUMNS` to the grammar. + +[22909](https://github.com/JSQLParser/JSqlParser/commit/229099c74b92845) Nathan Jaremko *2024-10-24 01:11:46* + +**Failure to parse query with PRIOR in select list (#2083)** + +* Added support for PRIOR operator to be used in select list +* Fixed copy paste issue + +[30469](https://github.com/JSQLParser/JSqlParser/commit/30469248935ecb9) hannes92 *2024-10-02 23:57:04* + +**Skyline syntax (preferring clause) (#2078)** + +* feat: Implement skyline syntax (preferring clause) +* fix: Fix codacy errors +* style: Execute :spotlessApply +* fix: Remove unused import +* refactor: Replace wildcard imports +* refactor: Remove redundant imports +* --------- +* Co-authored-by: Stefan Steinhauser <stefan.steinhauser@arz.at> + +[d1373](https://github.com/JSQLParser/JSqlParser/commit/d1373c5f7048224) Stefan Steinhauser *2024-09-17 09:31:32* + +**Unparenthesized `SubSelect` as `FromItem` (#2073)** + +* feat: Implement FromItem in Select +* Implement FromItem interface in Select to allow Select being an unparenthesized FromItem +* Refs: JSQLParser/JSqlParser#2071 +* feat: Implement grammar to support Select as FromItem +* Refs: JSQLParser/JSqlParser#2071 +* style: Run gradle :spotlessApply +* style: Run gradle :spotlessApply +* --------- +* Co-authored-by: Stefan Steinhauser <stefan.steinhauser@arz.at> + +[60f4d](https://github.com/JSQLParser/JSqlParser/commit/60f4d74f7d8d500) Stefan Steinhauser *2024-09-10 10:49:49* + +**Create dependabot.yml** + + +[27969](https://github.com/JSQLParser/JSqlParser/commit/27969defdcea4d9) manticore-projects *2024-09-06 05:22:17* + +**** + + +[340d8](https://github.com/JSQLParser/JSqlParser/commit/340d855db9b36e3) Tobias Warneke *2024-08-20 21:01:45* + +**Exasol support (#2046)** + +* feat: Support REGEXP_LIKE as LikeExpression +* Implement support of REGEXP_LIKE as LikeExpression as described here: https://docs.exasol.com/db/latest/sql_references/predicates/not_regexp_like.htm +* feat: Support sub select as part of function parameters +* Allow unparenthesesed sub selects being part of multiple function parameters +* fix: Readd mistakenly removed K_TEXT_LITERAL +* revert: Revert code formatting changes +* fix: Fix choice conflicts +* refactor: Rename test methods +* refactor: Apply on changed files +* feat: Introduce allowUnparenthesizedSubSelects feature +* refactor: Apply formatApply +* test: add test for the standard grammar, expected to fail +* test: make the performance tests more robust regarding the time-outs +* style: reformat code +* Signed-off-by: Andreas Reichel <andreas@manticore-projects.com> +* fix: Revert default keyword changes +* fix: Revert default keyword changes +* --------- +* Signed-off-by: Andreas Reichel <andreas@manticore-projects.com> +* Co-authored-by: Stefan Steinhauser <stefan.steinhauser@arz.at> +* Co-authored-by: Andreas Reichel <andreas@manticore-projects.com> + +[93ca6](https://github.com/JSQLParser/JSqlParser/commit/93ca6610425fc8a) Stefan Steinhauser *2024-08-20 08:16:27* + +**chore removing system.out.println lines + minor clean up of unit test scripts (#2060)** + +* chore removing system.out.println lines + minor clean up +* formatting fixes via spotlessApply + +[11616](https://github.com/JSQLParser/JSqlParser/commit/11616a0206ed7c5) nicky6s *2024-08-19 07:50:32* + +**feature/fix: parsing inserts/updates/delete within CTEs (#2055)** + +* feature parsing inserts/updates/delete within CTEs +* removing System lines +* fixing codacy issues +* reducing the looping in NestedBracketsPerformanceTest to just 6 +* formatting fixes via spotlessApply + +[82470](https://github.com/JSQLParser/JSqlParser/commit/82470e55aaf9157) nicky6s *2024-08-04 16:45:56* + +**chore adding extra details to unit test scenarios (#2051)** + +* chore adding extra details to unit test scenarios +* addressing review comments + +[21c60](https://github.com/JSQLParser/JSqlParser/commit/21c605e3e2f5f52) nicky6s *2024-07-31 19:19:08* + +**fix insert default values statements not parsing (#2050)** + + +[dc14c](https://github.com/JSQLParser/JSqlParser/commit/dc14c4b4e1401f4) nicky6s *2024-07-27 18:53:54* + +**fix truncate parsing to capture multiple tables (#2048)** + +* fix truncate parsing to capture multiple tables +* followup fixes including adding a lookahead +* replacng tabs with spaces +* increasing lookahead +* fixing after getting maven working locally + +[aca82](https://github.com/JSQLParser/JSqlParser/commit/aca82f5926b2e95) Nick Redfearn *2024-07-26 11:52:27* + +**Resolve parsing error for CHARACTER SET and COLLATE in MySQL ALTER TABLE (issue 2027) (#2045)** + +* fix: parsing alter text character set +* style: remove unnecessary comment +* fix: TEXT as a data type token +* --------- +* Co-authored-by: mj-db <mj.db@kakaocorp.com> + +[93c82](https://github.com/JSQLParser/JSqlParser/commit/93c8210e218d7f5) Minjae Lee *2024-07-23 02:27:05* + +**Avoid private tokens to be white listed and allow any word character in token value (#2044)** + +* fix: Avoid private tokens to be white listed +* Closes JSQLParser/JSqlParser#2040 +* feat: Allow all word characters as token value +* Closes JSQLParser/JSqlParser#2041 +* --------- +* Co-authored-by: Stefan Steinhauser <stefan.steinhauser@arz.at> + +[821e9](https://github.com/JSQLParser/JSqlParser/commit/821e92e8fb6e48e) Stefan Steinhauser *2024-07-20 10:35:47* + + +## jsqlparser-5.0 (2024-06-30) + +### Breaking changes + +- Visitors return Objects and accept parameters ([5bd28](https://github.com/JSQLParser/JSqlParser/commit/5bd28c8b309df6c) Andreas Reichel) +- Visitors return Objects ([131a9](https://github.com/JSQLParser/JSqlParser/commit/131a988ccea2d91) Andreas Reichel) +- Visitors return Objects ([c2328](https://github.com/JSQLParser/JSqlParser/commit/c2328120e7a79ff) Andreas Reichel) +- Visitors return Objects ([ec497](https://github.com/JSQLParser/JSqlParser/commit/ec49762708e920a) Andreas Reichel) +- Visitors return Objects ([681ca](https://github.com/JSQLParser/JSqlParser/commit/681cac933d83516) Andreas Reichel) + +### Features + +- provide compatibility methods ([3f995](https://github.com/JSQLParser/JSqlParser/commit/3f99548b99bbfe3) Andreas Reichel) +- apply the new parametrized Visitor patterns to all entities and provide default implementations ([e1692](https://github.com/JSQLParser/JSqlParser/commit/e1692990c543ed1) Andreas Reichel) +- syntax sugar ([2fce4](https://github.com/JSQLParser/JSqlParser/commit/2fce4c009b77d85) Andreas Reichel) +- Visitors return Objects and accept parameters ([5bd28](https://github.com/JSQLParser/JSqlParser/commit/5bd28c8b309df6c) Andreas Reichel) +- Visitors return Objects ([131a9](https://github.com/JSQLParser/JSqlParser/commit/131a988ccea2d91) Andreas Reichel) +- Visitors return Objects ([c2328](https://github.com/JSQLParser/JSqlParser/commit/c2328120e7a79ff) Andreas Reichel) +- Visitors return Objects ([ec497](https://github.com/JSQLParser/JSqlParser/commit/ec49762708e920a) Andreas Reichel) +- Visitors return Objects ([681ca](https://github.com/JSQLParser/JSqlParser/commit/681cac933d83516) Andreas Reichel) +- Allow OUTER keyword as function parameter name (#2021) ([fc90c](https://github.com/JSQLParser/JSqlParser/commit/fc90c0b5e566533) Chris Crabtree) +- BigQuery `SELECT AS STRUCT ...` and `SELECT AS VALUE ...` ([5c360](https://github.com/JSQLParser/JSqlParser/commit/5c360a2fc95c261) Andreas Reichel) +- add syntax sugar ([2ace7](https://github.com/JSQLParser/JSqlParser/commit/2ace74d1047e87d) Andreas Reichel) +- `AllColumns`, DuckDB uses `EXCLUDE` instead of `EXCEPT` ([1ad42](https://github.com/JSQLParser/JSqlParser/commit/1ad4234280f7a70) Andreas Reichel) +- syntax sugar ([ae1ef](https://github.com/JSQLParser/JSqlParser/commit/ae1eff9f7434c08) Andreas Reichel) +- syntax sugar ([81846](https://github.com/JSQLParser/JSqlParser/commit/818464c93ae665a) Andreas Reichel) +- syntax sugar ([2cb3e](https://github.com/JSQLParser/JSqlParser/commit/2cb3e589b60e192) Andreas Reichel) +- syntax sugar ([b2eed](https://github.com/JSQLParser/JSqlParser/commit/b2eed1e910c97de) Andreas Reichel) +- Databricks IGNORE/RESPECT NULLS ([e9c9a](https://github.com/JSQLParser/JSqlParser/commit/e9c9a173a660bbe) Andreas Reichel) +- Databricks IGNORE/RESPECT NULLS ([544b1](https://github.com/JSQLParser/JSqlParser/commit/544b1683789f20b) Andreas Reichel) +- Capture expression name part delimiters (#2001) ([0368b](https://github.com/JSQLParser/JSqlParser/commit/0368b9ebad76742) Chris Crabtree) +- syntax sugar ([ca5c5](https://github.com/JSQLParser/JSqlParser/commit/ca5c553efde37eb) Andreas Reichel) +- translate HEX to Unicode String and ByteArray String ([df519](https://github.com/JSQLParser/JSqlParser/commit/df519333ff34740) Andreas Reichel) +- `StructType` syntax sugar ([6e9bf](https://github.com/JSQLParser/JSqlParser/commit/6e9bf42b0b2d783) Andreas Reichel) +- `Values` implement `FromItem` ([e426c](https://github.com/JSQLParser/JSqlParser/commit/e426c5a67c505b5) Andreas Reichel) +- add `ParenthesedSelect` delegate ([66d05](https://github.com/JSQLParser/JSqlParser/commit/66d05a2bb7c41f3) Andreas Reichel) +- add `ParenthesedSelect` delegate ([f1699](https://github.com/JSQLParser/JSqlParser/commit/f16999393589702) Andreas Reichel) +- Simplify traversing the AST bottom to top ([bddc4](https://github.com/JSQLParser/JSqlParser/commit/bddc41cddf5b5bf) Andreas Reichel) +- AST Node access for `FromItem` ([c1edf](https://github.com/JSQLParser/JSqlParser/commit/c1edf0f8f21bd52) Andreas Reichel) +- RedShift specific Window function IGNORE | RESPECT NULLS ([321c8](https://github.com/JSQLParser/JSqlParser/commit/321c88098a75791) Andreas Reichel) +- RedShift allows `TOP` before `DISTINCT`, see https://docs.aws.amazon.com/redshift/latest/dg/r_SELECT_list.html ([13e61](https://github.com/JSQLParser/JSqlParser/commit/13e61a726a87c2f) Andreas Reichel) +- Redshift `APPROXIMATE` Aggregate functions ([e4ece](https://github.com/JSQLParser/JSqlParser/commit/e4ece0c3ecd7ce3) Andreas Reichel) +- add `CCJSqlParserUtil.sanitizeSingleSql(String sqlStr)` to help MyBatikPlus users to clean their statements ([1606e](https://github.com/JSQLParser/JSqlParser/commit/1606e5f0492a485) Andreas Reichel) +- return any `UnsupportedStatement` content ([063d2](https://github.com/JSQLParser/JSqlParser/commit/063d2442d82f920) Andreas Reichel) +- re-enable `UnsupportedStatement` ([82b45](https://github.com/JSQLParser/JSqlParser/commit/82b459bfcd23851) Andreas Reichel) +- better statement error recovery ([b3d3a](https://github.com/JSQLParser/JSqlParser/commit/b3d3a8e492f74a8) Andreas Reichel) +- Syntax Sugar for the parser features ([1d943](https://github.com/JSQLParser/JSqlParser/commit/1d9438e7ef1a86f) Andreas Reichel) +- allow `EXTRACT` to be parsed as regular function also ([b85dc](https://github.com/JSQLParser/JSqlParser/commit/b85dc2fd0004652) Andreas Reichel) +- syntax sugar ([a3858](https://github.com/JSQLParser/JSqlParser/commit/a38581acd538d95) Andreas Reichel) +- syntax sugar ([df7c7](https://github.com/JSQLParser/JSqlParser/commit/df7c792184c61a6) Andreas Reichel) +- Syntax sugar ([67bfa](https://github.com/JSQLParser/JSqlParser/commit/67bfae673421d7c) Andreas Reichel) +- syntax sugar ([b0317](https://github.com/JSQLParser/JSqlParser/commit/b03170e180175b1) Andreas Reichel) +- syntax sugar ([57a29](https://github.com/JSQLParser/JSqlParser/commit/57a296b2c8c5bb0) Andreas Reichel) +- remove Aliases of `ParenthesedSelect`, `LateralSubSelect` and `ParenthesedFromItem` from the Table Names ([46682](https://github.com/JSQLParser/JSqlParser/commit/466826b9b115cb7) Andreas Reichel) +- better access to the `DataType` checks ([edeaf](https://github.com/JSQLParser/JSqlParser/commit/edeafc311c2ab7e) Andreas Reichel) +- Add Data Type information to task for making it easy to understand the expected return type ([31c55](https://github.com/JSQLParser/JSqlParser/commit/31c5533f49776c6) Andreas Reichel) +- Implicit Casts `SELECT DOUBLE PRECISION '1'` ([411a3](https://github.com/JSQLParser/JSqlParser/commit/411a3da9facf206) Andreas Reichel) +- Function Column Aliases without an Alias Name `func(x) (a, b, c)` ([b4ef7](https://github.com/JSQLParser/JSqlParser/commit/b4ef763614bf3a4) Andreas Reichel) +- Support BigQuery specific Aggregate clauses ([0179c](https://github.com/JSQLParser/JSqlParser/commit/0179cc0cac9ceeb) Andreas Reichel) +- syntax sugar for Binary Expressions like Conact, Addition, Multiplication ([ffdde](https://github.com/JSQLParser/JSqlParser/commit/ffddeef7199a056) Andreas Reichel) +- Hex to Long conversion ([620db](https://github.com/JSQLParser/JSqlParser/commit/620db709e48c22e) Andreas Reichel) +- syntax sugar for Expressions ([a5693](https://github.com/JSQLParser/JSqlParser/commit/a56934da1d3a7ae) Andreas Reichel) +- Salesforce SOQL `INCLUDES` and `EXCLUDES` operators (#1985) ([f3f0e](https://github.com/JSQLParser/JSqlParser/commit/f3f0e051358a493) lucarota) +- Google BigQuery `CAST` with `FORMAT` clause ([0d813](https://github.com/JSQLParser/JSqlParser/commit/0d813f03faa2b3b) Andreas Reichel) +- DuckDB Lambda Functions ([23679](https://github.com/JSQLParser/JSqlParser/commit/236793aaeabc30f) Andreas Reichel) +- DuckDB `STRUCT` with curly brackets and explicit Column Type Cast ([1cd57](https://github.com/JSQLParser/JSqlParser/commit/1cd576b32c774e8) Andreas Reichel) +- `RECURSIVE` does not need to be a reserved ([5cb4c](https://github.com/JSQLParser/JSqlParser/commit/5cb4c55067f4fe2) Andreas Reichel) +- DuckDB `STRUCT` with curly brackets ([339d6](https://github.com/JSQLParser/JSqlParser/commit/339d6baece2c199) Andreas Reichel) +- BigQuery `STRUCT` data types and literal ([4c187](https://github.com/JSQLParser/JSqlParser/commit/4c187d51055a3d8) Andreas Reichel) +- TablesNamesFinder can return also references to WITH items ([9d645](https://github.com/JSQLParser/JSqlParser/commit/9d64511239a4514) Andreas Reichel) +- allow double-quoted `DateTimeLiteral` like `DATETIME "2005-01-03 12:34:56"` ([f6790](https://github.com/JSQLParser/JSqlParser/commit/f6790913b754850) Andreas Reichel) +- support `DATETIME` literal used for Google BigQuery ([a386d](https://github.com/JSQLParser/JSqlParser/commit/a386d297c418921) Andreas Reichel) +- link `TOP` to AST node ([79c42](https://github.com/JSQLParser/JSqlParser/commit/79c42ed31eb6986) Andreas Reichel) + +### Bug Fixes + +- `AllTableColumns`, DuckDB specific `EXCLUDE` ([c9ecf](https://github.com/JSQLParser/JSqlParser/commit/c9ecfc6ddbdd139) Andreas Reichel) +- `AllColumns` Replacement shall be about Columns only ([f4b40](https://github.com/JSQLParser/JSqlParser/commit/f4b40e43a4f8d3d) Andreas Reichel) +- `FromItem` with Alias without `AS` keyword ([5f580](https://github.com/JSQLParser/JSqlParser/commit/5f580af190c6fbb) Andreas Reichel) +- set `stringValue` in `DoubleValue.setValue` (#2009) ([e07f8](https://github.com/JSQLParser/JSqlParser/commit/e07f8d019ddf38d) Damian) +- try working around `UnsupportedStatement` issue ([fbe97](https://github.com/JSQLParser/JSqlParser/commit/fbe97a8deb84ae9) Andreas Reichel) +- allow `BASE64` keyword ([7daf7](https://github.com/JSQLParser/JSqlParser/commit/7daf7af36d825f7) Andreas Reichel) +- `StructType` expressions must use Visitor instead of `toString()` ([b95d8](https://github.com/JSQLParser/JSqlParser/commit/b95d8e3e4ee01b0) Andreas Reichel) +- `AnyComparisionItem` with extra brackets ([4e1a1](https://github.com/JSQLParser/JSqlParser/commit/4e1a1535f4ef706) Andreas Reichel) +- `FOR UPDATE` clause should come after the select body ([cf7fe](https://github.com/JSQLParser/JSqlParser/commit/cf7fe157de372f3) Andreas Reichel) +- initialise the `SelectDeparser` with an `ExpressionDeparser` (but not with an empty Adaptor only) ([f417c](https://github.com/JSQLParser/JSqlParser/commit/f417c8f248c7bb1) Andreas Reichel) +- `ALTER ...` shall `captureRest()` only to the next statement terminator ([15d14](https://github.com/JSQLParser/JSqlParser/commit/15d14ab0b9dcadf) Andreas Reichel) +- correct the wrong Assertion ([8461e](https://github.com/JSQLParser/JSqlParser/commit/8461e8ad1a3f5e3) Andreas Reichel) +- don't insert space after certain punctuation ([159c2](https://github.com/JSQLParser/JSqlParser/commit/159c28ee8f68cab) Andreas Reichel) +- treat Array Brackets `[..]` as syntax characters and surround by space when normalizing for comparison ([c9d1e](https://github.com/JSQLParser/JSqlParser/commit/c9d1eaefca91c6e) Andreas Reichel) +- `REGEXP` does not need to be reserved ([f6524](https://github.com/JSQLParser/JSqlParser/commit/f65240f381f9855) Andreas Reichel) +- `REGEXP` does not need to be reserved ([a9e67](https://github.com/JSQLParser/JSqlParser/commit/a9e67667b9c1590) Andreas Reichel) +- Array Arguments without `ARRAY` keyword ([0f9a8](https://github.com/JSQLParser/JSqlParser/commit/0f9a8ec02786f5d) Andreas Reichel) +- Function with Array Arguments ([f782e](https://github.com/JSQLParser/JSqlParser/commit/f782eda7afa17d3) Andreas Reichel) +- parsing `SelectItem` shall support `Xor` ([c8839](https://github.com/JSQLParser/JSqlParser/commit/c883920a1175ffc) Andreas Reichel) + +### Other changes + +**switched to version 5.0-SNAPSHOT** + + +[275e0](https://github.com/JSQLParser/JSqlParser/commit/275e0c0627bb8a2) Tobias Warneke *2024-06-30 20:26:08* + +**corrected license header** + + +[5fb9f](https://github.com/JSQLParser/JSqlParser/commit/5fb9f568684ace1) Tobias Warneke *2024-06-30 20:21:47* + +**corrected license header** + + +[456d5](https://github.com/JSQLParser/JSqlParser/commit/456d53b09c48f77) Tobias Warneke *2024-06-30 20:02:41* + +**support custom DeParser (#2013)** + + +[74793](https://github.com/JSQLParser/JSqlParser/commit/7479342dd95125a) Redkale *2024-05-29 06:02:40* + +**Add missing java.sql require (#1999)** + +* Add missing java.sql +* Update maven checkstyle +* Fix gradle checkstyle +* Bump surefire plugin +* Skip modules in tests + +[df48c](https://github.com/JSQLParser/JSqlParser/commit/df48c4ba5b2b44f) Ethan McCue *2024-04-30 05:13:54* + +**Add module info (#1998)** + +* Add module info +* Trailing newline + +[761b4](https://github.com/JSQLParser/JSqlParser/commit/761b45b2f6c4b81) Ethan McCue *2024-04-30 04:36:41* + +**** + + +[89ac0](https://github.com/JSQLParser/JSqlParser/commit/89ac0fc3c0af712) Tobias Warneke *2024-03-09 22:12:33* + + +## jsqlparser-4.9 (2024-03-09) + +### Features + +- add DB2 special register `CURRENT TIMEZONE` ([c412d](https://github.com/JSQLParser/JSqlParser/commit/c412d6a52f9b2ea) Andreas Reichel) +- add additional CREATE VIEW modifiers (#1964) ([67e22](https://github.com/JSQLParser/JSqlParser/commit/67e220425f24148) David Goss) +- with no log (#1953) ([d9c44](https://github.com/JSQLParser/JSqlParser/commit/d9c44499d096b1f) mjh) +- support keyword "only" for postgresql (#1952) ([f1676](https://github.com/JSQLParser/JSqlParser/commit/f1676dd992911d9) 猫屎咖啡) +- support any number/order of merge operations (#1938) ([f1c52](https://github.com/JSQLParser/JSqlParser/commit/f1c525a1eaf3087) David Goss) + +### Bug Fixes + +- chained function calls of `SimpleFunction` ([98055](https://github.com/JSQLParser/JSqlParser/commit/9805581accf89d2) Andreas Reichel) +- issue #1948 `Between` with expression ([b9453](https://github.com/JSQLParser/JSqlParser/commit/b9453f228adf9ad) Andreas Reichel) +- return NULL when parsing empty Strings ([94fb8](https://github.com/JSQLParser/JSqlParser/commit/94fb87237f36cce) Andreas Reichel) +- allow Parameters like `$1`,`$2` ([17f5f](https://github.com/JSQLParser/JSqlParser/commit/17f5f2ad680dfdb) Andreas Reichel) +- allow `DATA` as `ColumnType()` keyword ([72a51](https://github.com/JSQLParser/JSqlParser/commit/72a51e58413a291) Andreas Reichel) +- make analytic expression visitor null-safe (#1944) ([768c6](https://github.com/JSQLParser/JSqlParser/commit/768c63f4660509b) David Goss) +- Fixes parsing failing for ALTER MODIFY queries not containing datatype (#1961) ([029fd](https://github.com/JSQLParser/JSqlParser/commit/029fd42e84e65ee) Tanish Grover) +- tables not find in parentheses join sql. (#1956) ([182f4](https://github.com/JSQLParser/JSqlParser/commit/182f484dc43945b) hancher) +- issue1875 (#1957) ([98aa9](https://github.com/JSQLParser/JSqlParser/commit/98aa90cb988580a) mjh) +- ExpressionVisitor.visit(AllTableColumns) method isn't being called. (#1942) ([bc166](https://github.com/JSQLParser/JSqlParser/commit/bc16618eaa8fd93) Brian S. O'Neill) + +### Other changes + +**** + + +[2319d](https://github.com/JSQLParser/JSqlParser/commit/2319da81bb27f4e) Tobias Warneke *2024-03-09 20:49:14* + +**Handle select in ExpressionVisitorAdapter (#1972)** + + +[424a8](https://github.com/JSQLParser/JSqlParser/commit/424a852ac8071d7) Kaartic Sivaraam *2024-02-23 23:32:07* + +**Update README.md** + +* Fixes #1968 + +[8dcfb](https://github.com/JSQLParser/JSqlParser/commit/8dcfb4a3bf5682d) manticore-projects *2024-02-17 12:03:43* + +**Guard Values against null/empty values (#1965)** + +* Guard Values against null/empty values +* The classes modified by this commit are `DoubleValue`, `LongValue`, and +* `TimeValue`. Both `null` and empty strings provided to their +* constructors fail, but they provide very different error messages +* (NullPointerException and StringIndexOutOfBoundsException), which is +* neither sensible nor helpful in debugging. +* This commit adds a guard to throw `IllegalArgumentException` for both +* cases in order to improve coherency and usefulness of the error +* messages. +* fix checkstyle issues + +[b0032](https://github.com/JSQLParser/JSqlParser/commit/b00322efa0c77d2) Heewon Lee *2024-02-14 07:34:40* + +**support oracle alter table truncate partition (#1954)** + +* feat: oracle alter table truncate partition +* feat: oracle alter table truncate partition +* feat: code format +* feat: code format +* --------- +* Co-authored-by: mjh <majh118@chinaunicom.cn> + +[cc7aa](https://github.com/JSQLParser/JSqlParser/commit/cc7aa01913a7201) mjh *2024-02-04 07:19:19* + +**Build with Automatic-Module-Name for compatibility with the Java module system. (#1941)** + + +[92e02](https://github.com/JSQLParser/JSqlParser/commit/92e02c6da69d917) Brian S. O'Neill *2024-01-06 14:04:45* + +**Create maven_deploy.yml** + + +[b4070](https://github.com/JSQLParser/JSqlParser/commit/b40705785751b49) Tobias *2023-12-28 22:31:54* + +**corrected hopefully maven snapshot deployment** + + +[a70f0](https://github.com/JSQLParser/JSqlParser/commit/a70f0d1f3f3d91e) Tobias Warneke *2023-12-28 22:20:08* + +**corrected hopefully maven snapshot deployment** + + +[f0d3a](https://github.com/JSQLParser/JSqlParser/commit/f0d3ab6b42193ae) Tobias Warneke *2023-12-28 22:17:43* + +**finally done** + + +[6c1ca](https://github.com/JSQLParser/JSqlParser/commit/6c1caff118f84bd) Tobias Warneke *2023-12-28 00:29:26* + + +## jsqlparser-4.8 (2023-12-28) + +### Features + +- support mysql with rollup (#1923) ([77f6f](https://github.com/JSQLParser/JSqlParser/commit/77f6fb8c92b3378) jxnu-liguobin) +- Support `FOR SHARE` (#1922) ([815f8](https://github.com/JSQLParser/JSqlParser/commit/815f8753d552d89) jxnu-liguobin) +- [MySQL] Support `TABLE STATEMENT` (#1921) ([313a4](https://github.com/JSQLParser/JSqlParser/commit/313a4b42444b2d2) jxnu-liguobin) +- Support `RENAME INDEX` for MySQL, `RENAME CONSTRAINT` for PostgreSQL (#1920) ([989a8](https://github.com/JSQLParser/JSqlParser/commit/989a84bb215283b) jxnu-liguobin) +- Add support comment in `create view` for MySQL and MariaDb (#1913) ([4d47e](https://github.com/JSQLParser/JSqlParser/commit/4d47e0ab7bc2872) jxnu-liguobin) +- Add support for `REFRESH MATERIALIZED VIEW` (#1911) ([425c7](https://github.com/JSQLParser/JSqlParser/commit/425c72eb7d7f931) jxnu-liguobin) +- `SimpleFunction` for faster parsing of simple, but deep nested functions ([085d7](https://github.com/JSQLParser/JSqlParser/commit/085d7504235e58c) Andreas Reichel) +- add support for snowflake merge statements (#1887) ([36b80](https://github.com/JSQLParser/JSqlParser/commit/36b806dede06260) David Goss) +- `ColDataType` supports `PUBLIC` schema and all non-restricted keywords for type ([1088d](https://github.com/JSQLParser/JSqlParser/commit/1088db7aea0b2f9) Andreas Reichel) +- T-SQL Join Hints ([5f09e](https://github.com/JSQLParser/JSqlParser/commit/5f09ec4914fbdd1) Andreas Reichel) +- old TSQL Joins `*=` and `=*` ([0b50d](https://github.com/JSQLParser/JSqlParser/commit/0b50da4cca555b6) Andreas Reichel) +- MS SQL Server `Merge` `Output` clause ([7bd42](https://github.com/JSQLParser/JSqlParser/commit/7bd42edaa0d9aed) Andreas Reichel) +- MS SQL Server `UPDATE ...` Index Hint ([f919e](https://github.com/JSQLParser/JSqlParser/commit/f919e00c30ff5df) Andreas Reichel) +- Postgres `Contains` and `ContainedBy` Operators ([28a4c](https://github.com/JSQLParser/JSqlParser/commit/28a4c080b718aba) Andreas Reichel) +- Postgres `Contains` and `ContainedBy` Operators ([09d6d](https://github.com/JSQLParser/JSqlParser/commit/09d6dfe7bc7acb8) Andreas Reichel) +- Clickhouse `GLOBAL IN ...` ([ced0d](https://github.com/JSQLParser/JSqlParser/commit/ced0d0090c5c9a9) Andreas Reichel) +- `CREATE INDEX IF NOT EXISTS...` ([da13d](https://github.com/JSQLParser/JSqlParser/commit/da13d7dc1dd1608) Andreas Reichel) +- support clickhouse global keyword in IN Expression ([a9ed7](https://github.com/JSQLParser/JSqlParser/commit/a9ed79825110df7) hezw) + +### Bug Fixes + +- refactor `JsonExpression`, avoiding expensive semantic lookahead and improving performance ([56515](https://github.com/JSQLParser/JSqlParser/commit/56515aba6ca893f) Andreas Reichel) +- `GO` shall terminate statement only, when appearing alone on an empty line ([14637](https://github.com/JSQLParser/JSqlParser/commit/14637ce64763b42) Andreas Reichel) +- De-Parse Oracle Hints in UPDATE, INSERT, DELETE and MERGE ([aaca0](https://github.com/JSQLParser/JSqlParser/commit/aaca05855f9a11b) Andreas Reichel) +- `UpdateSet` shall not have brackets with single element only ([15b9a](https://github.com/JSQLParser/JSqlParser/commit/15b9aef7ca05416) Andreas Reichel) +- make `GLOBAL` a restricted keyword, not usable as an Alias ([dd6cf](https://github.com/JSQLParser/JSqlParser/commit/dd6cf23150f4804) Andreas Reichel) +- Postgres `NextVal()` function ([e3afa](https://github.com/JSQLParser/JSqlParser/commit/e3afa5fbdebc715) Andreas Reichel) +- optional `Expression` in `FETCH` clause ([daee3](https://github.com/JSQLParser/JSqlParser/commit/daee30f7ae88bea) Andreas Reichel) +- allow `RAW` as `CreateParameter` ([ecd40](https://github.com/JSQLParser/JSqlParser/commit/ecd40386585a519) Andreas Reichel) + +### Other changes + +**problem with old sonatype repo?** + + +[66dd0](https://github.com/JSQLParser/JSqlParser/commit/66dd0cffad8255d) Tobias Warneke *2023-12-28 00:10:08* + +**problem with old sonatype repo?** + + +[19bde](https://github.com/JSQLParser/JSqlParser/commit/19bdef65c0e04c3) Tobias Warneke *2023-12-27 22:50:54* + +**problem with old sonatype repo?** + + +[d6b4c](https://github.com/JSQLParser/JSqlParser/commit/d6b4cc374db4197) Tobias Warneke *2023-12-27 22:43:59* + +**problem with old sonatype repo?** + + +[5ff53](https://github.com/JSQLParser/JSqlParser/commit/5ff53e835e675ea) Tobias Warneke *2023-12-27 00:54:26* + +**** + + +[6a327](https://github.com/JSQLParser/JSqlParser/commit/6a327b186528d1a) Tobias Warneke *2023-12-26 23:15:57* + +**npe in memory leak verifier** + + +[63955](https://github.com/JSQLParser/JSqlParser/commit/639555315180cbf) Tobias Warneke *2023-12-26 23:01:20* + +**allow reinitializing of javacc semanticize** + + +[44274](https://github.com/JSQLParser/JSqlParser/commit/44274b252c21cd1) Tobias Warneke *2023-12-26 22:53:28* + +**Allowed to build JSqlParser on slower computers by increasing a fixed timeout. This should take machine power into account.** + + +[806d3](https://github.com/JSQLParser/JSqlParser/commit/806d3a39e8f093e) Tobias Warneke *2023-12-26 20:31:48* + +**upgraded some plugins** + + +[cff03](https://github.com/JSQLParser/JSqlParser/commit/cff03ca200c674c) Tobias Warneke *2023-12-26 12:59:38* + +**upgraded some plugins** + + +[256a1](https://github.com/JSQLParser/JSqlParser/commit/256a1eff904834b) Tobias Warneke *2023-12-25 23:53:18* + +**upgraded some plugins** + + +[b2bd0](https://github.com/JSQLParser/JSqlParser/commit/b2bd025b424e472) Tobias Warneke *2023-12-25 23:51:46* + +**corrected license header of some files** + + +[23ba3](https://github.com/JSQLParser/JSqlParser/commit/23ba326db05e863) Tobias Warneke *2023-12-25 23:39:37* + +**Update sphinx.yml** + + +[2974f](https://github.com/JSQLParser/JSqlParser/commit/2974f4d20e2d785) manticore-projects *2023-12-16 07:13:01* + +**Update sphinx.yml** + + +[a35fb](https://github.com/JSQLParser/JSqlParser/commit/a35fbe77b33a07b) manticore-projects *2023-12-16 04:42:01* + +**Update build.gradle** + + +[546b3](https://github.com/JSQLParser/JSqlParser/commit/546b3ee00e4c3f8) manticore-projects *2023-12-15 09:14:49* + +**Update build.gradle** + + +[48b3a](https://github.com/JSQLParser/JSqlParser/commit/48b3acbeef56b2d) manticore-projects *2023-12-15 09:11:51* + +**Closed #1814, mysql and mariadb can use `index type` before `ON` (#1918)** + + +[b0aff](https://github.com/JSQLParser/JSqlParser/commit/b0aff31314a8df4) jxnu-liguobin *2023-12-15 04:56:55* + +**Fix conflict (#1915)** + + +[2ae1d](https://github.com/JSQLParser/JSqlParser/commit/2ae1d53e56e45b2) jxnu-liguobin *2023-12-14 07:22:57* + +**Fix typo in migration.rst (#1888)** + +* Found a typo in the 4.7 migration document. Trivial PR. Please merge. + +[902e4](https://github.com/JSQLParser/JSqlParser/commit/902e4c46f783985) Ed Sabol *2023-11-10 03:05:39* + +**Unit tests support multi-os and higher versions of jdk (#1886)** + +* fix: tokenBlockPattern support \r\n or \r +* test: remove nashorn ignore annotation to support jdk11+ + +[97e92](https://github.com/JSQLParser/JSqlParser/commit/97e9229d15df7d6) human-user *2023-11-08 03:07:04* + +**Support for Nested With Clauses Added** + + +[59104](https://github.com/JSQLParser/JSqlParser/commit/59104fd96f29a2e) MathewJoseph31 *2023-09-12 12:01:59* + +**Support for Array Contains (&>) and ContainedBy (<&) operator added** + + +[727c7](https://github.com/JSQLParser/JSqlParser/commit/727c732fd217843) MathewJoseph31 *2023-09-12 12:01:20* + +**Support for postgres overlap operator && added, natural left/right/full outer joins added** + + +[6955c](https://github.com/JSQLParser/JSqlParser/commit/6955c4391e65a33) MathewJoseph31 *2023-09-12 12:01:15* + +**add support for index hints in Update statement for MySQL** + + +[9a67d](https://github.com/JSQLParser/JSqlParser/commit/9a67d1277a0bf80) joeqiao *2022-11-08 01:27:25* + +**added support for T-SQL left and right joins (*= and =*)** + + +[786c8](https://github.com/JSQLParser/JSqlParser/commit/786c8fc65858ff6) Nico *2019-01-29 11:11:07* + + +## jsqlparser-4.7 (2023-09-02) + +### Breaking changes + +- add support for INTERPRET function parsing (#1816) ([180ec](https://github.com/JSQLParser/JSqlParser/commit/180ec68cc9fa7eb) Matteo Sist) +- Remove `ItemsList`, `MultiExpressionList`, `Replace` ([14170](https://github.com/JSQLParser/JSqlParser/commit/141708eabc4f2ea) Andreas Reichel) +- Consolidate the `ExpressionList`, removing many redundant List alike Classes and Productions ([288b1](https://github.com/JSQLParser/JSqlParser/commit/288b177fe9c8a4c) Andreas Reichel) +- remove `SelectExpressionItem` in favor of `SelectItem` ([b9057](https://github.com/JSQLParser/JSqlParser/commit/b9057d2b75cd1d7) Andreas Reichel) +- ClickHouse `Select...` ``FINAL` modifier ([4b7f2](https://github.com/JSQLParser/JSqlParser/commit/4b7f21c54c24d04) Andreas Reichel) + +### Features + +- H2 BYTEA Values `X'01' '02'` ([54828](https://github.com/JSQLParser/JSqlParser/commit/54828a456a7f192) Andreas Reichel) +- BigQuery Except(..) Replace(..) syntax ([4b4ae](https://github.com/JSQLParser/JSqlParser/commit/4b4ae04f44ff18b) Andreas Reichel) +- implement a few missing expressions ([04128](https://github.com/JSQLParser/JSqlParser/commit/0412897f9ea809f) Andreas Reichel) +- SQL:2016 TABLESAMPLE clause ([4d8a5](https://github.com/JSQLParser/JSqlParser/commit/4d8a512191a4a1b) Andreas Reichel) +- add a method checking balanced brackets ([52df3](https://github.com/JSQLParser/JSqlParser/commit/52df32dd8ec2c10) Andreas Reichel) +- add support for INTERPRET function parsing (#1816) ([180ec](https://github.com/JSQLParser/JSqlParser/commit/180ec68cc9fa7eb) Matteo Sist) +- MySQL `NOT RLIKE`, `NOT REGEXP` expressions ([f1325](https://github.com/JSQLParser/JSqlParser/commit/f132547f56a1edd) Andreas Reichel) +- Postgres `NOTNULL` support ([386dc](https://github.com/JSQLParser/JSqlParser/commit/386dc7a0df98f1c) manticore-projects) +- `QUALIFY` clause ([75e4d](https://github.com/JSQLParser/JSqlParser/commit/75e4d30747a7e6e) Andreas Reichel) +- T-SQL `FOR ...` clause ([8027d](https://github.com/JSQLParser/JSqlParser/commit/8027dbf2cbf9163) Andreas Reichel) +- Quoted Identifiers can contain double-quotes (PostgreSQL) ([73c55](https://github.com/JSQLParser/JSqlParser/commit/73c55fda1ac6a42) Andreas Reichel) +- functions blocks, parenthesed JSON Expressions ([5263b](https://github.com/JSQLParser/JSqlParser/commit/5263b91f3e555b7) Andreas Reichel) +- functions blocks, parenthesed JSON Expressions ([e19dc](https://github.com/JSQLParser/JSqlParser/commit/e19dc0e081f741d) Andreas Reichel) +- parse CREATE TRIGGER as UnsupportedStatement ([64b03](https://github.com/JSQLParser/JSqlParser/commit/64b0331f772278b) Andreas Reichel) +- chaining JSON Expressions ([6ef5e](https://github.com/JSQLParser/JSqlParser/commit/6ef5e0b6ee06211) Andreas Reichel) +- Write API documentation to the WebSite via XMLDoclet ([c5366](https://github.com/JSQLParser/JSqlParser/commit/c53667f8eff30e3) Andreas Reichel) +- `MEMBER OF` condition as shown at https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#operator_member-of ([6e7a7](https://github.com/JSQLParser/JSqlParser/commit/6e7a78dfc563749) Andreas Reichel) +- access Elements of Array Columns ([09a70](https://github.com/JSQLParser/JSqlParser/commit/09a70a499121792) Andreas Reichel) +- JdbcNamedParameter allows "&" (instead of ":") ([c07a4](https://github.com/JSQLParser/JSqlParser/commit/c07a43b3c128a5d) Andreas Reichel) +- Consolidate the `ExpressionList`, removing many redundant List alike Classes and Productions ([288b1](https://github.com/JSQLParser/JSqlParser/commit/288b177fe9c8a4c) Andreas Reichel) +- ClickHouse `LIMIT ... BY ...` clause ([4d5e2](https://github.com/JSQLParser/JSqlParser/commit/4d5e26d3febe686) Andreas Reichel) +- implement SQL:2016 Convert() and Trim() ([3a27a](https://github.com/JSQLParser/JSqlParser/commit/3a27a9dd4add700) Andreas Reichel) +- Switch off contradicting `JOIN` qualifiers, when setting a qualifier ([b6ea8](https://github.com/JSQLParser/JSqlParser/commit/b6ea8b162450545) Andreas Reichel) +- Test if a JOIN is an INNER JOIN according to the SQL:2016 ([6281b](https://github.com/JSQLParser/JSqlParser/commit/6281b07a543b088) Andreas Reichel) +- ClickHouse `Select...` ``FINAL` modifier ([4b7f2](https://github.com/JSQLParser/JSqlParser/commit/4b7f21c54c24d04) Andreas Reichel) +- Multi-Part Names for Variables and Parameters ([9da7a](https://github.com/JSQLParser/JSqlParser/commit/9da7a06ebe9b036) Andreas Reichel) +- Oracle `HAVING` before `GROUP BY` ([4efb9](https://github.com/JSQLParser/JSqlParser/commit/4efb99f1510ad16) Andreas Reichel) +- Lateral View ([8a1bd](https://github.com/JSQLParser/JSqlParser/commit/8a1bdeccbadb04f) Andreas Reichel) +- FETCH uses EXPRESSION ([0979b](https://github.com/JSQLParser/JSqlParser/commit/0979b2e5ea76b8c) Andreas Reichel) +- Support more Statement Separators ([b0814](https://github.com/JSQLParser/JSqlParser/commit/b08148414bd8f30) Andreas Reichel) +- CREATE VIEW ... REFRESH AUTO... ([1c8d8](https://github.com/JSQLParser/JSqlParser/commit/1c8d8daf48ebac1) Andreas Reichel) +- Oracle Alternative Quoting ([c57c4](https://github.com/JSQLParser/JSqlParser/commit/c57c427032c91d0) Andreas Reichel) +- make important Classes Serializable ([b94b2](https://github.com/JSQLParser/JSqlParser/commit/b94b2cc6a8f8c7d) Andreas Reichel) + +### Bug Fixes + +- ExpressionList of Expressions in `Values` ([994e6](https://github.com/JSQLParser/JSqlParser/commit/994e6c63d065a48) Andreas Reichel) +- check for NULL before iterating ([beb68](https://github.com/JSQLParser/JSqlParser/commit/beb68d55239da97) Andreas Reichel) +- Backslash escaped single quote `'\''` ([a2975](https://github.com/JSQLParser/JSqlParser/commit/a29754341adeffc) Andreas Reichel) +- `INSERT` must use simple Column Names only ([420d7](https://github.com/JSQLParser/JSqlParser/commit/420d7d834760f14) Andreas Reichel) +- SPHINX modules and themes ([6f277](https://github.com/JSQLParser/JSqlParser/commit/6f277654b9344ec) Andreas Reichel) +- expose IntervalExpression attributes and use DeParser ([b6fab](https://github.com/JSQLParser/JSqlParser/commit/b6fab2a484e0b47) Andreas Reichel) +- throw the specific exception ([cb960](https://github.com/JSQLParser/JSqlParser/commit/cb960a35647a19a) Andreas Reichel) +- Complex Parsing Approach ([4f048](https://github.com/JSQLParser/JSqlParser/commit/4f0488ccb4611f0) Andreas Reichel) +- issue #1789 ([32ec5](https://github.com/JSQLParser/JSqlParser/commit/32ec56114c1fbc4) Andreas Reichel) +- issue #1789 ([d20c8](https://github.com/JSQLParser/JSqlParser/commit/d20c8e94de64e2a) Andreas Reichel) +- issue #1791 ([88d1b](https://github.com/JSQLParser/JSqlParser/commit/88d1b62f0038a9a) Andreas Reichel) +- Java Version 8 ([7cecd](https://github.com/JSQLParser/JSqlParser/commit/7cecd293cf4e0ea) Andreas Reichel) +- find the correct position when field belongs to an internal class ([21389](https://github.com/JSQLParser/JSqlParser/commit/21389b712995674) Andreas Reichel) +- Remove tests for `()`, since `ParenthesedExpressionList` will catch those too ([905ef](https://github.com/JSQLParser/JSqlParser/commit/905ef6512d592d6) Andreas Reichel) +- assign Enum case insensitive ([fc577](https://github.com/JSQLParser/JSqlParser/commit/fc577caa4146878) Andreas Reichel) + +### Other changes + +**** + + +[d45f2](https://github.com/JSQLParser/JSqlParser/commit/d45f29ef42a6859) Tobias Warneke *2023-09-01 22:07:49* + +**Fixing a problem with an OP_CONCAT in WhenExpression (#1837)** + +* fix: Concatenation in inner ELSE statement (Second level of Case Expression) +* fix: broken tests +* fix: Delete lookahead(3) + +[f05cb](https://github.com/JSQLParser/JSqlParser/commit/f05cb7ff4aa46c5) amigalev *2023-08-20 04:43:30* + +**Update Gradle JavaCC parser to latest version (3.0.0) (#1843)** + + +[c59a0](https://github.com/JSQLParser/JSqlParser/commit/c59a088dfaee75a) Zbynek Konecny *2023-08-05 22:14:21* + +**Update sql-parser-error.md** + + +[41d70](https://github.com/JSQLParser/JSqlParser/commit/41d705bb1036b34) manticore-projects *2023-07-26 00:37:51* + +**Update sql-parser-error.md** + + +[812c6](https://github.com/JSQLParser/JSqlParser/commit/812c6cae3a8438b) manticore-projects *2023-07-26 00:37:14* + +**Update sql-parser-error.md** + + +[b34d3](https://github.com/JSQLParser/JSqlParser/commit/b34d3c88a881c0f) manticore-projects *2023-07-25 00:09:05* + +**Update sphinx.yml** + +* fix the FURO theme + +[51cc4](https://github.com/JSQLParser/JSqlParser/commit/51cc444ff98ad1d) manticore-projects *2023-06-01 02:49:23* + +**Create gradle.yml** + + +[be7fc](https://github.com/JSQLParser/JSqlParser/commit/be7fc53cff240be) manticore-projects *2023-05-18 10:16:14* + +**Update sphinx.yml** + + +[11323](https://github.com/JSQLParser/JSqlParser/commit/11323388ab4abfd) manticore-projects *2023-05-14 13:10:16* + +**** + + +[0aa8a](https://github.com/JSQLParser/JSqlParser/commit/0aa8a629b9cecc2) Tobias Warneke *2023-04-27 21:18:29* + +**Fix #1758: Use long for Feature.timeOut (#1759)** + +* Co-authored-by: Tobias <t.warneke@gmx.net> + +[3314e](https://github.com/JSQLParser/JSqlParser/commit/3314edf0ea17772) Tomasz Zarna *2023-04-27 20:30:31* + +**Ignoring unnecessarily generated jacoco report (#1762)** + +* Ignoring unnecessarily generated jacoco report +* Ignoring unnecessarily generated by pmd plugin +* --------- +* Co-authored-by: other <other@ECE-A55006.austin.utexas.edu> +* Co-authored-by: Tobias <t.warneke@gmx.net> + +[1bbb1](https://github.com/JSQLParser/JSqlParser/commit/1bbb1443d84684c) optimizing-ci-builds *2023-04-27 19:50:42* + +**Ignoring unnecessarily generated by pmd plugin (#1763)** + +* Co-authored-by: other <other@ECE-A55006.austin.utexas.edu> + +[52648](https://github.com/JSQLParser/JSqlParser/commit/52648277e69fa07) optimizing-ci-builds *2023-04-27 19:49:15* + +**Refactor Parenthesed SelectBody and FromItem (#1754)** + +* 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 +* 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() +* style: apply Spotless +* test: commit missing test +* fix: JSon Operator can use Simple Function +* Supports `Function() ->> Literal` (although `Function()` would not allow Nested Expression Parameters) +* fixes #1571 +* style: Reformat changed files and headers +* style: Remove unused variable +* feat: Add support for Hangul "\uAC00"-"\uD7A3" +* fixes #1747 +* style: expose `SetStatement` key-value list +* fixes #1746 +* style: Appease PMD/Codacy +* feat: `ConflictTarget` allows multiple `IndexColumnNames` +* fixes #1749 +* fixes #1633 +* fixes #955 +* doc: fix reference in the Java Doc +* build: better Upload Groovy Task +* feat: ParenthesedSelectBody and ParenthesedFromItem +* - First properly working version +* - Work in progress, 13 tests failing +* feat: ParenthesedSelectBody and ParenthesedFromItem +* - delete unneeded ParenthesedJoin +* - rename ParenthesisFromItem into ParenthesedFromItem +* feat: ParenthesedSelectBody and ParenthesedFromItem +* - fix `NULLS FIRST` and `NULLS LAST` +* feat: ParenthesedSelectBody and ParenthesedFromItem +* - fix Oracle Hints +* feat: ParenthesedSelectBody and ParenthesedFromItem +* - parse `SetOperation` only after a (first plain) SelectBody has found, this fixes the performance issue +* - one more special Oracle Test succeeds +* - 5 remaining test failures +* feat: ParenthesedSelectBody and ParenthesedFromItem +* - extract `OrderByElements` into `SelectBody` +* - one more special Oracle Test succeeds +* - all tests succeed +* style: Appease PMD/Codacy +* style: Appease PMD/Codacy +* feat: Refactor SelectBody implementations +* - `SelectBody` implements `FromItem` +* - get rid of `SubSelect` and `SpecialSubSelect` +* - `Merge` can use `FromItem` instead of `SubSelect` or `Table` +* - `LateralSubSelect` extends `ParenthesedSelectBody` directly +* - Simplify the `Select` statement, although it is still redundant since `SelectBody` also could implement `Statement` directly +* - `WithItem` can use `SelectBody` directly, which allows for nested `WithItems` +* BREAKING-CHANGE: Lots of redundant methods and intermediate removed +* feat: Refactor SelectBody implementations +* - `SelectBody` implements `Statement` and so makes `Select` redundant +* - get rid of `ValuesList` +* - refactor `ValuesStatement` into `Values` which just implements `SelectBody` (and becomes a `Statement` and a `FromItem`), move to `select` package +* BREAKING-CHANGE: Lots of redundant methods and intermediate removed +* style: Code cleanup +* - remove 3 unused/obsolete productions +* - appease PMD/Codacy +* feat: Merge `SelectBody` into `Select` Statement +* - former `SelectBody` implements `Statement` and so becomes `Select` +* - this reduces the AST by 1 hierarchy level +* style: Remove unused import +* test: @Disabled invalid Test +* style: Appease PMD/Codacy +* test: Add a SubSelect Parsing Test +* --------- +* Co-authored-by: zaza <tzarna@gmail.com> + +[a312d](https://github.com/JSQLParser/JSqlParser/commit/a312dcdc2d618f1) manticore-projects *2023-04-27 19:38:24* + +**** + + +[c1c92](https://github.com/JSQLParser/JSqlParser/commit/c1c92ade94ebe60) Tobias Warneke *2023-04-01 19:54:09* + +**Assorted Fixes #7 (#1745)** + +* 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 +* 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() +* style: apply Spotless +* test: commit missing test +* fix: JSon Operator can use Simple Function +* Supports `Function() ->> Literal` (although `Function()` would not allow Nested Expression Parameters) +* fixes #1571 +* style: Reformat changed files and headers +* style: Remove unused variable +* feat: Add support for Hangul "\uAC00"-"\uD7A3" +* fixes #1747 +* style: expose `SetStatement` key-value list +* fixes #1746 +* style: Appease PMD/Codacy +* feat: `ConflictTarget` allows multiple `IndexColumnNames` +* fixes #1749 +* fixes #1633 +* fixes #955 +* doc: fix reference in the Java Doc +* build: better Upload Groovy Task +* --------- +* Co-authored-by: zaza <tzarna@gmail.com> + +[31ef1](https://github.com/JSQLParser/JSqlParser/commit/31ef1aaf23e2917) manticore-projects *2023-03-21 22:04:58* + +**disable xml report (#1748)** + +* Co-authored-by: other <other@ECE-A55006.austin.utexas.edu> + +[476d9](https://github.com/JSQLParser/JSqlParser/commit/476d96965492131) optimizing-ci-builds *2023-03-21 21:58:25* + +**Assorted Fixes #6 (#1740)** + +* 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 +* 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() +* style: apply Spotless +* test: commit missing test +* feat: Unicode CJK Unified Ideographs (Unicode block) +* fixes #1741 +* feat: Unicode CJK Unified Ideographs (Unicode block) +* fixes #1741 +* feat: Functions with nested Attributes +* Supports `SELECT schemaName.f1(arguments).f2(arguments).f3.f4` and similar constructs +* fixes #1742 +* fixes #1050 +* --------- +* Co-authored-by: zaza <tzarna@gmail.com> + +[adeed](https://github.com/JSQLParser/JSqlParser/commit/adeed5359c65b8f) manticore-projects *2023-03-09 21:22:40* + +**version 4.7-SNAPSHOT** + + +[74570](https://github.com/JSQLParser/JSqlParser/commit/745701bfb90a233) Tobias Warneke *2023-02-23 21:41:03* + +**Update issue templates** + + +[4aeaf](https://github.com/JSQLParser/JSqlParser/commit/4aeafbc68f0525c) manticore-projects *2023-02-01 01:37:53* + +**Update issue templates** + + +[46314](https://github.com/JSQLParser/JSqlParser/commit/46314c41eb06957) manticore-projects *2023-02-01 01:24:35* + +**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 + +[2ef66](https://github.com/JSQLParser/JSqlParser/commit/2ef6637afffa943) Andreas Reichel *2023-01-21 04:06:00* + +**Define Reserved Keywords explicitly** + +* Derive All Keywords from Grammar directly +* Generate production for Object Names (semi-) automatically +* Add parametrized Keyword Tests + +[f49e8](https://github.com/JSQLParser/JSqlParser/commit/f49e828fc9c5f2f) Andreas Reichel *2023-01-21 04:05:51* + +**Adjust Gradle to JUnit 5** + +* Parallel Test execution +* Gradle Caching +* Explicitly request for latest JavaCC 7.0.10 + +[e960a](https://github.com/JSQLParser/JSqlParser/commit/e960a35e591ce07) Andreas Reichel *2023-01-21 04:05:51* + +**Enhanced Keywords** + +* Add Keywords and document, which keywords are allowed for what purpose + +[b5321](https://github.com/JSQLParser/JSqlParser/commit/b5321d6e8bac588) Andreas Reichel *2023-01-21 04:05:51* + +**Remove unused imports** + + +[a016b](https://github.com/JSQLParser/JSqlParser/commit/a016be0c7f8a46f) Andreas Reichel *2023-01-21 04:05:51* + +**Fix test resources** + + +[86f33](https://github.com/JSQLParser/JSqlParser/commit/86f337dbafd10ab) Andreas Reichel *2023-01-21 04:05:51* + +**Do not mark SpeedTest for concurrent execution** + + +[67f79](https://github.com/JSQLParser/JSqlParser/commit/67f7951a048a05d) Andreas Reichel *2023-01-21 04:05:51* + +**Fix incorrect tests** + + +[5fae2](https://github.com/JSQLParser/JSqlParser/commit/5fae2f5984c3b39) Andreas Reichel *2023-01-21 04:05:51* + +**Remove unused imports** + + +[3ba54](https://github.com/JSQLParser/JSqlParser/commit/3ba5410bf052091) Andreas Reichel *2023-01-21 04:05:51* + +**Adjust Gradle to JUnit 5** + +* Parallel Test execution +* Gradle Caching +* Explicitly request for latest JavaCC 7.0.10 + +[2d51a](https://github.com/JSQLParser/JSqlParser/commit/2d51a82d3e9e51c) Andreas Reichel *2023-01-21 04:05:51* + +**Do not mark SpeedTest for concurrent execution** + + +[232af](https://github.com/JSQLParser/JSqlParser/commit/232aff6873f24f9) Andreas Reichel *2023-01-21 04:05:51* + +**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. + +[ea447](https://github.com/JSQLParser/JSqlParser/commit/ea4477bb775ebdb) zaza *2023-01-08 20:43:40* + +**Fixes #1684: Support CREATE MATERIALIZED VIEW with AUTO REFRESH** + +* Support parsing create view statements in Redshift with AUTO REFRESH +* option. + +[74715](https://github.com/JSQLParser/JSqlParser/commit/747152a9fc1bfd1) zaza *2022-12-11 20:03:52* + + +## jsqlparser-4.6 (2023-02-23) + +### Bug Fixes + +- add missing public Getter (#1632) ([d2212](https://github.com/JSQLParser/JSqlParser/commit/d2212776ac5eb83) manticore-projects) + +### Other changes + +**actualized release plugin** + + +[9911a](https://github.com/JSQLParser/JSqlParser/commit/9911ad7a990356f) Tobias Warneke *2023-02-23 21:17:52* + +**actualized release plugin** + + +[0b2c3](https://github.com/JSQLParser/JSqlParser/commit/0b2c33b29928ec4) Tobias Warneke *2023-02-23 21:16:43* + +**** + + +[b07f7](https://github.com/JSQLParser/JSqlParser/commit/b07f791b27c3ee4) Tobias Warneke *2023-02-23 19:50:39* + +**Update build.gradle** + + +[35233](https://github.com/JSQLParser/JSqlParser/commit/35233882aaffb0e) Tobias *2023-02-17 20:20:25* + +**Update README.md** + + +[0b092](https://github.com/JSQLParser/JSqlParser/commit/0b09229a3d92547) Tobias *2023-02-17 16:27:41* + +**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> + +[e71e5](https://github.com/JSQLParser/JSqlParser/commit/e71e57dfe4b377c) manticore-projects *2023-02-07 20:18:52* + +**Issue1673 case within brackets (#1675)** + +* fix: add missing public Getter +* Add public Getter for `updateSets` +* Fixes #1630 +* fix: Case within brackets +* fixes #1673 + +[2ced7](https://github.com/JSQLParser/JSqlParser/commit/2ced7ded930f8b0) manticore-projects *2023-01-31 20:56:01* + +**Added support for SHOW INDEX from table (#1704)** + +* Added support for SHOW INDEX from table +* Added * import +* fix for javadoc +* added <doclint>none</doclint> + +[a2618](https://github.com/JSQLParser/JSqlParser/commit/a2618321135d517) Jayant Kumar Yadav *2023-01-31 20:54:05* + +**** + + +[d33f6](https://github.com/JSQLParser/JSqlParser/commit/d33f6f5a658751d) Tobias Warneke *2023-01-22 15:43:07* + +**Sphinx Website (#1624)** + +* 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 +* Keyword test adopt JUnit5 +* Update keywords +* CheckStyle sanitation of method names +* Merge Master +* Add Jupiter Parameters dependency again +* Automate the `updateKeywords` Step +* Update PMD and rules +* Rewrite test expected to fail +* Appease Codacy +* Remove broken rule warning about perfectly fine switch-case statements +* Force Changes +* Fix Merge Issues +* Read Tokens directly from the Grammar File without invoking JTREE +* - read Tokens per REGEX Matcher +* - move Reserved Keywords from Grammar into ParserKeywordsUtils +* - adjust the Tests +* Appease PMD/Codacy +* Extract the Keywords from the Grammar by using JTRee (instead of Regex) +* Add some tests to ensure, that all Keywords or found +* Appease Codacy/PMD +* Separate UpdateKeywords Task again +* Including it into compileJavacc won't work since it depends on compiling the ParserKeywordUtils.java +* Single file compilation did not work +* Clean-up the imports +* Add JavaCC dependency to Maven for building ParserKeywordsUtils +* Add JavaCC dependency to Maven for building ParserKeywordsUtils +* Merge Upstream +* Merge Master +* Fixes broken PR #1524 and Commit fb6e950ce0e62ebcd7a44ba9eea679da2b04b2ed +* Add AST Visualization +* Show the Statement's Java Objects in a tree hierarchy +* 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 +* test: Document an additional Special Oracle test success +* doc: ignore the autogenerated changelog.rst in GIT +* build: temporarily reduce the Code Coverage requirements +* Temporarily reduce the Coverage checks regarding Minimum Coverage and Maximum Missed Lines in order to get the Keywords PR accepted. We should do a major Code cleanup afterwards. +* build: Clean-up the Gradle Build +* Prefix the Sphinx Prolog Variables with JSQLPARSER in order to allow for build the Main Website for various projects +* Remove some redundant version requests for PMD, CheckStyle and friends +* Remove JUnit-4 dependency and add HarmCrest +* Complete the PUBLISHING task +* doc: Explain the ``updateKeywords`` Gradle Task +* build: Un-escape the Unicode on the changelog file +* build: Un-escape the Unicode on the changelog file +* doc: Cleanup +* Unescape unicode characters from Git Changelog +* Remove obsolete code from Sphinx' conf.py +* doc: Properly un-escape the Git Commit message +* doc: request for `Conventional Commit` messages +* doc: correctly refer to `RelObjectNameWithoutValue()` +* build: upload the built files via Excec/SFTP +* doc: Add an example on Token White-listing +* doc: write the correct Git Repository +* doc: pronounce the OVERLAPS example more +* feat: make important Classes Serializable +* Implement Serializable for persisting via ObjectOutputStream +* doc: Add the "How to Use" java code +* chore: Make Serializable +* fix: Non-serializable field in serializable class +* build: various fixes to the Maven build file +* add the Keywords Documentation file to the task +* exclude the Sphinx files from the license header plugin +* fix the JavaDoc plugin options +* build: add the Keywords Documentation file to the task +* doc: add a page about actually Reserved Keywords +* build: avoid PMD/Codacy for Sphinx Documentation +* update Changelog +* build: Add Sphinx GitHub Action +* Add a GitHub Action, which will +* - Install Sphinx and Extensions +* - Install Gradle Wrapper +* - Run Gradle Wrapper Task `sphinx` +* - Deploy the generated static HTML site to GH Pages +* fix: fix a merge error, brackets +* fix: remove JavaCC dependency +* Parse Tokens via Regex +* Move JavaCC Token Parser into the KeywordsTest +* Make JavaCC a Test Dependency only +* doc: Fix Maven Artifact Version +* style: Avoid throwing raw exception types. +* style: Avoid throwing raw exception types. +* 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 +* build: gradle, execute all Checks after Test +* Co-authored-by: Tobias <t.warneke@gmx.net> + +[be8e7](https://github.com/JSQLParser/JSqlParser/commit/be8e7a8a1d77184) manticore-projects *2023-01-20 21:45:35* + +**Assorted Fixes #5 (#1715)** + +* refactor: Merge REPLACE into UPSERT +* fixes #1706 +* feat: `DROP TEMPORARY TABLE ...` +* fixes #1712 +* build: PMD compliance +* ci: Merge master +* feat: Configurable backslash `\` escaping +* - Enables `\` as escape character in String Literals (beside SQL:2016 compliant `'`) +* - Default is OFF (since its not SQL:2016 compliant) +* - Activate per Parser Feature +* - Fixes #1638 +* - Fixes #1209 +* - Fixes #1173 +* - Fixes #1172 +* - Fixes #832 +* - Fixes #827 +* - Fixes #578 +* BREAKING-CHANGE: Backslash Escaping needs to be activated explicitly or else Backslash won't work as Escape Character. +* style: Checkstyle +* style: remove dead code +* style: PMD compliance +* style: Checkstyle, unused import +* feat: allow `S_CHAR_LITERAL` to break lines +* - fixes #875 + +[a00d7](https://github.com/JSQLParser/JSqlParser/commit/a00d77a100bfab7) manticore-projects *2023-01-20 21:32:20* + +**Support DROP MATERIALIZED VIEW statements (#1711)** + + +[1af68](https://github.com/JSQLParser/JSqlParser/commit/1af682d436055ad) Tomasz Zarna *2023-01-12 21:37:42* + +**corrected readme** + + +[4dfd2](https://github.com/JSQLParser/JSqlParser/commit/4dfd2e43fcdd3ab) Tobias Warneke *2023-01-04 21:07:17* + +**Update README.md** + +* lgtm removed + +[954b8](https://github.com/JSQLParser/JSqlParser/commit/954b8dd2e760a01) Tobias *2022-12-27 10:34:18* + +**Fix #1686: add support for creating views with "IF NOT EXISTS" clause (#1690)** + + +[0f34f](https://github.com/JSQLParser/JSqlParser/commit/0f34f5bc647365d) Tomasz Zarna *2022-12-22 21:52:35* + +**Assorted Fixes #4 (#1676)** + +* support clickhouse global keyword in join +* fix: add missing public Getter +* Add public Getter for `updateSets` +* Fixes #1630 +* feat: Clickhouse GLOBAL JOIN +* All credits to @julianzlzhang +* fixes #1615 +* fixes #1535 +* feat: IF/ELSE statements supports Block +* Make `If... Else...` statements work with Blocks +* Make `Statement()` production work with `Block()` +* Rewrite the `Block()` related Unit Tests +* fixes #1682 +* fix: Revert unintended changes to the Special Oracle Tests +* fix: `SET` statement supports `UserVariable` +* Make `SetStatement` parse Objects instead of Names only +* Add Grammar to accept `UserVariable` (e.g. "set @Flag = 1") +* Add Test Case for `UserVariable` +* fixes #1682 +* feat: Google Spanner Support +* Replaces PR #1415, all credit goes to @s13o +* Re-arranged some recently added Tokens in alphabetical order +* Update Keywords +* fix: fix JSonExpression, accept Expressions +* Make JSonExpression accept Expressions +* Add Testcase +* Expose Idents() and Operators() +* Fixes #1696 +* test: add Test for Issue #1237 +* Co-authored-by: Zhang Zhongliang <zhangzhongliang@xiaomi.com> + +[8d9db](https://github.com/JSQLParser/JSqlParser/commit/8d9db7052c3aeb5) manticore-projects *2022-12-22 21:17:55* + +**Fixed download war script in the renderRR task (#1659)** + +* Co-authored-by: Hai Chang <haichang@microsoft.com> + +[08a92](https://github.com/JSQLParser/JSqlParser/commit/08a92fcd7b4f7f2) haha1903 *2022-12-10 09:23:53* + +**Assorted fixes (#1666)** + +* fix: add missing public Getter +* Add public Getter for `updateSets` +* Fixes #1630 +* feat: LISTAGG() with OVER() clause +* fixes issue #1652 +* fixes 3 more Special Oracle Tests +* fix: White-list CURRENT_DATE and CURRENT_TIMESTAMP tokens +* allows CURRENT_DATE(3) and CURRENT_TIMESTAMP(3) as regular functions +* fixes #1507 +* fixes #1607 +* feat: Deparser for Expression Lists +* Visit each Expression of a List instead ExpressionList.toString() +* fixes #1608 +* fix: Lookahead needed + +[bff26](https://github.com/JSQLParser/JSqlParser/commit/bff268a7c699947) manticore-projects *2022-11-20 10:06:01* + +**Fix parsing statements with multidimensional array PR2 (#1665)** + +* Fix parsing statements with multidimensional array +* fix: Whitelist LOCKED keyword +* Co-authored-by: Andrei Lisouski <alisousk@akamai.com> + +[e1865](https://github.com/JSQLParser/JSqlParser/commit/e186588f044753f) manticore-projects *2022-11-20 09:59:26* + +**removed disabled from Keyword tests and imports** + + +[af6c2](https://github.com/JSQLParser/JSqlParser/commit/af6c2702c8a505c) Tobias Warneke *2022-11-02 23:02:38* + +**removed disabled from Keyword tests** + + +[89a9a](https://github.com/JSQLParser/JSqlParser/commit/89a9a575fac1ba8) Tobias Warneke *2022-11-02 22:58:19* + +**** + + +[8a018](https://github.com/JSQLParser/JSqlParser/commit/8a0183311b01d2d) Tobias Warneke *2022-10-28 22:30:25* + +**** + + +[67de4](https://github.com/JSQLParser/JSqlParser/commit/67de469e585060f) Tobias Warneke *2022-10-25 23:26:28* + +**Enhanced Keywords (#1382)** + +* 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 +* Keyword test adopt JUnit5 +* Update keywords +* CheckStyle sanitation of method names +* Merge Master +* Add Jupiter Parameters dependency again +* Automate the `updateKeywords` Step +* Update PMD and rules +* Rewrite test expected to fail +* Appease Codacy +* Remove broken rule warning about perfectly fine switch-case statements +* Force Changes +* Fix Merge Issues +* Read Tokens directly from the Grammar File without invoking JTREE +* - read Tokens per REGEX Matcher +* - move Reserved Keywords from Grammar into ParserKeywordsUtils +* - adjust the Tests +* Appease PMD/Codacy +* Extract the Keywords from the Grammar by using JTRee (instead of Regex) +* Add some tests to ensure, that all Keywords or found +* Appease Codacy/PMD +* Separate UpdateKeywords Task again +* Including it into compileJavacc won't work since it depends on compiling the ParserKeywordUtils.java +* Single file compilation did not work +* Clean-up the imports +* Add JavaCC dependency to Maven for building ParserKeywordsUtils +* Add JavaCC dependency to Maven for building ParserKeywordsUtils +* Merge Upstream +* Merge Master +* Fixes broken PR #1524 and Commit fb6e950ce0e62ebcd7a44ba9eea679da2b04b2ed +* Add AST Visualization +* Show the Statement's Java Objects in a tree hierarchy +* build: temporarily reduce the Code Coverage requirements +* Temporarily reduce the Coverage checks regarding Minimum Coverage and Maximum Missed Lines in order to get the Keywords PR accepted. We should do a major Code cleanup afterwards. +* build: JSQLParser is a build dependency +* chore: Update keywords +* feat: add line count to output + +[4863e](https://github.com/JSQLParser/JSqlParser/commit/4863eb5a8e30a5d) manticore-projects *2022-10-25 23:15:32* + +**#1610 Support for SKIP LOCKED tokens on SELECT statements (#1649)** + +* Co-authored-by: Lucas Dillmann <lucas.dillmann@totvs.com.br> + +[e6d50](https://github.com/JSQLParser/JSqlParser/commit/e6d50f756e99846) Lucas Dillmann *2022-10-25 22:59:09* + +**Assorted fixes (#1646)** + +* fix: add missing public Getter +* Add public Getter for `updateSets` +* Fixes #1630 +* fix: Assorted Fixes +* SelectExpressionItem with Function and Complex Parameters +* Tables with Oracle DB Links +* Make Table Name Parts accessible +* Fixes #1644 +* Fixes #1643 +* fix: Revert correct test case + +[15ff8](https://github.com/JSQLParser/JSqlParser/commit/15ff84348228278) manticore-projects *2022-10-16 20:15:36* + +**actualized multiple dependencies** + + +[34502](https://github.com/JSQLParser/JSqlParser/commit/34502d0e66ad214) Tobias Warneke *2022-09-28 20:17:35* + +**Bump h2 from 1.4.200 to 2.1.210 (#1639)** + +* Bumps [h2](https://github.com/h2database/h2database) from 1.4.200 to 2.1.210. +* - [Release notes](https://github.com/h2database/h2database/releases) +* - [Commits](https://github.com/h2database/h2database/compare/version-1.4.200...version-2.1.210) +* --- +* updated-dependencies: +* - dependency-name: com.h2database:h2 +* dependency-type: direct:development +* ... +* Signed-off-by: dependabot[bot] <support@github.com> +* Signed-off-by: dependabot[bot] <support@github.com> +* Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +[fc3c4](https://github.com/JSQLParser/JSqlParser/commit/fc3c4cfd6b1eda9) dependabot[bot] *2022-09-28 19:52:31* + +**Support BigQuery SAFE_CAST (#1622) (#1634)** + +* Co-authored-by: Zhang, Dequn <deqzhang@paypal.com> + +[d9985](https://github.com/JSQLParser/JSqlParser/commit/d9985ae4f559cda) dequn *2022-09-20 18:22:25* + +**Support timestamptz dateliteral (#1621)** + +* support timestamptz as datetime literal +* rename test + +[81a64](https://github.com/JSQLParser/JSqlParser/commit/81a648eba8db92d) Todd Pollak *2022-08-31 20:31:44* + +**fixes #1617** + + +[b0aae](https://github.com/JSQLParser/JSqlParser/commit/b0aae378864c6e1) Tobias Warneke *2022-08-31 20:22:25* + +**fixes #419** + + +[427e9](https://github.com/JSQLParser/JSqlParser/commit/427e90f6b861e23) Tobias Warneke *2022-08-31 19:01:57* + +**Closes #1604, added simple OVERLAPS support (#1611)** + + +[236a5](https://github.com/JSQLParser/JSqlParser/commit/236a50b800a4794) Rob Audenaerde *2022-08-16 08:21:03* + +**Fixes PR #1524 support hive alter sql (#1609)** + +* 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 +* Fixes broken PR #1524 and Commit fb6e950ce0e62ebcd7a44ba9eea679da2b04b2ed + +[2619c](https://github.com/JSQLParser/JSqlParser/commit/2619ce0a6fd8bd5) manticore-projects *2022-08-14 16:29:18* + +**#1524 support hive alter sql : ALTER TABLE name ADD COLUMNS (col_spec[, col_spec ...]) (#1605)** + +* Co-authored-by: zhum@aotain.com <zm7705264> + +[fb6e9](https://github.com/JSQLParser/JSqlParser/commit/fb6e950ce0e62eb) Zhumin-lv-wn *2022-08-03 20:56:44* + +**fixes #1581** + + +[732e8](https://github.com/JSQLParser/JSqlParser/commit/732e840e99740ff) Tobias Warneke *2022-07-25 06:43:39* + +**Using own Feature - constant for "delete with returning" #1597 (#1598)** + + +[d3218](https://github.com/JSQLParser/JSqlParser/commit/d3218483f7f33ec) gitmotte *2022-07-25 04:55:20* + +**** + + +[2f491](https://github.com/JSQLParser/JSqlParser/commit/2f4916d3e512e14) Tobias Warneke *2022-07-22 23:19:59* + + +## jsqlparser-4.5 (2022-07-22) + +### Other changes + +**introduced changelog generator** + + +[e0f0e](https://github.com/JSQLParser/JSqlParser/commit/e0f0eabdfd1e820) Tobias Warneke *2022-07-22 22:47:00* + +**fixes #1596** + + +[60d64](https://github.com/JSQLParser/JSqlParser/commit/60d648397b01c2d) Tobias Warneke *2022-07-22 22:31:12* + +**integrated test for #1595** + + +[b3927](https://github.com/JSQLParser/JSqlParser/commit/b392733f25468f1) Tobias Warneke *2022-07-19 22:04:18* + +**** + + +[09830](https://github.com/JSQLParser/JSqlParser/commit/09830c9fb999bc6) Tobias Warneke *2022-07-19 21:44:43* + +**reduced time to parse exception to minimize impact on building time** + + +[191b9](https://github.com/JSQLParser/JSqlParser/commit/191b9fd2c796aa1) Tobias Warneke *2022-07-19 21:40:35* + +**add support for drop column if exists (#1594)** + + +[fcfdf](https://github.com/JSQLParser/JSqlParser/commit/fcfdfb7458fd28f) rrrship *2022-07-19 21:38:40* + +**PostgreSQL INSERT ... ON CONFLICT Issue #1551 (#1552)** + +* 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 +* 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 +* Support Postgres INSERT ... ON CONFLICT +* Fixes #1551 +* Refactor UpdateSet.toString(), which is used by Insert and Update +* Allow KEEP keyword +* Enables special Oracle Test keywordasidentifier04.sql, now 191 tests succeed +* Sanitize before push +* Tweak Grammar in order to survive the Maven Build +* Ammend the README +* Move Plugin configuration files to the CONFIG folder (hoping, that Codacy will find it there) +* Update PMD in the Maven configuration +* Update PMD in the Maven and Gradle configuration +* Appease Codacy +* Co-authored-by: Tobias <t.warneke@gmx.net> + +[5ae09](https://github.com/JSQLParser/JSqlParser/commit/5ae09ad097c7294) manticore-projects *2022-07-19 21:18:02* + +**Configurable Parser Timeout via Feature (#1592)** + +* Configurable Parser Timeout via Feature +* Fixes #1582 +* Implement Parser Timeout Feature, e. g. `CCJSqlParserUtil.parse(sqlStr, parser -> parser.withTimeOut(60000));` +* Add a special test failing after a long time only, to test TimeOut vs. Parser Exception +* Appease Codacy +* Appease Codacy +* Co-authored-by: Tobias <t.warneke@gmx.net> + +[74000](https://github.com/JSQLParser/JSqlParser/commit/74000130e850788) manticore-projects *2022-07-19 20:48:49* + +**fixes #1590** + + +[cfba6](https://github.com/JSQLParser/JSqlParser/commit/cfba6e54df4ed58) Tobias Warneke *2022-07-19 20:26:19* + +**fixes #1590** + + +[1abaf](https://github.com/JSQLParser/JSqlParser/commit/1abaf4cdbed1938) Tobias Warneke *2022-07-19 20:17:50* + +**extended support Postgres' `Extract( field FROM source)` where `field` is a String instead of a Keyword (#1591)** + +* Fixes #1582 +* Amend the ExtractExpression +* Add Test case for issue #1582 +* Amend the README + +[2b3ce](https://github.com/JSQLParser/JSqlParser/commit/2b3ce25a23b264a) manticore-projects *2022-07-19 19:25:23* + +**** + + +[87a37](https://github.com/JSQLParser/JSqlParser/commit/87a37d73f29ff55) Tobias Warneke *2022-07-14 19:30:27* + +**** + + +[26545](https://github.com/JSQLParser/JSqlParser/commit/26545484caa9372) Tobias Warneke *2022-07-14 19:23:39* + +**Closes #1579. Added ANALYZE support. (#1587)** + + +[e5c8a](https://github.com/JSQLParser/JSqlParser/commit/e5c8a89ded6d5ca) Rob Audenaerde *2022-07-14 19:22:47* + +**** + + +[b4a5c](https://github.com/JSQLParser/JSqlParser/commit/b4a5ce1374ab4f1) Tobias Warneke *2022-07-14 19:01:29* + +**** + + +[b08f2](https://github.com/JSQLParser/JSqlParser/commit/b08f205ea573553) Tobias Warneke *2022-07-14 18:56:19* + +**Closes #1583:: Implement Postgresql optional TABLE in TRUNCATE (#1585)** + +* Closes #1583 +* Closes #1583, removed unnecessary local variable. +* Closes #1583, proper support for deparsing. + +[26248](https://github.com/JSQLParser/JSqlParser/commit/262482610b80d18) Rob Audenaerde *2022-07-14 18:55:44* + +**** + + +[6b242](https://github.com/JSQLParser/JSqlParser/commit/6b2422e9cca5d56) Tobias Warneke *2022-07-14 18:53:41* + +**Support table option character set and index options (#1586)** + +* Support table option character set and index options +* Signed-off-by: luofei <luoffei@outlook.com> +* move test +* Signed-off-by: luofei <luoffei@outlook.com> + +[27cdf](https://github.com/JSQLParser/JSqlParser/commit/27cdfa9ca1237f6) luofei *2022-07-14 18:46:14* + +**corrected a last minute bug** + + +[afbaf](https://github.com/JSQLParser/JSqlParser/commit/afbaf53f4d5e727) Tobias Warneke *2022-07-09 15:28:17* + +**corrected a last minute bug** + + +[f3d2b](https://github.com/JSQLParser/JSqlParser/commit/f3d2b19dda25d09) Tobias Warneke *2022-07-09 15:25:36* + +**corrected a last minute bug** + + +[8378e](https://github.com/JSQLParser/JSqlParser/commit/8378ea4343e1a97) Tobias Warneke *2022-07-09 15:23:50* + +**fixes #1576** + + +[48ea0](https://github.com/JSQLParser/JSqlParser/commit/48ea0e2238e8186) Tobias Warneke *2022-07-09 14:26:07* + +**added simple test for #1580** + + +[5fdab](https://github.com/JSQLParser/JSqlParser/commit/5fdabf13251b193) Tobias Warneke *2022-07-07 20:13:12* + +**disabled test for large cnf expansion and stack overflow problem** + + +[d3000](https://github.com/JSQLParser/JSqlParser/commit/d30005b4486618b) Tobias Warneke *2022-07-07 19:30:37* + +**Add test for LikeExpression.setEscape and LikeExpression.getStringExpression (#1568)** + +* Add test for LikeExpression.setEscape and LikeExpression.getStringExpression +* like + set escape test for $ as escape character + +[bcf6f](https://github.com/JSQLParser/JSqlParser/commit/bcf6ff4157277f9) Caro *2022-07-07 19:27:43* + +**** + + +[a8a05](https://github.com/JSQLParser/JSqlParser/commit/a8a05535ca6e7c9) Tobias Warneke *2022-07-06 20:22:51* + +**add support for postgres drop function statement (#1557)** + + +[964fa](https://github.com/JSQLParser/JSqlParser/commit/964fa49ff25cd46) rrrship *2022-07-06 20:06:09* + +**** + + +[afbb5](https://github.com/JSQLParser/JSqlParser/commit/afbb595c749d2c2) Tobias Warneke *2022-07-06 19:53:35* + +**Add support for Hive dialect GROUPING SETS. (#1539)** + +* Add support for Hive GROUPING SETS dialect `GROUP BY a, b, c GROUPING SETS ((a, b), (a, c))` +* Simplify HiveTest::testGroupByGroupingSets. + +[03c58](https://github.com/JSQLParser/JSqlParser/commit/03c58de9d341a13) chenwl *2022-07-06 19:40:41* + +**fixes #1566** + + +[886f0](https://github.com/JSQLParser/JSqlParser/commit/886f06dac867b55) Tobias Warneke *2022-06-28 20:55:12* + +**Postgres NATURAL LEFT/RIGHT joins (#1560)** + +* Postgres NATURAL LEFT/RIGHT joins +* Fixes #1559 +* Make NATURAL an optional Join Keyword, which can be combined with LEFT, RIGHT, INNER +* Add tests +* Postgres NATURAL LEFT/RIGHT joins +* Amend readme +* Revert successful Oracle test + +[74a0f](https://github.com/JSQLParser/JSqlParser/commit/74a0f2fb22e24fe) manticore-projects *2022-06-28 20:15:34* + +**compound statement tests (#1545)** + + +[c1c38](https://github.com/JSQLParser/JSqlParser/commit/c1c38fe26b1fe90) Matthew Rathbone *2022-06-08 19:11:08* + +**Allow isolation keywords as column name and aliases (#1534)** + + +[fc5a9](https://github.com/JSQLParser/JSqlParser/commit/fc5a9a3dbb91e8e) Tomer Shay (Shimshi) *2022-05-19 21:01:44* + +**added github action badge** + + +[e4ec0](https://github.com/JSQLParser/JSqlParser/commit/e4ec041bdcf5683) Tobias *2022-05-16 09:31:36* + +**Create maven.yml** + +* started maven build using github actions + +[b7e5c](https://github.com/JSQLParser/JSqlParser/commit/b7e5c151df37f5e) Tobias *2022-05-16 09:24:24* + +**introduced deparser and toString correction for insert output clause** + + +[51105](https://github.com/JSQLParser/JSqlParser/commit/5110598f0a2a774) Tobias Warneke *2022-05-15 22:07:19* + +**revived compilable status after merge** + + +[75489](https://github.com/JSQLParser/JSqlParser/commit/75489bfc3a0355c) Tobias Warneke *2022-05-15 21:29:21* + +**INSERT with SetOperations (#1531)** + +* INSERT with SetOperations +* Simplify the INSERT production +* Use SetOperations for Select and Values +* Better Bracket handling for WITH ... SELECT ... +* Fixes #1491 +* INSERT with SetOperations +* Appease Codazy/PMD +* INSERT with SetOperations +* Appease Codazy/PMD +* Update Readme +* List the changes +* Minor rephrases +* Correct the Maven Artifact Example +* Fix the two test cases (missing white space) +* Remove unused import + +[b5672](https://github.com/JSQLParser/JSqlParser/commit/b5672c54386cdf8) manticore-projects *2022-05-15 20:29:06* + +**#1516 rename without column keyword (#1533)** + +* 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 +* `RENAME ... TO ...` without `COLUMN` keyword +* Fixes #1516 + +[e8f07](https://github.com/JSQLParser/JSqlParser/commit/e8f0750d75e74c7) manticore-projects *2022-05-11 20:44:34* + +**Add support for `... ALTER COLUMN ... DROP DEFAULT` (#1532)** + + +[de0e8](https://github.com/JSQLParser/JSqlParser/commit/de0e8715ad7cab5) manticore-projects *2022-05-11 20:37:08* + +**** + + +[81caf](https://github.com/JSQLParser/JSqlParser/commit/81caf3af5eb2762) Tobias Warneke *2022-05-11 20:15:28* + +**#1527 DELETE ... RETURNING ... (#1528)** + +* #1527 DELETE ... RETURNING ... +* Fixes #1527 +* Add DELETE... RETURNING ... expression +* Simplify INSERT ... RETURNING ... expression +* Simply UPDATE ... RETURNING ... expression +* TSQL Output Clause +* According to https://docs.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql?view=sql-server-ver15 +* Implement Output Clause for INSERT, UPDATE and DELETE +* Add Tests according the Microsoft Documentation +* Appease Codacy/PMD + +[4d815](https://github.com/JSQLParser/JSqlParser/commit/4d8152159454069) manticore-projects *2022-05-11 20:04:23* + +**fixs #1520 (#1521)** + + +[f7f9d](https://github.com/JSQLParser/JSqlParser/commit/f7f9d270b13377d) chiangcho *2022-05-11 19:51:47* + +**** + + +[22fef](https://github.com/JSQLParser/JSqlParser/commit/22fef8c95eddbce) Tobias Warneke *2022-05-11 19:45:25* + +**Unsupported statement (#1519)** + +* 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 +* 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 +* Implement UnsupportedStatement +* - Add Feature allowUnsupportedStatement, default=false +* - Fully implement UnsupportedStatement for the Statement() production +* - Partially implement UnsupportedStatement for the Statements() production, works only when UnsupportedStatement comes first +* Revert unintended changes of the test resources +* Reformat BLOCK production +* Disable STATEMENTS() test, which will never fail and add comments to this regard + +[59bb9](https://github.com/JSQLParser/JSqlParser/commit/59bb9a4e40753cf) manticore-projects *2022-05-11 19:23:35* + +**fixes #1518** + + +[bc113](https://github.com/JSQLParser/JSqlParser/commit/bc11309777df6b4) Tobias Warneke *2022-04-26 21:06:44* + +**Update bug_report.md (#1512)** + +* Focus more on the particular SQL Statement and the JSQLParser Version. +* Link to the Online Formatter for testing. + +[13441](https://github.com/JSQLParser/JSqlParser/commit/13441f47fbd8023) manticore-projects *2022-04-22 22:29:07* + +**changed to allow #1481** + + +[0cc2a](https://github.com/JSQLParser/JSqlParser/commit/0cc2a29c4d7b3ad) Tobias Warneke *2022-04-22 21:56:27* + +**Performance Improvements (#1439)** + +* 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 +* Performance Improvements +* Simplify the Primary Expression Production +* Try to simple parse without Complex Expressions first, before parsing complex and slow (if supported by max nesting depth) +* Add Test cases for issues #1397 and #1438 +* Update Libraries to its latest version +* Remove JUnit 4 from Gradle +* Appease PMD +* Update Gradle Plugins to its latest versions +* Let Parser timeout after 6 seconds and fail gently +* Add a special test verifying the clean up after timeout +* Revert unintended changes to the Test Resources +* Appease PMD/Codacy +* Correct the Gradle "+" dependencies +* Bump version to 4.4.-SNAPSHOT +* update build file +* revert unwarranted changes in test files +* strip the Exception Class Name from the Message +* maxDepth = 10 collides with the Parser Timeout = 6 seconds +* License Headers +* Unused imports +* Bump version to 4.5-SNAPSHOT +* Reduce test loops to fit intothe timeout + +[181a2](https://github.com/JSQLParser/JSqlParser/commit/181a21ab90870e1) manticore-projects *2022-04-14 21:18:18* + + +## jsqlparser-4.4 (2022-04-10) + +### Other changes + +**** + + +[00b24](https://github.com/JSQLParser/JSqlParser/commit/00b2440852b847a) Tobias Warneke *2022-04-09 22:43:11* + +**Json function Improvements (#1506)** + +* 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 +* Improve JSON Functions +* Space around the `:` delimiter of JSON Functions +* Improve JSON Functions +* Enforce `KEY` as `S_CHAR_LITERAL` +* Allow `Column` as `VALUE` +* Temporarily disable Postgres Syntax +* Improve JSON Functions +* Bring back Postgres Syntax +* Enable MySQL Syntax JSON_OBJECT(key, value [, key, value, ...]) +* Fix some more tests, where key was not a String +* Appease Codacy +* Let JSON_OBJECT accept Expressions as value +* set Version = 4.4-SNAPSHOT + +[e3f53](https://github.com/JSQLParser/JSqlParser/commit/e3f531caf7ad9ba) manticore-projects *2022-04-09 22:37:36* + +**fixes #1505** + + +[41c77](https://github.com/JSQLParser/JSqlParser/commit/41c77ca5dd75ae1) Tobias Warneke *2022-04-09 21:16:45* + +**** + + +[f3fac](https://github.com/JSQLParser/JSqlParser/commit/f3facb762de3ef7) Tobias Warneke *2022-04-09 20:20:23* + +**fixes #1502** + + +[fea85](https://github.com/JSQLParser/JSqlParser/commit/fea8575fbed4cbb) Tobias Warneke *2022-04-09 20:10:41* + +**Issue1500 - Circular References in `AllColumns` and `AllTableColumns` (#1501)** + +* 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 +* Remove circular reference revealed by issue #1500 +* Add test for Issue 1500 Circular reference for All Columns Expression +* Fix Test case +* Add Test for AllTableColumn due to similar circular reference +* Remove similar circular reference from AllTableColumn +* Update dependencies +* Adjust Jacoco Missed Lines count + +[0949d](https://github.com/JSQLParser/JSqlParser/commit/0949df9d789123c) manticore-projects *2022-04-03 18:51:35* + +**** + + +[62677](https://github.com/JSQLParser/JSqlParser/commit/62677a68fcc5c34) Tobias Warneke *2022-04-02 23:59:19* + +**Optimize assertCanBeParsedAndDeparsed (#1389)** + +* Optimize assertCanBeParsedAndDeparsed +* - Avoid redundant calls of buildSqlString() +* - Replace String.replaceAll() with Matcher.replaceAll() based on precompiled Regex Patterns +* Reset the testcase results + +[ea316](https://github.com/JSQLParser/JSqlParser/commit/ea3164a1e418f3b) manticore-projects *2022-04-02 22:40:09* + +**Add geometry distance operator (#1493)** + +* Add support for geometry distance operators in PostGIS. +* Fix missing imports. +* Co-authored-by: Thomas Powell <tpowell@palantir.com> + +[98c47](https://github.com/JSQLParser/JSqlParser/commit/98c476a6c9fa1a1) Thomas Powell *2022-04-02 22:31:08* + +**Support WITH TIES option in TOP #1435 (#1479)** + +* Support WITH TIES option in TOP +* - Add the support of WITH TIES option in SELECT TOP statement. +* add specific test + +[1756a](https://github.com/JSQLParser/JSqlParser/commit/1756adcade48fb4) Olivier Cavadenti *2022-04-02 21:26:54* + +**fixes #1482** + + +[7ddb7](https://github.com/JSQLParser/JSqlParser/commit/7ddb7c8e056be6d) Tobias Warneke *2022-03-15 21:51:56* + +**fixes #1482** + + +[251cc](https://github.com/JSQLParser/JSqlParser/commit/251cc3c09c477d1) Tobias Warneke *2022-03-15 21:48:13* + +**Extending CaseExpression, covering #1458 (#1459)** + +* Add unit tests for Case expressions. +* More tests for CaseExpression. +* Switch expression becomes an Expression instead of a Condition. +* It allows complex expressions in the switch, similarly to what is allowed in when clauses. + +[4df13](https://github.com/JSQLParser/JSqlParser/commit/4df1391a28a7402) Mathieu Goeminne *2022-03-15 20:07:43* + +**fixes #1471** + + +[3695e](https://github.com/JSQLParser/JSqlParser/commit/3695e0479448ab9) Tobias Warneke *2022-02-18 23:03:24* + +**fixes #1471** + + +[e789c](https://github.com/JSQLParser/JSqlParser/commit/e789c9c7869dc27) Tobias Warneke *2022-02-18 22:32:04* + +**fixes #1470** + + +[c7075](https://github.com/JSQLParser/JSqlParser/commit/c70758266b5af51) Tobias Warneke *2022-02-06 22:21:12* + +**Add support for IS DISTINCT FROM clause (#1457)** + +* Co-authored-by: Tomer Shay <tomer@Tomers-MBP.lan> + +[31ed3](https://github.com/JSQLParser/JSqlParser/commit/31ed383ff0f3903) Tomer Shay (Shimshi) *2022-01-18 07:01:14* + +**fix fetch present in the end of union query (#1456)** + + +[6e632](https://github.com/JSQLParser/JSqlParser/commit/6e6321481a15965) chiangcho *2022-01-18 07:00:14* + +**added SQL_CACHE implementation and changed** + + +[cf012](https://github.com/JSQLParser/JSqlParser/commit/cf0128ac884c2b8) Tobias Warneke *2022-01-09 12:16:39* + +**support for db2 with ru (#1446)** + + +[3e976](https://github.com/JSQLParser/JSqlParser/commit/3e976528094e646) chiangcho *2021-12-20 22:50:56* + +**** + + +[13878](https://github.com/JSQLParser/JSqlParser/commit/1387891cc837f64) Tobias Warneke *2021-12-12 15:37:58* + + +## jsqlparser-4.3 (2021-12-12) + +### Other changes + +**updated readme.md to show all changes for version 4.3** + + +[f0396](https://github.com/JSQLParser/JSqlParser/commit/f039659d1fb5b35) Tobias Warneke *2021-12-12 15:20:32* + +**Adjust Gradle to JUnit 5 (#1428)** + +* 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 + +[af7bc](https://github.com/JSQLParser/JSqlParser/commit/af7bc1cc06700c3) manticore-projects *2021-11-28 21:43:10* + +**corrected some maven plugin versions** + + +[0acb2](https://github.com/JSQLParser/JSqlParser/commit/0acb28fe33bc7df) Tobias Warneke *2021-11-28 21:40:56* + +**fixes #1429** + + +[bc891](https://github.com/JSQLParser/JSqlParser/commit/bc891e7dcf1d86d) Tobias Warneke *2021-11-23 06:29:25* + +**closes #1427** + + +[46424](https://github.com/JSQLParser/JSqlParser/commit/46424d93784f205) Tobias Warneke *2021-11-21 19:42:11* + +**CreateTableTest** + + +[50ef7](https://github.com/JSQLParser/JSqlParser/commit/50ef7edc3ed6bd6) Tobias Warneke *2021-11-21 12:21:21* + +**Support EMIT CHANGES for KSQL (#1426)** + +* - Add the EMIT CHANGES syntax used in KSQL. + +[f6c17](https://github.com/JSQLParser/JSqlParser/commit/f6c17412accdd18) Olivier Cavadenti *2021-11-21 12:20:56* + +**SelectTest.testMultiPartColumnNameWithDatabaseNameAndSchemaName** + + +[d8735](https://github.com/JSQLParser/JSqlParser/commit/d873526fe9f9a38) Tobias Warneke *2021-11-21 12:17:29* + +**reformatted test source code** + + +[fb455](https://github.com/JSQLParser/JSqlParser/commit/fb455a7efe1ed04) Tobias Warneke *2021-11-21 12:11:43* + +**organize imports** + + +[31921](https://github.com/JSQLParser/JSqlParser/commit/31921285376bb41) Tobias Warneke *2021-11-21 12:09:26* + +**replaced all junit 3 and 4 with junit 5 stuff** + + +[2c672](https://github.com/JSQLParser/JSqlParser/commit/2c6724769e76429) Tobias Warneke *2021-11-21 12:03:37* + +**** + + +[fce5b](https://github.com/JSQLParser/JSqlParser/commit/fce5b9953a5a9c1) Tobias Warneke *2021-11-20 00:08:05* + +**Support RESTART without value (#1425)** + +* Since Postgre 8.4, RESTART in ALTER SEQUENCE can be set without value. + +[98b66](https://github.com/JSQLParser/JSqlParser/commit/98b66be4b2919df) Olivier Cavadenti *2021-11-20 00:00:32* + +**Add support for oracle UnPivot when use multi columns at once. (#1419)** + +* Co-authored-by: LeiJun <02280245@yto.net.cn> + +[8e8bb](https://github.com/JSQLParser/JSqlParser/commit/8e8bb708636e6c6) LeiJun *2021-11-19 23:22:29* + +**** + + +[1fe92](https://github.com/JSQLParser/JSqlParser/commit/1fe92bc61914135) Tobias Warneke *2021-11-19 22:36:41* + +**Fix issue in parsing TRY_CAST() function (#1391)** + +* Fix issue in parsing TRY_CAST() function +* Fix issue in parsing TRY_CAST() function +* Add parser, deparser, validator and vistior implementation for try_cast function +* Update toString() method of TryCastExpression class + +[bfcf0](https://github.com/JSQLParser/JSqlParser/commit/bfcf00f9dfcc0a3) Prashant Sutar *2021-11-19 22:24:49* + +**fixes #1414** + + +[93b8c](https://github.com/JSQLParser/JSqlParser/commit/93b8c8b96d5558d) Tobias Warneke *2021-11-19 22:21:21* + +**Add support for expressions (such as columns) in AT TIME ZONE expressions (#1413)** + +* Co-authored-by: EverSQL <tomer@eversql.com> + +[ebe17](https://github.com/JSQLParser/JSqlParser/commit/ebe171b3b502089) Tomer Shay (Shimshi) *2021-11-19 22:04:40* + +**Add supported for quoted cast expressions for PostgreSQL (#1411)** + +* Co-authored-by: EverSQL <tomer@eversql.com> + +[dbbce](https://github.com/JSQLParser/JSqlParser/commit/dbbcebbf0490e1c) Tomer Shay (Shimshi) *2021-11-19 21:54:37* + +**added USE SCHEMA and CREATE OR REPLACE
support; things that are allowed in Snowflake SQL (#1409)** + +* Co-authored-by: Richard Kooijman <richard.kooijman@inergy.nl> + +[f35d2](https://github.com/JSQLParser/JSqlParser/commit/f35d24cfbb88342) Richard Kooijman *2021-11-19 21:40:45* + +**Issue #420 Like Expression with Escape Expression (#1406)** + +* Issue #420 Like Expression with Escape Expression +* Fixes issue #420 +* CheckStyle compliance + +[8eaa4](https://github.com/JSQLParser/JSqlParser/commit/8eaa4d2fc243f0a) manticore-projects *2021-11-19 21:38:54* + +**fixes #1405 and some junit.jupiter stuff** + + +[9adab](https://github.com/JSQLParser/JSqlParser/commit/9adab8d059685ff) Tobias Warneke *2021-11-19 21:32:23* + +**#1401 add junit-jupiter-api (#1403)** + + +[80ff5](https://github.com/JSQLParser/JSqlParser/commit/80ff50e0296c107) gitmotte *2021-11-19 21:10:18* + +**Support Postgres Dollar Quotes #1372 (#1395)** + + +[0bd4c](https://github.com/JSQLParser/JSqlParser/commit/0bd4c198e483616) Olivier Cavadenti *2021-11-19 20:32:26* + +**Add Delete / Update modifiers for MySQL #1254 (#1396)** + +* Add Delete / Update modifiers for MySQL #1254 +* fix codacy issues + pr return +* simplify low_priority + +[7be5d](https://github.com/JSQLParser/JSqlParser/commit/7be5d8e65e23f6e) Olivier Cavadenti *2021-11-19 20:31:00* + +**Fixes #1381 (#1383)** + +* Allow Complex Expressions as SelectItem + +[cdf0f](https://github.com/JSQLParser/JSqlParser/commit/cdf0f095294b04a) manticore-projects *2021-11-19 20:27:44* + +**Allows CASE ... ELSE ComplexExpression (#1388)** + +* Fixes #1375 +* Co-authored-by: Tobias <t.warneke@gmx.net> + +[60a7d](https://github.com/JSQLParser/JSqlParser/commit/60a7d103853cb5e) manticore-projects *2021-11-02 20:48:39* + +**IN() with complex expressions (#1384)** + +* IN() with Complex Expressions +* Fixes #905 +* Allow Complex Expressions and multiple SubSelects for the IN() Expression +* Tune the Test Coverage +* Remove unused import +* Reset TEST status + +[c4232](https://github.com/JSQLParser/JSqlParser/commit/c42322440d5fb36) manticore-projects *2021-11-01 21:23:48* + +**Fixes #1385 and PR#1380 (#1386)** + +* Add another Alias() Keyword related LOOKAHEAD +* Fix a Keyword Spelling Error in the Deparser +* Remove UNPIVOT from the PARENTHESIS Deparser, as it was an ugly workaround made obsolete by PR #1380 + +[8c1eb](https://github.com/JSQLParser/JSqlParser/commit/8c1eba24be61cf0) manticore-projects *2021-10-22 20:19:15* + +**Fixes #1369 (#1370)** + +* Issue1369 +* Add test + +[2335e](https://github.com/JSQLParser/JSqlParser/commit/2335ed136e92163) Ben Grabham *2021-10-20 21:44:06* + +**Fixes #1371 (#1377)** + +* Fixes #1371 +* Postgres specific JSON_OBJECT syntax supporting: +* SELECT json_object('{a, 1, b, 2}'); +* SELECT json_object('{{a, 1}, {b, 2}}'); +* SELECT json_object('{a, b}', '{1,2 }'); +* Improve Test Coverage + +[cbffe](https://github.com/JSQLParser/JSqlParser/commit/cbffe6b58cd0074) manticore-projects *2021-10-20 21:13:54* + +**LIMIT OFFSET with Expressions (#1378)** + +* Fixes #933 + +[a52db](https://github.com/JSQLParser/JSqlParser/commit/a52db54ff61be34) manticore-projects *2021-10-20 21:05:27* + +**Oracle Multi Column Drop (#1379)** + +* Fixes #1363 + +[9ad18](https://github.com/JSQLParser/JSqlParser/commit/9ad18d29efb66a2) manticore-projects *2021-10-20 21:01:04* + +**Support alias for UnPivot statement (see discussion #1374) (#1380)** + +* - Changed JSqlParserCC.jjt file to add the alias to the UnPivot lexical entity. +* - Added Alias to the UnPivot object. +* - Improved SelectDeParser to correctly deparse SubSelect's UnPivot component. + +[0c0c3](https://github.com/JSQLParser/JSqlParser/commit/0c0c32e9cda0f1a) fabriziodelfranco *2021-10-20 20:18:13* + +**Issue1352 (#1353)** + +* Fixes #1352 +* Allow SYSTEM as table- or column- name +* Fixes #1352 +* Allow SYSTEM as tablename +* Fixes #1352 +* Allow SYSTEM as tablename and columnname +* Fixes #1352 +* Allow QUERY as tablename and columnname +* Fixes #1352 +* Allow FULLTEXT as tablename and columnname +* Co-authored-by: Tobias <t.warneke@gmx.net> + +[a8afd](https://github.com/JSQLParser/JSqlParser/commit/a8afd9a4e6a8bc0) manticore-projects *2021-10-09 21:31:45* + +**Enhance ALTER TABLE ... DROP CONSTRAINTS ... (#1351)** + +* Enhance ALTER TABLE ... DROP CONSTRAINTS ... +* Add support for DROP PRIMARY KEY, DROP UNIQUE(...) +* Add support for DROP FOREIGN KEY(...) +* Fixes #1342 +* Remove one useless PMD rule +* Add more tests +* Adjust Test Coverage + +[388b7](https://github.com/JSQLParser/JSqlParser/commit/388b7c3afff4f50) manticore-projects *2021-10-08 23:02:46* + +**Function to use AllColumns or AllTableColumns Expression (#1350)** + +* Fix a trivial MERGE error from Commit 4797a8d676625fcc6cf8c9e3b403ca120b6a8141 +* Function use AllColumns or AllTableColumns +* Fixes #1346 +* Remove one useless PMD rule + +[b0ada](https://github.com/JSQLParser/JSqlParser/commit/b0adaa8de1421ea) manticore-projects *2021-10-08 21:58:04* + +**Postgres compliant ALTER TABLE ... RENAME TO ... (#1334)** + +* Fix a trivial MERGE error from Commit 4797a8d676625fcc6cf8c9e3b403ca120b6a8141 +* Fixes #1333 +* Postgres compliant ALTER TABLE ... RENAME TO ... +* Postgres compliant ALTER TABLE IF EXISTS ... RENAME TO ... +* Postgres compliant ALTER TABLE IF EXISTS ... RENAME TO ... + +[f353e](https://github.com/JSQLParser/JSqlParser/commit/f353ec830deb719) manticore-projects *2021-09-18 11:35:17* + +**Postgres compliant ALTER TABLE ... RENAME TO ... (#1334)** + +* Fix a trivial MERGE error from Commit 4797a8d676625fcc6cf8c9e3b403ca120b6a8141 +* Fixes #1333 +* Postgres compliant ALTER TABLE ... RENAME TO ... +* Postgres compliant ALTER TABLE IF EXISTS ... RENAME TO ... +* Postgres compliant ALTER TABLE IF EXISTS ... RENAME TO ... + +[5e904](https://github.com/JSQLParser/JSqlParser/commit/5e9045f431d9cc4) manticore-projects *2021-09-18 11:34:50* + +**corrected readme to the new snapshot version** + + +[b8867](https://github.com/JSQLParser/JSqlParser/commit/b8867d71c0f29d3) Tobias Warneke *2021-09-08 09:57:36* + + +## jsqlparser-4.2 (2021-09-08) + +### Other changes + +**introducing test for issue #1328** + + +[56a39](https://github.com/JSQLParser/JSqlParser/commit/56a39a4693a991f) Tobias Warneke *2021-09-07 09:57:20* + +**included some distinct check** + + +[1264a](https://github.com/JSQLParser/JSqlParser/commit/1264a2033c0062a) Tobias Warneke *2021-09-07 09:49:48* + +**corrected a merge bug** + + +[d53f8](https://github.com/JSQLParser/JSqlParser/commit/d53f8a7fb6b898c) Tobias Warneke *2021-09-07 09:28:35* + +**Prepare4.2 (#1329)** + +* Implement caching of the Gradle and Maven files +* Provided by @YunLemon via PR #1307 +* Fix CREATE TABLE AS SELECT ... UNION SELECT ... +* Provided by @fanchuo via PR #1309 +* Fix #1316 +* Add more specific tests verifying the nature of the UpdateSets +* Allow "SELECT *" (without FROM) to parse, its a valid SELECT statement +* Add the enhancements since Release 4.1 +* Adjust the Coverage +* Improve Test Coverage +* Revert the Special Oracle Tests (accidentally set to FAILURE) +* Co-authored-by: Tobias <t.warneke@gmx.net> + +[4797a](https://github.com/JSQLParser/JSqlParser/commit/4797a8d676625fc) manticore-projects *2021-09-07 08:56:12* + +**CREATE TABLE AS (...) UNION (...) fails (#1309)** + + +[a7b5c](https://github.com/JSQLParser/JSqlParser/commit/a7b5c2b078e3ebe) François Sécherre *2021-09-07 08:51:01* + +**Fixes #1325 (#1327)** + +* Removes redundant production Identifier() and uses RelObjectnameWithoutValue() instead for MS SQL Server Hints + +[cf0d7](https://github.com/JSQLParser/JSqlParser/commit/cf0d74f6572d6aa) manticore-projects *2021-09-06 12:09:01* + +**Implement Joins with multiple trailing ON Expressions (#1303)** + +* Implement Joins with multiple trailing ON Expressions +* Fixes #1302 +* Fixes SpecialOracleTest JOIN17, now 190/273 tests pass +* Fixes #1229 +* Merge MASTER +* Refactor the appendTo() method in favour of the traditional toString() +* Remove unused imports + +[d18c5](https://github.com/JSQLParser/JSqlParser/commit/d18c59bf845c57d) manticore-projects *2021-09-06 11:34:05* + +**Fix Gradle PMD and Checkstyle (#1318)** + +* Fixes #1306 +* Nested Cases with Complex Expressions +* Reduce coverage for Java 8 +* GROUP BY with Complex Expressions +* Fixes #1308 +* Update Sets with Complex Expressions +* Fixes #1316 +* Update Sets with Complex Expressions +* Fix existing tests +* Add tests for the new functionality +* Implement PMD/Codacy recommendations +* Add Checkstyle Configuration to Gradle +* Add Checkstyle Config files +* Fix additional exceptions in Test Sources + +[2e876](https://github.com/JSQLParser/JSqlParser/commit/2e876130b46d087) manticore-projects *2021-09-01 22:01:40* + +**** + + +[3f2e7](https://github.com/JSQLParser/JSqlParser/commit/3f2e76cf07ba699) Tobias Warneke *2021-08-28 20:59:29* + +**Fixes #1306 (#1311)** + +* Fixes #1306 +* Nested Cases with Complex Expressions +* Reduce coverage for Java 8 +* GROUP BY with Complex Expressions +* Fixes #1308 + +[8f632](https://github.com/JSQLParser/JSqlParser/commit/8f632b92e511b28) manticore-projects *2021-08-28 20:28:55* + +**Update sets (#1317)** + +* Fixes #1306 +* Nested Cases with Complex Expressions +* Reduce coverage for Java 8 +* GROUP BY with Complex Expressions +* Fixes #1308 +* Update Sets with Complex Expressions +* Fixes #1316 +* Update Sets with Complex Expressions +* Fix existing tests +* Add tests for the new functionality +* Implement PMD/Codacy recommendations + +[21e5e](https://github.com/JSQLParser/JSqlParser/commit/21e5ebac02822e2) manticore-projects *2021-08-27 21:37:05* + +**** + + +[50313](https://github.com/JSQLParser/JSqlParser/commit/50313376d5e6554) Tobias Warneke *2021-08-25 21:12:12* + +**Special oracle tests (#1279)** + +* Allow keywords: LINK, GROUPING() +* Deparse ParenthesisFromItem's Pivot and UnPivot correctly +* Write Test results to the SQL File +* Reduce the noise during the test +* Update/correct the list of expected passing files +* Get the benchmark from the list of expected passing files +* There are no Pivots or UnPivots yet, so we will return NULL. +* Record the expected Test Results on each SQL Source +* Fail the test when any expected success suddenly fails +* Improve Test Coverage +* Appease Codacy + +[346ee](https://github.com/JSQLParser/JSqlParser/commit/346eea5fbcf2461) manticore-projects *2021-08-09 21:55:00* + +**Implements Hierarchical CONNECT_BY_ROOT Operator (#1282)** + +* Implements Hierarchical CONNECT_BY_ROOT Operator +* Fixes Issue #1269 +* Resolves some Special Oracle Tests +* Improve Test Coverage +* Co-authored-by: Tobias <t.warneke@gmx.net> + +[b6014](https://github.com/JSQLParser/JSqlParser/commit/b60140740aab93e) manticore-projects *2021-08-09 21:53:08* + +**Implement Transact-SQL IF ELSE Statement Control Flows. (#1275)** + +* Implement Transact-SQL IF ELSE Statement Control Flows. +* Fixes #1273 except for Blocks. +* Improce Test Coverage +* Adjust the required Test Coverage for JDK 8 + +[750c3](https://github.com/JSQLParser/JSqlParser/commit/750c30aafe83957) manticore-projects *2021-08-09 21:43:50* + +**Add some flexibility to the Alter Statement (#1293)** + +* in order to allow: +* ALTER TABLE ... MOVE TABLESPACE ... +* ALTER TABLE ... COMPRESS NOLOGGING +* ALTER TABLE ... ROWFORMAT=DYNAMIC +* Fixes #1033 + +[a88e9](https://github.com/JSQLParser/JSqlParser/commit/a88e921970c57b8) manticore-projects *2021-08-02 20:51:19* + +**Implement Oracle's Alter System (#1288)** + + +[4ac5a](https://github.com/JSQLParser/JSqlParser/commit/4ac5ab468b1dd1d) manticore-projects *2021-08-02 20:37:40* + +**Implement Oracle Named Function Parameters Func( param1 => arg1, ...) (#1283)** + +* Fixes #1270 + +[c8a5d](https://github.com/JSQLParser/JSqlParser/commit/c8a5d7c3dfc97f4) manticore-projects *2021-08-02 20:32:41* + +**Implement Gradle Buildsystem (#1271)** + +* Gradle build +* implement SpotBugs, PMD and JaCoCo +* implement RR diagrams +* Move Special Oracle Test resources into the correct package +* Implement a basic Gradle/Maven compatibility workaround for the Special Oracle Test +* Fix the Gradle Wrapper and add the folder to git + +[6933d](https://github.com/JSQLParser/JSqlParser/commit/6933d86e0fa2d48) manticore-projects *2021-08-02 20:18:48* + +**fixes #1272** + + +[48a11](https://github.com/JSQLParser/JSqlParser/commit/48a1133ced7dd19) Tobias Warneke *2021-07-26 21:14:20* + +**Allowes JdbcParameter or JdbcNamedParameter for MySQL FullTextSearch (#1278)** + +* Fixes issue #1223 + +[e6c91](https://github.com/JSQLParser/JSqlParser/commit/e6c91b6a813a1e0) manticore-projects *2021-07-26 21:06:38* + +**Fixes #1267 Cast into RowConstructor (#1274)** + +* Fixes #1267 Cast into RowConstructor +* Improve Test Coverage +* Improve Test Coverage +* Improve Test Coverage +* Co-authored-by: Tobias <t.warneke@gmx.net> + +[c89cf](https://github.com/JSQLParser/JSqlParser/commit/c89cf21641d672b) manticore-projects *2021-07-26 21:02:19* + +**** + + +[fecc9](https://github.com/JSQLParser/JSqlParser/commit/fecc95d0ee93100) Tobias Warneke *2021-07-26 20:47:58* + +**Separate MySQL Special String Functions accepting Named Argument Separation as this could collide with ComplexExpressionList when InExpression is involved (#1285)** + +* Fixes #1284 +* Co-authored-by: Tobias <t.warneke@gmx.net> + +[c074a](https://github.com/JSQLParser/JSqlParser/commit/c074a21ad70dd0e) manticore-projects *2021-07-26 20:34:06* + +**Implements Oracle RENAME oldTable TO newTable Statement (#1286)** + +* Implements Oracle RENAME oldTable TO newTable Statement +* Fixes #1253 +* Implement MariaDB specific syntax +* Remove redundant License Headers +* Use LinkedHashMap to preserve the order of the Entries +* Increase Test Coverage +* Co-authored-by: Tobias <t.warneke@gmx.net> + +[f7f7b](https://github.com/JSQLParser/JSqlParser/commit/f7f7bcd65be8f4c) manticore-projects *2021-07-26 20:26:47* + +**Implement Oracle Purge Statement (#1287)** + + +[f86bc](https://github.com/JSQLParser/JSqlParser/commit/f86bc2e432305fb) manticore-projects *2021-07-26 20:18:39* + +**included jacoco to allow code coverage for netbeans** + + +[f85b4](https://github.com/JSQLParser/JSqlParser/commit/f85b4b630008d9e) Tobias Warneke *2021-07-18 21:15:14* + +**corrected a Lookahead problem** + + +[db90e](https://github.com/JSQLParser/JSqlParser/commit/db90e74f1d5d6e8) Tobias Warneke *2021-07-16 21:31:17* + +**Json functions (#1263)** + +* Implement Json Aggregate Functions JSON_OBJECTAGG() and JSON_ARRAYAGG() +* fix the returned type +* Implement JSON_OBJECT and JSON_ARRAY +* Solves #1260 and dbeaver/dbeaver/#13141 +* Better workaround for NULL, NULL NULL ON NULL +* Remove the workaround for NULL ON NULL (without expression) +* Implement "PMD.MissingBreakInSwitch" in order to appease Codacy +* Improve Test Coverage +* Improve Test Coverage +* KEYs can be SQL Value Expressions +* Add another testcase + +[59bf0](https://github.com/JSQLParser/JSqlParser/commit/59bf07f5425ecb4) manticore-projects *2021-07-16 21:24:44* + +**fixes #1255** + + +[2c732](https://github.com/JSQLParser/JSqlParser/commit/2c732ad9bfbe34e) Tobias Warneke *2021-07-16 21:12:45* + +**Active JJDoc and let it create the Grammar BNF documentation (#1256)** + +* Clean-up the Site generation + +[1ecff](https://github.com/JSQLParser/JSqlParser/commit/1ecffd2c1a6e8d8) manticore-projects *2021-07-16 20:38:05* + +**Bump commons-io from 2.6 to 2.7 (#1265)** + +* Bumps commons-io from 2.6 to 2.7. +* --- +* updated-dependencies: +* - dependency-name: commons-io:commons-io +* dependency-type: direct:development +* ... +* Signed-off-by: dependabot[bot] <support@github.com> +* Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +[09898](https://github.com/JSQLParser/JSqlParser/commit/09898107fe6d001) dependabot[bot] *2021-07-14 05:27:57* + +**Update README.md** + + +[e6303](https://github.com/JSQLParser/JSqlParser/commit/e630354df1cd0f4) Tobias *2021-07-13 05:34:12* + +**Implement DB2 Special Register Date Time CURRENT DATE and CURRENT TIME (#1252)** + +* Implement DB2 Special Register Date Time CURRENT DATE and CURRENT TIME +* Fixes issue #1249 +* (Although there are more Special Registers which are not supported yet.) +* Make the spaces mandatory +* Add 2 more tests + +[05157](https://github.com/JSQLParser/JSqlParser/commit/05157a841897033) manticore-projects *2021-07-13 05:32:38* + +**Rename the PMD ruleset configuration file hoping for automatic synchronization with Codacy (#1251)** + +* Solves Issue #1220 + +[930b7](https://github.com/JSQLParser/JSqlParser/commit/930b7a561876b7e) manticore-projects *2021-07-13 05:28:43* + +**corrected .travis.yml** + + +[11124](https://github.com/JSQLParser/JSqlParser/commit/111244ab565a160) Tobias Warneke *2021-07-05 20:57:22* + +**corrected .travis.yml** + + +[5cf7e](https://github.com/JSQLParser/JSqlParser/commit/5cf7eeaa6f7074d) Tobias Warneke *2021-07-05 20:52:40* + +**** + + +[3e0e7](https://github.com/JSQLParser/JSqlParser/commit/3e0e7f38a11fe21) Tobias Warneke *2021-07-05 20:39:11* + +**Update README.md** + + +[ec16d](https://github.com/JSQLParser/JSqlParser/commit/ec16d1f68c83063) Tobias *2021-07-05 20:27:41* + +**fixes #1250** + + +[9e434](https://github.com/JSQLParser/JSqlParser/commit/9e4341a26be1f7f) Tobias Warneke *2021-07-01 12:24:36* + +**** + + +[05d68](https://github.com/JSQLParser/JSqlParser/commit/05d684416f338b6) Tobias Warneke *2021-06-30 22:12:00* + + +## jsqlparser-4.1 (2021-06-30) + +### Other changes + +**fixes #1140** + + +[1a917](https://github.com/JSQLParser/JSqlParser/commit/1a9173f7d65a026) Tobias Warneke *2021-06-30 21:50:28* + +**introduced #1248 halfway** + + +[1deea](https://github.com/JSQLParser/JSqlParser/commit/1deeab8b349343f) Tobias Warneke *2021-06-30 21:15:56* + +**Savepoint rollback (#1236)** + +* Implement SAVEPOINT and ROLLBACK statements, fixes issue #1235 +* Activate a test which is supported now. + +[2cae6](https://github.com/JSQLParser/JSqlParser/commit/2cae62dbf74a744) manticore-projects *2021-06-30 19:57:56* + +**Fixes Function Parameter List Brackets issue #1239 (#1240)** + + +[750f3](https://github.com/JSQLParser/JSqlParser/commit/750f3d1e28fa0d9) manticore-projects *2021-06-30 19:45:32* + +**** + + +[0ba44](https://github.com/JSQLParser/JSqlParser/commit/0ba44c59fcea1cc) Tobias Warneke *2021-06-30 19:41:44* + +**corrected javadoc problem** + + +[f7ea4](https://github.com/JSQLParser/JSqlParser/commit/f7ea4a5040ac7c7) Tobias Warneke *2021-06-27 00:20:35* + +**corrected some lookahead problem** + + +[59c2a](https://github.com/JSQLParser/JSqlParser/commit/59c2a9432ee23d7) Tobias Warneke *2021-06-26 23:57:06* + +**RESET statement, SET PostgreSQL compatibility (#1104)** + +* Support +* RESET statement (https://www.postgresql.org/docs/current/sql-reset.html) +* SET [LOCAL|SESSION] (https://www.postgresql.org/docs/current/sql-set.html) +* SET search_path=my_schema, public ( https://www.postgresql.org/docs/current/sql-set.html +* value New value of parameter. Values can be specified as string constants, identifiers, numbers, or comma-separated lists of these) +* Update ResetStatementTest.java +* remove Tim Zone token +* Co-authored-by: Tobias <t.warneke@gmx.net> + +[13503](https://github.com/JSQLParser/JSqlParser/commit/13503edff30f06d) Роман Зотов *2021-06-26 22:44:33* + +**corrected some lookahead problem** + + +[6711f](https://github.com/JSQLParser/JSqlParser/commit/6711f6043c168f7) Tobias Warneke *2021-06-26 22:42:24* + +**Implement Oracle Alter Session Statements (#1234)** + +* Implement Oracle Alter Session Statements according to https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_2012.htm +* Implement PMD Rule "SwitchStmtsShouldHaveDefault" +* Reorganize Test Case imports + +[3a46a](https://github.com/JSQLParser/JSqlParser/commit/3a46a29d6936611) manticore-projects *2021-06-26 22:38:19* + +**fixes #1230** + + +[3082d](https://github.com/JSQLParser/JSqlParser/commit/3082de3a689c88e) Tobias Warneke *2021-06-26 22:31:43* + +**Support DELETE FROM T1 USING T2 WHERE ... (#1228)** + +* Co-authored-by: Francois Secherre <secherre.nospam@gmail.com> + +[96cd4](https://github.com/JSQLParser/JSqlParser/commit/96cd483ab85783d) francois-secherre *2021-06-16 05:27:14* + +**Row access support (#1181)** + +* Row acess support +* Remove IN Left Expression List, replaced by RowConstructor Expression +* Remove IN Left Expression List, replaced by RowConstructor Expression +* Formatting + +[27e6a](https://github.com/JSQLParser/JSqlParser/commit/27e6a9f0e07320e) Роман Зотов *2021-06-16 05:15:47* + +**corrected lookahead problem of PR #1225** + + +[aec76](https://github.com/JSQLParser/JSqlParser/commit/aec76eae23f1edd) Tobias Warneke *2021-06-14 05:27:40* + +**Delete queries without from, with a schema identifier fails (#1224)** + +* Delete queries without from, with a schema identifier fails +* Better tests +* Fix style issue +* Deparse should match for DELETE WITHOUT FROM queries +* Co-authored-by: François Sécherre <francois.secherre@ouicar.fr> + +[d70e1](https://github.com/JSQLParser/JSqlParser/commit/d70e151c0f22f22) François Sécherre *2021-06-14 05:15:15* + +**Create temporary table t(c1, c2) as select ... (#1225)** + +* Co-authored-by: Francois Secherre <secherre.nospam@gmail.com> + +[b62f1](https://github.com/JSQLParser/JSqlParser/commit/b62f19feb3b497c) francois-secherre *2021-06-14 05:13:13* + +**Nested with items (#1221)** + +* Nested WithItems, fixes issue #1186 +* Remove redundant Test +* Avoid altering the nb-configuration +* Mention Nested WITH CTEs in the readme +* Eliminate dead/unused MultiExpression Code + +[8eb3d](https://github.com/JSQLParser/JSqlParser/commit/8eb3d9a586a182e) manticore-projects *2021-06-10 05:50:08* + +**Implement GROUP BY () without columns (#1218)** + +* Implement GROUP BY () without columns +* Migrate GroupByElement to ExpressionList +* Also solves issue #1210 automatically +* Solves issue #1168, add a test for it. + +[999db](https://github.com/JSQLParser/JSqlParser/commit/999db01658c30f9) manticore-projects *2021-06-03 05:55:35* + +**TSQL Compliant NEXT VALUE FOR sequence_id (but keeping the spurious NEXTVAL FOR expression) (#1216)** + +* Co-authored-by: Tobias <t.warneke@gmx.net> + +[7c212](https://github.com/JSQLParser/JSqlParser/commit/7c21242e893abcd) manticore-projects *2021-06-02 12:35:03* + +**Pmd clean up (#1215)** + +* Add PMD Annotations in order to avoid useless exceptions for the Deparsers +* Add Eclipse Formatter configuration +* Fix typo +* Replace Comments on empty methods with Class wide PMD Annotation +* Do not enforce checkstyle formatting + +[53764](https://github.com/JSQLParser/JSqlParser/commit/537649bf28f641b) manticore-projects *2021-06-02 12:19:32* + +**Add support for boolean 'XOR' operator (#1193)** + +* Add support for boolean 'XOR' operator +* XorExpression added to the ReflectionModelTest +* XorExpression case added to the SelectTest +* XorExpression cases added for Validation +* Additional tests added for code coverage. +* Code style fixed. +* Separate test case for XOR added. +* Imports explicitly added to avoid namespace pollution. +* Additional tests cases for precedence and associativity. +* Co-authored-by: Szabó Miklós <miklos.szabo@arh.hu> + +[c7832](https://github.com/JSQLParser/JSqlParser/commit/c7832402dded4c0) Adaptive Recognition *2021-06-02 12:10:56* + +**Update README.md** + + +[1feea](https://github.com/JSQLParser/JSqlParser/commit/1feea013d865f58) Tobias *2021-05-31 08:46:48* + +**Implement WITH for DELETE, UPDATE and MERGE statements (#1217)** + + +[63ed1](https://github.com/JSQLParser/JSqlParser/commit/63ed1a2f42d14e9) manticore-projects *2021-05-31 08:44:08* + +**** + + +[9184c](https://github.com/JSQLParser/JSqlParser/commit/9184cda558e60a5) Tobias Warneke *2021-05-26 23:12:05* + +**** + + +[f83ed](https://github.com/JSQLParser/JSqlParser/commit/f83ed0a3a30f6d4) Tobias Warneke *2021-05-26 23:09:08* + +**** + + +[76bff](https://github.com/JSQLParser/JSqlParser/commit/76bff01b6b4450f) Tobias Warneke *2021-05-26 23:04:41* + +**increases complex scanning range** + + +[13b88](https://github.com/JSQLParser/JSqlParser/commit/13b88f7f511107e) Tobias Warneke *2021-05-26 21:38:44* + +**Allow Complex Parsing of Functions (#1200)** + +* Allow Complex Parsing of Functions +* Fixes issues #1190 #1103 +* Apply Complex Parsing to PrimaryExpression() +* Fixes issue #1194 +* Increase Test Timeout to 2 seconds for slow CI Servers. +* Appease Codazy + +[3a5da](https://github.com/JSQLParser/JSqlParser/commit/3a5da445ea9cb85) manticore-projects *2021-05-26 20:35:10* + +**Add support for AT TIME ZONE expressions (#1196)** + +* Add support for AT TIME ZONE expressions +* adding tests +* Fixing imports + +[a5204](https://github.com/JSQLParser/JSqlParser/commit/a5204f63ccb1ea8) Tomer Shay (Shimshi) *2021-05-25 23:03:31* + +**fixes #1211** + + +[ed089](https://github.com/JSQLParser/JSqlParser/commit/ed089f1f800ece1) Tobias Warneke *2021-05-25 21:52:01* + +**fixes #1212** + + +[b8ee7](https://github.com/JSQLParser/JSqlParser/commit/b8ee7526375c9d9) Tobias Warneke *2021-05-25 21:45:01* + +**** + + +[1c2ac](https://github.com/JSQLParser/JSqlParser/commit/1c2ac7a4e998e76) Tobias Warneke *2021-05-25 21:32:45* + +**** + + +[68695](https://github.com/JSQLParser/JSqlParser/commit/686958cf0bd758b) Tobias Warneke *2021-05-25 19:42:23* + +**Fix Nested CASE WHEN performance, fixes issue #1162 (#1208)** + +* Fix Nested CASE WHEN performance, fixes issue #1162 +* Apease Codazy +* Apease Codazy + +[42610](https://github.com/JSQLParser/JSqlParser/commit/426102e4cf272ca) manticore-projects *2021-05-25 19:26:30* + +**Add support for casts in json expressions (#1189)** + + +[86b61](https://github.com/JSQLParser/JSqlParser/commit/86b613c72428e0c) Tomer Shay (Shimshi) *2021-05-10 20:00:59* + +**fixes #1185** + + +[2320b](https://github.com/JSQLParser/JSqlParser/commit/2320b1baa6e1dea) Tobias Warneke *2021-05-04 21:11:12* + +**** + + +[53745](https://github.com/JSQLParser/JSqlParser/commit/537452dda91bcc3) Tobias Warneke *2021-05-01 20:57:01* + +**** + + +[002f5](https://github.com/JSQLParser/JSqlParser/commit/002f5966c577366) Tobias Warneke *2021-05-01 19:57:10* + +**supporting/fixing unique inside sql function such as count eg - SELECT count(UNIQUE col2) FROM mytable (#1184)** + +* Co-authored-by: Adhikesavan <radhikesavan@paypal.com> + +[f18e9](https://github.com/JSQLParser/JSqlParser/commit/f18e92eaf4b3bc6) RajaSudharsan Adhikesavan *2021-05-01 19:28:05* + +**Oracle compliant ALTER TABLE ADD/MODIFY deparser (#1163)** + +* javadoc-fixes +* fix check-style error : assignment to parameter not allowed +* import for javadoc reference +* javadoc - add description to parameter "fqn" (fix warning) +* remove doclint=none, but exclude package with exclude package with +* generated sources (javacc/jjtree) from javadoc +* Implement Oracle Hints for INSERT, UPDATE, MERGE, DELETE +* Correct CreateIndex TailOptions +* Add a Test Case for CreateIndex TailOptions +* Add WHERE expression to MergeInsert +* Add test case for MergeInsert WHERE expression +* Fix Issue #1156: ALTER TABLE ADD FOREIGN KEY with schema reference +* Add a specific test case +* Fix Issue #1157: Oracle does not accept COLUMN keyword in ALTER TABLE ADD/MODIFY +* Correct the test cases accepting a non existing COLUMN keyword +* Add a specific test cases +* Fix Issue #1164 UNIQUE after PRIMARY KEY +* Add test case for UNIQUE after PRIMARY KEY +* Switch of warnings for un-fixble method namings +* Switch of warnings for un-fixble method namings +* Activate PMD and define our own ruleset +* Execute PMD before building/testing in order to fail early +* Fix 63 PMD warnings +* Activate rule "PMD.CyclomaticComplexity" in order to simulate the Codazy checks +* Apply @SuppressWarnings({"PMD.CyclomaticComplexity"}) where this rule throws an unavoidable warning (especially for toString() and deparse()) +* Activate rule , "PMD.ExcessiveMethodLength" in order to simulate the Codazy checks +* Apply @SuppressWarnings({"PMD.ExcessiveMethodLength"}) where this rule throws an unavoidable warning (especially for toString() and deparse()) +* Refactor an ENUM name +* Refactor an ENUM name and reflect this also in the JavaCC Parser definition file +* Co-authored-by: gitmotte <www@synbee.at> + +[83837](https://github.com/JSQLParser/JSqlParser/commit/838379f21be0d32) manticore-projects *2021-04-21 07:55:17* + +**Pmd (#1165)** + +* Implement Oracle Hints for INSERT, UPDATE, MERGE, DELETE +* Correct CreateIndex TailOptions +* Add a Test Case for CreateIndex TailOptions +* Add WHERE expression to MergeInsert +* Add test case for MergeInsert WHERE expression +* Fix Issue #1156: ALTER TABLE ADD FOREIGN KEY with schema reference +* Add a specific test case +* Fix Issue #1157: Oracle does not accept COLUMN keyword in ALTER TABLE ADD/MODIFY +* Correct the test cases accepting a non existing COLUMN keyword +* Add a specific test cases +* Fix Issue #1164 UNIQUE after PRIMARY KEY +* Add test case for UNIQUE after PRIMARY KEY +* Switch of warnings for un-fixble method namings +* Switch of warnings for un-fixble method namings +* Activate PMD and define our own ruleset +* Execute PMD before building/testing in order to fail early +* Fix 63 PMD warnings +* Activate rule "PMD.CyclomaticComplexity" in order to simulate the Codazy checks +* Apply @SuppressWarnings({"PMD.CyclomaticComplexity"}) where this rule throws an unavoidable warning (especially for toString() and deparse()) +* Activate rule , "PMD.ExcessiveMethodLength" in order to simulate the Codazy checks +* Apply @SuppressWarnings({"PMD.ExcessiveMethodLength"}) where this rule throws an unavoidable warning (especially for toString() and deparse()) +* Refactor an ENUM name +* Refactor an ENUM name and reflect this also in the JavaCC Parser definition file + +[08cfd](https://github.com/JSQLParser/JSqlParser/commit/08cfd29459044c6) manticore-projects *2021-04-20 08:01:48* + +**function order by support (#1108)** + + +[d6ef7](https://github.com/JSQLParser/JSqlParser/commit/d6ef7b995134594) Роман Зотов *2021-04-20 04:16:03* + +**fixes #1159** + + +[79e2f](https://github.com/JSQLParser/JSqlParser/commit/79e2f587ee11297) Tobias Warneke *2021-04-16 23:51:24* + +**added improvements of pr to readme** + + +[0ef4a](https://github.com/JSQLParser/JSqlParser/commit/0ef4a5c8a105a44) Tobias Warneke *2021-04-16 23:02:51* + +**Assorted fixes to the Java CC Parser definition (#1153)** + +* Implement Oracle Hints for INSERT, UPDATE, MERGE, DELETE +* Correct CreateIndex TailOptions +* Add a Test Case for CreateIndex TailOptions +* Add WHERE expression to MergeInsert +* Add test case for MergeInsert WHERE expression +* Fix Issue #1156: ALTER TABLE ADD FOREIGN KEY with schema reference +* Add a specific test case + +[5ee6e](https://github.com/JSQLParser/JSqlParser/commit/5ee6ec9dd7a66bf) manticore-projects *2021-04-16 22:51:27* + +**** + + +[b880e](https://github.com/JSQLParser/JSqlParser/commit/b880e1663ca607f) Tobias Warneke *2021-04-16 22:49:29* + +**fixes #1138** + + +[e95f6](https://github.com/JSQLParser/JSqlParser/commit/e95f6ce1c5ecca8) Tobias Warneke *2021-04-10 21:36:07* + +**fixes #1138** + + +[cb7a0](https://github.com/JSQLParser/JSqlParser/commit/cb7a018a8c0cd9e) Tobias Warneke *2021-04-10 21:35:53* + +**fixes #1137** + + +[9d676](https://github.com/JSQLParser/JSqlParser/commit/9d676b90c6c1e30) Tobias Warneke *2021-04-10 21:23:00* + +**fixes #1136** + + +[ba9b8](https://github.com/JSQLParser/JSqlParser/commit/ba9b8d7a6f24274) Tobias Warneke *2021-04-10 21:09:19* + +**** + + +[f0bec](https://github.com/JSQLParser/JSqlParser/commit/f0bec22644f99e7) Tobias Warneke *2021-03-22 21:21:13* + +**issue #1134 adressed** + + +[5d9f4](https://github.com/JSQLParser/JSqlParser/commit/5d9f4fdff2e6ce6) Tobias Warneke *2021-03-20 21:35:05* + +**Add support for union_with_brackets_and_orderby (#1131)** + + +[c3a1a](https://github.com/JSQLParser/JSqlParser/commit/c3a1aa688442c1d) Tomer Shay (Shimshi) *2021-03-14 20:10:33* + +**Add support for union without brackets and with limit (#1132)** + +* add support for union without brackets and with limit +* Fixing the last commit. + +[56c2d](https://github.com/JSQLParser/JSqlParser/commit/56c2dfe332b5ee8) Tomer Shay (Shimshi) *2021-03-14 20:09:12* + +**** + + +[d2f61](https://github.com/JSQLParser/JSqlParser/commit/d2f61d138c2c0e3) Tobias Warneke *2021-03-14 20:04:28* + +**Add support for functions in an interval expression (#1099)** + + +[7f8b5](https://github.com/JSQLParser/JSqlParser/commit/7f8b58c1e32a919) Tomer Shay (Shimshi) *2021-03-14 19:55:40* + +**** + + +[bcc68](https://github.com/JSQLParser/JSqlParser/commit/bcc683ab8791b71) Tobias Warneke *2021-02-06 20:37:50* + +**** + + +[7deb6](https://github.com/JSQLParser/JSqlParser/commit/7deb6d9bde678d6) Tobias Warneke *2021-02-05 21:59:11* + +**subArray support arr[1:3] (#1109)** + + +[cde50](https://github.com/JSQLParser/JSqlParser/commit/cde50692c131fff) Роман Зотов *2021-02-05 21:55:29* + +**bug fix (#769)** + +* Co-authored-by: Kunal Jha <kjha@zalando-11116.corp.ad.zalando.net> + +[7234d](https://github.com/JSQLParser/JSqlParser/commit/7234de1d65ccf1b) Kunal jha *2021-02-05 17:46:15* + +**** + + +[089fc](https://github.com/JSQLParser/JSqlParser/commit/089fc44eba26cb1) Tobias Warneke *2021-02-04 19:47:39* + +**Array contructor support (#1105)** + +* Array contructor support array[[1, 2], [id1, id2]] +* ARRAYLITERAL->ARRAY_LITERAL +* Fix empty array +* Support ARRAY as DEFAULT value in CREATE TABLE +* https://github.com/JSQLParser/JSqlParser/issues/970#issue-594819872 +* fix empty Array + +[43c28](https://github.com/JSQLParser/JSqlParser/commit/43c282deaa05555) Роман Зотов *2021-02-04 19:28:49* + +**** + + +[85193](https://github.com/JSQLParser/JSqlParser/commit/8519356a4939816) Tobias Warneke *2021-01-31 22:59:20* + +**Partial support construct tuple as simple expression (#1107)** + +* SELECT (1,2) + +[2065f](https://github.com/JSQLParser/JSqlParser/commit/2065fedb5b4c318) Роман Зотов *2021-01-31 22:58:08* + +**support create table parameters without columns, parameter values any names (#1106)** + +* CREATE TEMPORARY TABLE t1 WITH (APPENDONLY=true,ORIENTATION=column,COMPRESSTYPE=zlib,OIDS=FALSE) ON COMMIT DROP AS SELECT column FROM t2 + +[f2e74](https://github.com/JSQLParser/JSqlParser/commit/f2e74f15cd63d87) Роман Зотов *2021-01-31 22:53:09* + +**fixes #995** + + +[d7b46](https://github.com/JSQLParser/JSqlParser/commit/d7b468a651ab966) Tobias Warneke *2021-01-13 19:21:40* + +**fixes #1100** + + +[ea31a](https://github.com/JSQLParser/JSqlParser/commit/ea31a0480cea00e) Tobias Warneke *2021-01-13 18:58:16* + +**next correction of parenthesis around unions** + + +[5706f](https://github.com/JSQLParser/JSqlParser/commit/5706fb4e1133884) Tobias Warneke *2021-01-11 23:15:21* + +**** + + +[e2ff2](https://github.com/JSQLParser/JSqlParser/commit/e2ff225132bfedd) Tobias Warneke *2021-01-10 00:13:16* + +**fixes #992** + + +[9fd11](https://github.com/JSQLParser/JSqlParser/commit/9fd11563fc86281) Tobias Warneke *2021-01-07 22:34:40* + +**corrected patch for case as table name** + + +[f2638](https://github.com/JSQLParser/JSqlParser/commit/f2638ead2f189c2) Tobias Warneke *2021-01-07 21:57:52* + +**Added support for the Case keyword in table names (#1093)** + + +[b85a2](https://github.com/JSQLParser/JSqlParser/commit/b85a2003bbd9a1a) Tomer Shay (Shimshi) *2021-01-07 21:43:11* + +**** + + +[9785b](https://github.com/JSQLParser/JSqlParser/commit/9785b09cd774e14) Tobias Warneke *2021-01-04 06:45:18* + +**corrected some javadoc parameter** + + +[449b7](https://github.com/JSQLParser/JSqlParser/commit/449b74a67c50700) Tobias Warneke *2021-01-03 22:16:44* + +**added missing pivot test files** + + +[e599b](https://github.com/JSQLParser/JSqlParser/commit/e599bd957b2a70f) Tobias Warneke *2021-01-03 21:07:06* + +**fixes #282 - first refactoring to allow with clause as a start in insert and update** + + +[d4402](https://github.com/JSQLParser/JSqlParser/commit/d4402df3ef4978d) Tobias Warneke *2021-01-02 23:57:26* + +**fixes #282 - first refactoring to allow with clause as a start in insert and update** + + +[e6d65](https://github.com/JSQLParser/JSqlParser/commit/e6d65ab3808b9cc) Tobias Warneke *2021-01-02 23:56:12* + +**Update README.md** + + +[54708](https://github.com/JSQLParser/JSqlParser/commit/5470880139cdc94) Tobias *2021-01-02 08:58:01* + +**fixes #887** + + +[74aab](https://github.com/JSQLParser/JSqlParser/commit/74aab7cc81f5665) Tobias Warneke *2021-01-02 00:04:43* + +**fixes #1091 - added H2 casewhen function with conditional parameters** + + +[085e1](https://github.com/JSQLParser/JSqlParser/commit/085e120d4221f1a) Tobias Warneke *2021-01-01 23:49:30* + +**fixes #1091 - added H2 casewhen function with conditional parameters** + + +[e5e7d](https://github.com/JSQLParser/JSqlParser/commit/e5e7d376fc641a9) Tobias Warneke *2021-01-01 23:46:03* + +**** + + +[1eaa1](https://github.com/JSQLParser/JSqlParser/commit/1eaa1ba88028f79) Tobias Warneke *2021-01-01 23:18:55* + + +## jsqlparser-4.0 (2021-01-01) + +### Other changes + +**fixes #961 - allow unsigned as type** + + +[7783e](https://github.com/JSQLParser/JSqlParser/commit/7783e05d024b006) Tobias Warneke *2020-12-31 01:49:42* + +**fixes #961 - allow unsigned as type** + + +[67a33](https://github.com/JSQLParser/JSqlParser/commit/67a331e0052527a) Tobias Warneke *2020-12-31 01:46:19* + +**fixes #1006 - included limit / offset test** + + +[b5514](https://github.com/JSQLParser/JSqlParser/commit/b55141b0bdb975d) Tobias Warneke *2020-12-31 00:59:36* + +**fixes #1013 - refactored fromitem grammar to drastically improve performance** + + +[36d0b](https://github.com/JSQLParser/JSqlParser/commit/36d0b7420fe9225) Tobias Warneke *2020-12-31 00:47:09* + +**** + + +[05a6f](https://github.com/JSQLParser/JSqlParser/commit/05a6f4b3cb719e6) Tobias Warneke *2020-12-30 23:12:55* + +**** + + +[b2c60](https://github.com/JSQLParser/JSqlParser/commit/b2c6097ab0a713e) Tobias Warneke *2020-12-30 22:50:48* + +**fixes #1088 - allowed CURRENT as jdbc named parameter name** + + +[4f925](https://github.com/JSQLParser/JSqlParser/commit/4f925c54cd89e12) Tobias Warneke *2020-12-30 22:12:28* + +**fixes #1089 - just included test case** + + +[4183a](https://github.com/JSQLParser/JSqlParser/commit/4183ae0a55a9455) Tobias Warneke *2020-12-30 21:45:32* + +**** + + +[f484d](https://github.com/JSQLParser/JSqlParser/commit/f484de7c4813cf9) Tobias Warneke *2020-12-18 22:15:09* + +**** + + +[10a69](https://github.com/JSQLParser/JSqlParser/commit/10a69a2dd873053) Tobias Warneke *2020-12-18 22:13:16* + +**fixes #1080** + + +[d9282](https://github.com/JSQLParser/JSqlParser/commit/d928268fb61c088) Tobias Warneke *2020-12-17 20:17:14* + +**Update README.md** + + +[624f2](https://github.com/JSQLParser/JSqlParser/commit/624f247eaab9a54) Tobias *2020-12-16 10:08:46* + +**fixes #926** + + +[97ab8](https://github.com/JSQLParser/JSqlParser/commit/97ab8e9b6cf4af8) Tobias Warneke *2020-12-11 22:13:14* + +**tested** + + +[d9da6](https://github.com/JSQLParser/JSqlParser/commit/d9da64bd9ac032b) Tobias Warneke *2020-12-06 11:53:35* + +**tested** + + +[875f7](https://github.com/JSQLParser/JSqlParser/commit/875f769e4ba353c) Tobias Warneke *2020-12-06 11:52:16* + +**upgraded to javacc 7.0.10, this time the lookahead seems to be working** + + +[881e4](https://github.com/JSQLParser/JSqlParser/commit/881e457d7520aab) Tobias Warneke *2020-11-30 06:35:59* + +**upgraded to javacc 7.0.10, this time the lookahead seems to be working** + + +[eae2e](https://github.com/JSQLParser/JSqlParser/commit/eae2e0d450c88c0) Tobias Warneke *2020-11-30 06:34:55* + +**fixes #1065** + + +[e0b3a](https://github.com/JSQLParser/JSqlParser/commit/e0b3a180da5b1f8) Tobias Warneke *2020-11-22 19:39:48* + +**support IN with value (#1065)** + +* Co-authored-by: Jan Monterrubio <Jan.Monterrubio@Cerner.com> +* Co-authored-by: Tobias <t.warneke@gmx.net> + +[8c7ee](https://github.com/JSQLParser/JSqlParser/commit/8c7ee289e78d07d) Jan Monterrubio *2020-11-22 19:29:27* + +**fixes #1074** + + +[ece8a](https://github.com/JSQLParser/JSqlParser/commit/ece8a5a9e39abff) Tobias Warneke *2020-11-22 19:14:52* + +**fixes #1075** + + +[b74f5](https://github.com/JSQLParser/JSqlParser/commit/b74f53228295d96) Tobias Warneke *2020-11-22 19:08:39* + +**** + + +[1008e](https://github.com/JSQLParser/JSqlParser/commit/1008ebcc5a806b9) Tobias Warneke *2020-11-06 22:01:54* + +**Support CreateSynonym statement (#1064)** + +* visual +* add synonym support +* add tests +* exclude keyword +* Co-authored-by: Jan Monterrubio <Jan.Monterrubio@Cerner.com> + +[17e26](https://github.com/JSQLParser/JSqlParser/commit/17e2633e46778c6) Jan Monterrubio *2020-11-06 21:45:14* + +**** + + +[d5258](https://github.com/JSQLParser/JSqlParser/commit/d5258232ea77690) Tobias Warneke *2020-11-06 21:34:08* + +**Validation visitor framework (#1045)** + +* * add with prefix for fluent setters. +* https://github.com/JSQLParser/JSqlParser/issues/1004 +* add getters +* * add with prefix for fluent setters. (revert to chaining setters, do +* not break current api) +* https://github.com/JSQLParser/JSqlParser/issues/1004 +* * add with prefix for fluent setters. (revert to chaining setters, do +* not break current api) +* https://github.com/JSQLParser/JSqlParser/issues/1004 +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* remove create() methods - they do not add enough value to be justified +* * use new methods within testcases +* add some constructors +* fix and add "with" / "add" methods +* * use new methods within testcases +* * use new methods within testcases +* add some constructors +* * renamed constant +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* * use new methods within testcases +* add some with-methods +* add getter/setter named after the field without abbrivation +* * use new methods within testcases +* remove empty implicit constructor +* return the deparsed Statement - object +* compare object tree +* compare object tree +* * fix ObjectTreeToStringStyle +* compare object tree +* remove casts not needed +* * use new methods within testcases +* add some "set" "with" "add" methods missing +* * use new methods within testcases +* add empty constructors and override with-/add-methods returning concrete +* type +* * add ReflectionModelTest +* * use new methods within testcases +* fix checkstyle errors +* license header +* remove test-classes from ReflectionModelTest +* remove visitoradapter-classes from ReflectionModelTest +* * add SelectDeParser(StringBuilder) +* remove overriding setters/getters of buffer +* #1007 +* push to synbee-contrib +* org.synbee.commons.contrib:jsqlparser:3.2-0.0.6-SNAPSHOT +* add ValidationUtil for simple validation of one or more statements +* remove overrides of +* getCause +* printStackTrace variants +* why add an additional cause ? +* set cause.getMessage() the message within constructor +* JSQLParserException(Throwable cause), othewise cause.toString() will be +* set as default. +* add ValidationVisitor showcase +* https://github.com/JSQLParser/JSqlParser/issues/1005 +* add ValidationUtil for simple validation of one or more statements +* remove overrides of +* getCause +* printStackTrace variants +* why add an additional cause ? +* set cause.getMessage() the message within constructor +* JSQLParserException(Throwable cause), othewise cause.toString() will be +* set as default. +* visit(ShowTablesStatement) +* copyright/license +* add stubs (use deparsers as template) +* Merge branch 'master.validate' of +* https://github.com/gitmotte/JSqlParser.git into master.validate +* add ValidationVisitor showcase +* https://github.com/JSQLParser/JSqlParser/issues/1005 +* add ValidationUtil for simple validation of one or more statements +* remove overrides of +* getCause +* printStackTrace variants +* why add an additional cause ? +* set cause.getMessage() the message within constructor +* JSQLParserException(Throwable cause), othewise cause.toString() will be +* set as default. +* visit(ShowTablesStatement) +* add stubs (use deparsers as template) +* Merge branch 'master.validate' of +* https://github.com/gitmotte/JSqlParser.git into master.validate +* add tests for ValidationUtil +* + implements OrderByVisitor +* split Expressionvalidator which implements both ItemsListVisitor and +* Expressionvisitor into Expressionvalidator and ItemListValidator +* Merge branch 'github.validate' +* implement upsertvalidator +* add copyright +* validate through given ValidationCapability's +* * switch to new method forced by +* ValidationCapability.validate(ValidationContext context, +* Consumer<String> errorMessageConsumer); +* add AllowedTypesValidation +* add FeatureConfiguration +* use FeatureConfiguration within parser +* repair pom.xml +* repair pom.xml +* repair pom.xml +* repair pom.xml +* * make FeatureConfiguration not a singleton any more +* CCJSqlParser extends AbstractJSqlParser<CCJSqlParser> +* add FeaturesAllowed for testing against features allowed +* implement some Validators +* basic implementation of DatabaseMetaDataValidation / +* JdbcDatabaseMetaDataCapability +* moving classes to sub-packages +* * moving classes to sub-packages +* fixing some bugs +* repair pom.xml +* add and fix validations +* add javadoc +* * force definition of ```public String getMessage(Feature feature)``` +* in FeatureSetValidation +* allow all objects as feature-value - this may be needed by the parser, +* if a none-boolean configuration is needed +* impl. +* SelectValidator.visit(PlainSelect) +* OrderByValidator +* add Version-enums +* impl. +* InsertValidator +* multiple implementations of visit(SubSelect) -> forward to +* SelectValidator +* add some known features to SqlServerVersion +* refactoring enum-name should be upper case +* add ansi sql enum +* refactoring enum-name should be upper case +* implement limitvalidator +* + validateOffset +* + validateFetch +* + validate Pivot, UnPivot, PivotXml +* + implement DropValidator +* change testcase to image a more probably usecase +* * add javadoc and +* predefined sets for EXECUTE, ALTER, DROP +* allow to combine FeatureSets +* * implement executevalidator +* implement ExpressionValidator +* implement GrantValidator +* javadoc and complete SELECT constant +* use utility methods from AbstractValidator +* more user friendly names +* javadoc +* add subtypes for ValidationException +* ValidationParseException +* DatabaseException +* UnexpectedValidationException +* and change Set<String> errors to Set<ValidationException> for collect. +* javadoc & rename exception +* rename method +* extract parsing task into package - private class for {@link +* ValidationUtil} to parse the statements +* within it's own {@link ValidationCapability} +* add null-check for parsedStatement +* bugfix - do not collect duplicates +* implement toString() for +* ValidationError +* ValidationException +* add simple caching +* + validateOptionalFromItem(s) +* * implement GroupByValidator +* implement merge-validator +* renaming ItemListValidator -> ItemsListValidator +* + validateOptionalItemsList +* + implement ReplaceValidator +* + use validateOptionalColumns, validateOptionalExpression where possible +* * remove validateOptionalColumns -> switch to +* validateOptionalExpressions +* move validateOptionalOrderByElements to AbstractValidator +* add validateOptional in AbstractValidator +* add validateOptionalList in AbstractValidator +* + SetStatementValidator +* + ValuesStatementValidator +* + UseStatementValidator +* * implement UpdateValidator +* * implement ShowStatementValidator/ShowColumnsStatementValidator +* * implement UpdateValidator +* * add Feature.jdbcParameter, Feature.jdbcNamedParameter, to all +* featuresets +* + Version.getFeaturesClone +* add javadoc to Version-enum-constructors +* + validateOptionalFeature +* * implement DeleteValidator +* ... +* fix typo +* small optimization +* * move method getFeaturesClone to FeatureSet +* implement join - validation +* add copy(), add(Collection), remove(*) methods to FeaturesAllowed +* * add join - features to sqlserver, h2 +* implementations +* bugfix - merging the errors +* copyright +* https://github.com/JSQLParser/JSqlParser/issues/1022 +* add more fine granular control for setOperations +* fix nullpointerexception +* add more fine granular control for comments +* add Features supported +* * add javadoc +* add features to *Version-files +* extract methods isNotEmpty +* check for isNotEmpty +* * add features to *Version-files +* always parse net.sf.jsqlparser.statement.Statements and validate the +* list of included net.sf.jsqlparser.statement.Statement's +* add known mariadb features +* new names-set for FeaturesAllowed +* new names-set for FeaturesAllowed +* new names-set for FeaturesAllowed +* add ature.withItem, Feature.withItemRecursive to H2 +* Feature.setOperation, Feature.setOperationUnion, +* Feature.setOperationIntersect, Feature.setOperationExcept, +* for MariaDb +* add features to SQLServer +* Merge branch 'master.orig' into github.validate +* @Override() -> @Override +* fix typing error "joinStaight" > joinStraight +* rename Feature "insertValues" -> "values" and use "insertValues" for +* INSERT INTO ... VALUES +* add javadoc +* add Feature.selectGroupByGroupingSets to PostgresqlVersion +* implement basic OracleVersion +* add Feature.mySql* - also supported by mariadb +* add some more finegraned control over "drop" Feature. +* drop, +* dropTable, +* dropIndex, +* dropView, +* dropSchema, +* dropSequence, +* dropIfExists, +* complete FeaturesAllowed groups INSERT/UPDATE/DELETE/MERGE/DML +* add link to documentation +* fix - duplicate use of feature "function" - the use of functions in +* statements and "createFunction" as a ddl statement +* TODO this feature seams very close to a jsqlparser-user usecase +* * implement MySqlVersion +* replace feature Feature.dropIfExists by features dropTableIfExists, +* dropIndexIfExists, dropViewIfExists, dropSchemaIfExists, +* dropSequenceIfExists +* add methods FeatureSet.getNotContained FeatureSet.retainAll +* remove HSQLDBVersion - do not support this variant +* remove HSQLDBVersion - do not support this variant +* add unit-test +* + add unittests for +* UpdateValidator +* DeleteValidator +* add stubs for all other Validator-classes +* + ModifyableFeatureSet +* add some utility-methods in ValidationTestAsserts +* complete unit-tests for InsertValidator +* remote Feature.insertReturningExpressionList for Oracle - +* returning_clause requires INTO clause (only PL/SQL) +* add some more select validation tests +* add DropValidatorTests +* add DropValidatorTests +* add CreateTableValidatorTests +* add CreateTableValidatorTests +* add ExpressionValidatorTests +* add OrderByValidatorTest +* use isNotEmpty +* implement GroupByValidatorTest +* implement CreateSequenceValidatorTest +* remove @Ignore - test is ok +* implement CreateIndexValidatorTest +* implement CreateViewValidatorTest +* enable validation of Feature.commentOnView (#1024 is merged already) +* change format of #toString() for better readability +* * implement MergeValidatorTest +* implement ReplaceValidatorTest +* implement StatementValidatorTest +* rename +* ValidationUtil -> Validation +* ValidatorUtil -> ValidationUtil +* add testcases for ValidationUtil +* add DatabaseMetaDataValidationTest +* checkstyle fix +* add copyright statement +* add unit-tests for show tables, show column, show statements +* * add ExecuteValidatorTest +* as there is a difference between execute <procedure> and execute +* [immediate] <dynamic sql> with USING expr, ... remove support for +* execute on MYSQL, MARIADB, ORACLE +* * add ExecuteValidatorTest for CALL fnName (mysql, mariadb, postgres) +* add upsertvalidatortest +* add GrantValidatorTest +* add AlterSequenceValidatorTest +* add AlterSequenceValidatorTest +* add AlterViewValidatorTest +* add AlterValidatorTest +* replace != null by isNotEmpty on collections +* fix formatting +* add validate commit +* add validate block +* add DeclareStatementValidatorTest +* let NamesLookup implement UnaryOperator<String> +* let NamesLookup implement UnaryOperator<String> +* add javadoc +* add more DatabaseMetaDataValidationTest's +* extract JdbcDatabaseMetaDataCapability.splitAndValidateMinMax +* add pivot/unpivot/pivotxml validation testcases +* add testcase for Feature.tableFunction +* add test for lateral joins and subjoins +* add testValidationRowMovementOption +* add values validator test +* move tests to LimitValidatorTest +* move tests to UseStatementValidatorTest +* add tests for SET - statements +* fix checkstyle error +* new serialVersionUID +* add validation for NamedObject not existing +* need table/view reference to validate column names +* fix typo +* fix errormessage (Arrays.toString(types)) +* add trigger, alias +* return null, instead of throwing exception, if not found +* extract NamesLookup to own file (jdk-bug enum inner classes) +* fix name-check AlterOperation.ALTER +* fix error message +* remove methods not needed (they only delegate to ValidationContext) +* add tests - validate metadata +* fix compile error +* fix columnExists check - depending on the statement the prefix is an +* alias, a table/view or it has no prefix (need to lookup within all +* related tables/views) +* fix javadoc warnings + +[8c735](https://github.com/JSQLParser/JSqlParser/commit/8c735be5b179e51) gitmotte *2020-11-06 21:12:25* + +**Support Create table LIKE (#1066)** + +* fixes #413 +* add coverage +* Co-authored-by: chyun <chyun_wu@163.com> + +[ac746](https://github.com/JSQLParser/JSqlParser/commit/ac7462286ae15b9) Chyun *2020-11-06 21:05:09* + +**fixes #1068** + + +[f1cf0](https://github.com/JSQLParser/JSqlParser/commit/f1cf0abc11ed783) Tobias Warneke *2020-11-06 20:59:19* + +**Bump junit from 4.12 to 4.13.1 (#1063)** + +* Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.1. +* - [Release notes](https://github.com/junit-team/junit4/releases) +* - [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.12.md) +* - [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13.1) +* Signed-off-by: dependabot[bot] <support@github.com> +* Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +[f9a11](https://github.com/JSQLParser/JSqlParser/commit/f9a115c582dd59b) dependabot[bot] *2020-10-13 12:26:17* + +**fixes #1062** + + +[80e28](https://github.com/JSQLParser/JSqlParser/commit/80e2891e8a79402) wumpz *2020-10-11 19:59:03* + +**corrected a test failure** + + +[bc0e5](https://github.com/JSQLParser/JSqlParser/commit/bc0e5b913fc4f61) wumpz *2020-10-06 21:07:00* + +**support FILTER not only for window function (#1046)** + +* support FILTER not only for window function +* Fixed imports + +[f32fa](https://github.com/JSQLParser/JSqlParser/commit/f32fa6137d6161b) Роман Зотов *2020-10-05 19:45:36* + +**fixes #1059** + + +[3e84a](https://github.com/JSQLParser/JSqlParser/commit/3e84a377b488960) wumpz *2020-10-04 20:43:42* + +**** + + +[6b35e](https://github.com/JSQLParser/JSqlParser/commit/6b35e2fc4f39083) wumpz *2020-10-04 20:17:54* + +**fixes #1055 - added simple jdbc parameter to interval expression** + + +[68659](https://github.com/JSQLParser/JSqlParser/commit/686599b199d6d49) wumpz *2020-10-04 20:16:04* + +**Retain original value in TimestampValue (#1057)** + +* Co-authored-by: Enrico Olivelli <enrico.olivelli@diennea.com> + +[622f9](https://github.com/JSQLParser/JSqlParser/commit/622f9aebb3ebce7) Enrico Olivelli *2020-10-04 19:51:01* + +**fixes #1053** + + +[45aa8](https://github.com/JSQLParser/JSqlParser/commit/45aa8f853a10779) wumpz *2020-10-04 19:42:23* + +**Addons/fixes for Fluent API (#1049)** + +* fix unittests for setter/wither methods with primitive arguments +* add missing withAscDescPresent + +[8165e](https://github.com/JSQLParser/JSqlParser/commit/8165e29cb081080) gitmotte *2020-10-04 19:20:43* + +**fixes #1040** + + +[3f516](https://github.com/JSQLParser/JSqlParser/commit/3f5165122bc9824) wumpz *2020-09-27 21:12:11* + +**xmlserialize support patch for optional order by part** + + +[3747f](https://github.com/JSQLParser/JSqlParser/commit/3747f1c00503b54) wumpz *2020-09-10 21:21:47* + +**xmlserialize support patch for expressions** + + +[8c4e0](https://github.com/JSQLParser/JSqlParser/commit/8c4e0ca141656fd) wumpz *2020-09-08 20:35:36* + +**Make UnPivot.getUnPivotInClause() return List (#1039)** + + +[abedc](https://github.com/JSQLParser/JSqlParser/commit/abedce539515638) MoonFruit *2020-09-07 11:32:37* + +**xmlserialize support** + + +[b580a](https://github.com/JSQLParser/JSqlParser/commit/b580a093c2edda6) wumpz *2020-09-05 22:00:43* + +**** + + +[536fb](https://github.com/JSQLParser/JSqlParser/commit/536fb0348ae985e) wumpz *2020-08-30 20:23:52* + +**bugfix issue #1036: supporting DROP SEQUENCE (#1037)** + + +[e5cd7](https://github.com/JSQLParser/JSqlParser/commit/e5cd7c83e15f7f9) suiwenbo *2020-08-30 20:16:20* + +**modified Condition production to be more performant** + + +[3d7f5](https://github.com/JSQLParser/JSqlParser/commit/3d7f55c48a8dfae) wumpz *2020-08-29 22:30:01* + +**bugfix #720 #991: supporting SELECT "conditions" (#1032)** + +* bugfix issue #1020: JSON type in MySQL not supported in v3.2 +* bugfix issue #720 #991: supporting SELECT "CONDITIONS" + +[9e26b](https://github.com/JSQLParser/JSqlParser/commit/9e26b76ddbc626f) suiwenbo *2020-08-25 22:29:41* + +**** + + +[81523](https://github.com/JSQLParser/JSqlParser/commit/815235606244b01) wumpz *2020-08-23 20:33:42* + +**setting version to 4-SNAPSHOT** + + +[85286](https://github.com/JSQLParser/JSqlParser/commit/852860985832c4c) wumpz *2020-08-23 20:32:33* + +**Fluent builder api #1004 (#1014)** + +* https://github.com/JSQLParser/JSqlParser/issues/1004 +* create(...) methods +* chaining - methods returning "this" +* overwrite chaining - methods of abstract parents/interfaces for +* returning concrete type +* add<Name> methods on collection-fields with varargs-parameter +* add public T get<Name>(Class<T>) - casting and returning an inner +* interface-type +* 1004 add chaining - methods returning "this" +* #1004 add chaining - methods returning "this" +* * add<Name> methods on collection-fields with varargs-parameter +* add<Name> methods on collection-fields with collection-parameter +* https://github.com/JSQLParser/JSqlParser/issues/1004 +* * add chaining - methods returning "this" +* add<Name> methods on collection-fields with varargs-parameter +* add<Name> methods on collection-fields with collection-parameter +* https://github.com/JSQLParser/JSqlParser/issues/1004 +* * add public T get<Name>(Class<T>) - casting and returning the concrete +* type +* https://github.com/JSQLParser/JSqlParser/issues/1004 +* * add public T get<Name>(Class<T>) - casting and returning the concrete +* type (swap Class<? extends E> for Class<E>) +* https://github.com/JSQLParser/JSqlParser/issues/1004 +* * overwrite chaining - methods of abstract parents/interfaces for +* returning concrete type +* https://github.com/JSQLParser/JSqlParser/issues/1004 +* * add with prefix for fluent setters. +* https://github.com/JSQLParser/JSqlParser/issues/1004 +* add getters +* * add with prefix for fluent setters. (revert to chaining setters, do +* not break current api) +* https://github.com/JSQLParser/JSqlParser/issues/1004 +* * add with prefix for fluent setters. (revert to chaining setters, do +* not break current api) +* https://github.com/JSQLParser/JSqlParser/issues/1004 +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* remove create() methods - they do not add enough value to be justified +* * use new methods within testcases +* add some constructors +* fix and add "with" / "add" methods +* * use new methods within testcases +* * use new methods within testcases +* add some constructors +* * renamed constant +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* use new methods within testcases +* * use new methods within testcases +* add some with-methods +* add getter/setter named after the field without abbrivation +* * use new methods within testcases +* remove empty implicit constructor +* return the deparsed Statement - object +* compare object tree +* compare object tree +* * fix ObjectTreeToStringStyle +* compare object tree +* remove casts not needed +* * use new methods within testcases +* add some "set" "with" "add" methods missing +* * use new methods within testcases +* add empty constructors and override with-/add-methods returning concrete +* type +* * add ReflectionModelTest +* * use new methods within testcases +* fix checkstyle errors +* license header +* remove test-classes from ReflectionModelTest +* remove visitoradapter-classes from ReflectionModelTest +* remove duplicate import declaration (checkstyle error) +* * fix RandomUtils to support used java.sql.* types +* fix RandomUtils to support enums +* fix RandomUtils to map objects by its interfaces and super-classes +* filter method "setASTNode" - do not test setters (cannot randomly +* create a SimpleNode) +* add javadoc, stating that this is a marker interface +* https://github.com/JSQLParser/JSqlParser/pull/1014#discussion_r454761902 +* revert formatting change +* https://github.com/JSQLParser/JSqlParser/pull/1014#discussion_r454762463 +* change to EXEC_TYPE.EXECUTE just so the assertion didn't change +* https://github.com/JSQLParser/JSqlParser/pull/1014#discussion_r454763565 +* try to revert format changes +* https://github.com/JSQLParser/JSqlParser/pull/1014#discussion_r454800430 +* try to revert format changes +* https://github.com/JSQLParser/JSqlParser/pull/1014#discussion_r454800430 +* remove brackets on @Override() -> @Override +* add with-methods to new fields + +[6cff1](https://github.com/JSQLParser/JSqlParser/commit/6cff161dacc1e6f) gitmotte *2020-08-23 20:07:53* + +**** + + +[02d58](https://github.com/JSQLParser/JSqlParser/commit/02d5837c5ee8c92) wumpz *2020-08-09 21:26:57* + +**** + + +[574a6](https://github.com/JSQLParser/JSqlParser/commit/574a6b7fda44857) wumpz *2020-08-09 21:22:24* + +**Support Foreign Key ON UPDATE CASCADE (#1025)** + +* https://github.com/JSQLParser/JSqlParser/issues/985 +* add 2 unit-tests for given statements +* https://github.com/JSQLParser/JSqlParser/issues/985 +* fix formating (line width) +* https://github.com/JSQLParser/JSqlParser/issues/985 +* * fix nullpointerexceptions +* add more unittest-assertions +* https://github.com/JSQLParser/JSqlParser/issues/985 +* change order to match the same order as in ForeignKeyIndex +* byAction should not throw an exception (is used by deprecated +* string-setters) +* add unit-tests for ReferentialAction within AlterExpression +* fix toString (added bug on refactoring) +* javadoc +* test set from get on null-values too +* refactoring: add and use ReferentialAction() to evaluate enum +* https://github.com/JSQLParser/JSqlParser/issues/985 +* refactoring: fix parser that order of referential actions does not +* matter +* https://github.com/JSQLParser/JSqlParser/issues/985 +* add empty constructor + +[1e88d](https://github.com/JSQLParser/JSqlParser/commit/1e88dd57eb48ebf) gitmotte *2020-08-09 21:01:34* + +**bugfix issue #1020: JSON type in MySQL not supported in v3.2 (#1028)** + + +[685f6](https://github.com/JSQLParser/JSqlParser/commit/685f6fe43fb35d7) suiwenbo *2020-08-09 20:59:52* + +**** + + +[cfe5a](https://github.com/JSQLParser/JSqlParser/commit/cfe5a2e725b555b) wumpz *2020-08-09 20:58:15* + +**Add generated sources to classpath. (#804)** + + +[14fb8](https://github.com/JSQLParser/JSqlParser/commit/14fb80d947d9bf0) Matthieu Vergne *2020-08-09 20:53:38* + +**** + + +[008d9](https://github.com/JSQLParser/JSqlParser/commit/008d9ad7f28a7b9) wumpz *2020-08-09 20:51:34* + +**COMMENT ON VIEW (#1024)** + +* * implement COMMENT ON VIEW +* testcase "testCommentOnView" +* https://github.com/JSQLParser/JSqlParser/issues/1023 +* add more asserts + +[449f5](https://github.com/JSQLParser/JSqlParser/commit/449f55219fc39eb) gitmotte *2020-08-09 20:49:05* + +**fixes #1026** + + +[4f888](https://github.com/JSQLParser/JSqlParser/commit/4f8882dd143469d) wumpz *2020-08-09 20:46:07* + +**fixes #1026** + + +[4c323](https://github.com/JSQLParser/JSqlParser/commit/4c32302d386ec88) wumpz *2020-08-09 20:39:48* + +**fixes #1027** + + +[a923e](https://github.com/JSQLParser/JSqlParser/commit/a923e7e00ef3518) wumpz *2020-08-09 20:31:26* + +**fixes #1029** + + +[db6ac](https://github.com/JSQLParser/JSqlParser/commit/db6acef1c38e09e) wumpz *2020-08-09 19:55:55* + +**fixes #732** + + +[57a7d](https://github.com/JSQLParser/JSqlParser/commit/57a7dcdf2ede8a0) wumpz *2020-07-15 21:07:09* + +**variable assignment implemented** + + +[cdd0f](https://github.com/JSQLParser/JSqlParser/commit/cdd0fa244dadca1) wumpz *2020-07-13 22:03:12* + +**allowed Jdbc named parameters within interval expressions** + + +[869a7](https://github.com/JSQLParser/JSqlParser/commit/869a7b2088ff54f) wumpz *2020-07-12 21:25:43* + +**allowed Jdbc named parameters within interval expressions** + + +[3602c](https://github.com/JSQLParser/JSqlParser/commit/3602c5f6d0a1766) wumpz *2020-07-12 21:25:05* + +**some house keeping** + + +[8bcf2](https://github.com/JSQLParser/JSqlParser/commit/8bcf2dc4f64cde3) wumpz *2020-07-11 20:39:37* + +**fixes #1009** + + +[71d65](https://github.com/JSQLParser/JSqlParser/commit/71d6523f2150bc2) wumpz *2020-07-11 20:30:30* + +**Add show tables support (#1015)** + +* visual +* implement show tables +* Co-authored-by: Jan Monterrubio <Jan.Monterrubio@Cerner.com> + +[c0373](https://github.com/JSQLParser/JSqlParser/commit/c03733b3cfcb758) Jan Monterrubio *2020-07-11 16:43:42* + +**let all deparsers extend AbstractDeParser (#1007)** + +* let all deparsers extend AbstractDeParser +* * add SelectDeParser(StringBuilder) +* remove overriding setters/getters of buffer +* #1007 + +[2b790](https://github.com/JSQLParser/JSqlParser/commit/2b7909c3be31ca8) gitmotte *2020-07-11 16:40:11* + +**** + + +[ea88e](https://github.com/JSQLParser/JSqlParser/commit/ea88e1b2899176e) wumpz *2020-06-28 19:22:52* + +**** + + +[51e84](https://github.com/JSQLParser/JSqlParser/commit/51e8428d7dcf7dc) wumpz *2020-06-27 23:01:20* + + +## jsqlparser-3.2 (2020-06-28) + +### Other changes + +**** + + +[cd742](https://github.com/JSQLParser/JSqlParser/commit/cd742d3104218ab) wumpz *2020-06-27 22:29:23* + +**partial func support (#1000)** + + +[9df19](https://github.com/JSQLParser/JSqlParser/commit/9df19b9517112b8) Jan Monterrubio *2020-06-25 05:31:27* + +**** + + +[7a19a](https://github.com/JSQLParser/JSqlParser/commit/7a19a9b71c2a44d) wumpz *2020-06-23 21:56:47* + +**Support options for Explain (#996)** + +* visual +* issue-995 +* support verbose +* postgres explain +* tests +* no text +* Co-authored-by: Jan Monterrubio <Jan.Monterrubio@Cerner.com> + +[13873](https://github.com/JSQLParser/JSqlParser/commit/1387354712285e4) Jan Monterrubio *2020-06-23 21:52:42* + +**** + + +[8c307](https://github.com/JSQLParser/JSqlParser/commit/8c3076efc9544cb) wumpz *2020-06-23 20:45:19* + +**Support multiple lists for an IN clause (#997)** + +* visual +* wip +* cleanup n test +* polish +* lookahead +* Co-authored-by: Jan Monterrubio <Jan.Monterrubio@Cerner.com> + +[5de4a](https://github.com/JSQLParser/JSqlParser/commit/5de4ae597fbeda3) Jan Monterrubio *2020-06-20 22:10:38* + +**fixes #999** + + +[ce8ee](https://github.com/JSQLParser/JSqlParser/commit/ce8eef8bb6c2526) wumpz *2020-06-20 22:06:17* + +**fixes #999** + + +[325cc](https://github.com/JSQLParser/JSqlParser/commit/325ccb0fc2cf067) wumpz *2020-06-20 21:57:10* + +**Support ALTER SEQUENCE (#980)** + +* support alter sequence +* improve coverage + +[d34c8](https://github.com/JSQLParser/JSqlParser/commit/d34c885ba5a8c93) Jan Monterrubio *2020-05-23 10:16:07* + +**** + + +[779a7](https://github.com/JSQLParser/JSqlParser/commit/779a744a8ab80c7) wumpz *2020-05-23 10:12:52* + +**fixes #984** + + +[38597](https://github.com/JSQLParser/JSqlParser/commit/38597f347c820a7) wumpz *2020-05-16 21:14:26* + +**fixes #984** + + +[60ac1](https://github.com/JSQLParser/JSqlParser/commit/60ac16a98022455) wumpz *2020-05-16 21:00:28* + +**tests for issue** + + +[82894](https://github.com/JSQLParser/JSqlParser/commit/8289406bbcbba45) wumpz *2020-05-14 21:16:52* + +**** + + +[d6bbc](https://github.com/JSQLParser/JSqlParser/commit/d6bbc3fa8a10d58) wumpz *2020-05-08 21:12:13* + +**** + + +[1ee7c](https://github.com/JSQLParser/JSqlParser/commit/1ee7c417bf0936e) wumpz *2020-05-08 20:19:13* + +**fixes #981** + + +[d79b4](https://github.com/JSQLParser/JSqlParser/commit/d79b44db122652e) wumpz *2020-05-08 20:14:21* + +**fixbuild (#978)** + + +[08b94](https://github.com/JSQLParser/JSqlParser/commit/08b9477ef28a377) Jan Monterrubio *2020-04-30 04:42:04* + +**Implement row movement clause for table creation (#974)** + +* visual +* implement row movement +* support row + AS +* Co-authored-by: Jan Monterrubio <Jan.Monterrubio@Cerner.com> + +[79b5f](https://github.com/JSQLParser/JSqlParser/commit/79b5fe9c5681961) Jan Monterrubio *2020-04-28 07:02:51* + +**Support CREATE SEQUENCE (#977)** + +* wip +* wip, some parsing +* support sequence +* implement feature +* delete issue tests +* compile it + +[a6a3c](https://github.com/JSQLParser/JSqlParser/commit/a6a3c616b8994f1) Jan Monterrubio *2020-04-28 07:01:10* + +**** + + +[ca76f](https://github.com/JSQLParser/JSqlParser/commit/ca76fed4be73522) wumpz *2020-04-19 19:50:28* + +**fixes #962** + + +[3f918](https://github.com/JSQLParser/JSqlParser/commit/3f918501bda7fc4) wumpz *2020-04-18 21:53:14* + +**implement feature (#972)** + +* Co-authored-by: Jan Monterrubio <Jan.Monterrubio@Cerner.com> + +[aee39](https://github.com/JSQLParser/JSqlParser/commit/aee3947757eecf4) Jan Monterrubio *2020-04-17 21:01:22* + +**test method names changed** + + +[2b564](https://github.com/JSQLParser/JSqlParser/commit/2b5647b5af32b74) zhumaliev-rv *2020-04-03 05:31:40* + +**added Oracle GRANT statement** + + +[fa215](https://github.com/JSQLParser/JSqlParser/commit/fa21512ea2f2dd8) zhumaliev-rv *2020-04-02 12:03:43* + +**fixes #855** + + +[f3ecd](https://github.com/JSQLParser/JSqlParser/commit/f3ecdcb1a8fe8b0) wumpz *2020-03-25 22:42:33* + +**fixes #915** + + +[9ce74](https://github.com/JSQLParser/JSqlParser/commit/9ce74e234e09525) wumpz *2020-03-04 22:04:40* + +**fixes #922** + + +[8abd6](https://github.com/JSQLParser/JSqlParser/commit/8abd6e732c926c2) wumpz *2020-03-01 00:00:26* + +**** + + +[65ad8](https://github.com/JSQLParser/JSqlParser/commit/65ad8f9b8b05835) wumpz *2020-02-29 23:22:26* + +**fixes #864** + + +[5783b](https://github.com/JSQLParser/JSqlParser/commit/5783b65f169560a) wumpz *2020-02-15 21:31:55* + +**fixes #701** + + +[8d43f](https://github.com/JSQLParser/JSqlParser/commit/8d43facbc33c803) wumpz *2020-02-15 20:43:38* + +**fixes #945** + + +[ab405](https://github.com/JSQLParser/JSqlParser/commit/ab4054ce5c1917e) wumpz *2020-02-14 23:19:47* + +**fixes #944** + + +[e1ff1](https://github.com/JSQLParser/JSqlParser/commit/e1ff1f09e9ad946) wumpz *2020-02-14 23:02:57* + +**fixes #944** + + +[22117](https://github.com/JSQLParser/JSqlParser/commit/22117c40613778b) wumpz *2020-02-14 22:58:06* + +**introduces sql server hints** + + +[92c74](https://github.com/JSQLParser/JSqlParser/commit/92c74bfb15b18ac) wumpz *2020-02-14 19:40:15* + +**introduces sql server hints** + + +[6a414](https://github.com/JSQLParser/JSqlParser/commit/6a414aa703b9a5b) wumpz *2020-02-14 19:04:41* + +**introduced view keyword** + + +[f12bb](https://github.com/JSQLParser/JSqlParser/commit/f12bb31a14973ac) wumpz *2020-02-12 23:54:37* + +**fixes #909** + + +[9b998](https://github.com/JSQLParser/JSqlParser/commit/9b998d67699bf5c) wumpz *2020-02-02 21:51:56* + +**fixes #930** + + +[4c4a5](https://github.com/JSQLParser/JSqlParser/commit/4c4a5361453c434) wumpz *2020-02-02 21:09:52* + +**fixes #940** + + +[dc93a](https://github.com/JSQLParser/JSqlParser/commit/dc93a07e38341de) wumpz *2020-02-02 20:43:09* + +**fixes #941 again :)** + + +[782dc](https://github.com/JSQLParser/JSqlParser/commit/782dce8d20ce99f) wumpz *2020-02-02 20:22:40* + +**fixes #941** + + +[ce392](https://github.com/JSQLParser/JSqlParser/commit/ce392b3739dcfbb) wumpz *2020-02-01 23:49:17* + +**fixes #924** + + +[d0cd8](https://github.com/JSQLParser/JSqlParser/commit/d0cd8f869bb1173) wumpz *2020-02-01 23:21:52* + +**Update README.md** + + +[a03d2](https://github.com/JSQLParser/JSqlParser/commit/a03d235d91de445) Tobias *2020-02-01 00:34:26* + +**updated some maven plugins** + + +[3ba29](https://github.com/JSQLParser/JSqlParser/commit/3ba29f1fdc76a7a) wumpz *2020-02-01 00:33:17* + +**fixes #936** + +* fixes #938 + +[39e92](https://github.com/JSQLParser/JSqlParser/commit/39e920df15fefd7) wumpz *2020-02-01 00:08:17* + +**fixes #936** + + +[abf44](https://github.com/JSQLParser/JSqlParser/commit/abf440d2be0fbc6) wumpz *2020-01-31 23:47:06* + +**added keyword group to possible object names** + + +[430b3](https://github.com/JSQLParser/JSqlParser/commit/430b3ee8f506173) wumpz *2020-01-27 06:42:20* + +**fixes #923** + + +[775a0](https://github.com/JSQLParser/JSqlParser/commit/775a09b0a763f55) wumpz *2020-01-25 23:09:35* + +**fixes #923** + + +[57d50](https://github.com/JSQLParser/JSqlParser/commit/57d5044a1a1d6bc) wumpz *2020-01-25 23:09:18* + +**started fixing #923** + + +[0f78d](https://github.com/JSQLParser/JSqlParser/commit/0f78dfdf5dfa6a7) wumpz *2020-01-23 23:19:41* + +**fixes #932** + + +[3490e](https://github.com/JSQLParser/JSqlParser/commit/3490e61dbc6b9b0) wumpz *2020-01-23 21:57:59* + +**fixes #918** + + +[3b89c](https://github.com/JSQLParser/JSqlParser/commit/3b89cd28ad893ae) wumpz *2020-01-23 21:26:58* + +**fixes #921** + + +[f4b10](https://github.com/JSQLParser/JSqlParser/commit/f4b10cff44e90f4) wumpz *2020-01-21 07:27:10* + +**fixes #921** + + +[a23d3](https://github.com/JSQLParser/JSqlParser/commit/a23d30bc9425b19) wumpz *2020-01-21 07:26:35* + +**fixes #929** + + +[a3c95](https://github.com/JSQLParser/JSqlParser/commit/a3c95d4712852f2) wumpz *2020-01-21 07:11:38* + +**fixes #928** + + +[0bae6](https://github.com/JSQLParser/JSqlParser/commit/0bae629dba2459c) wumpz *2020-01-21 06:58:58* + +**fixes #927** + + +[62648](https://github.com/JSQLParser/JSqlParser/commit/6264801af1c0bef) wumpz *2020-01-21 06:49:23* + +**fixes #917** + + +[8de0f](https://github.com/JSQLParser/JSqlParser/commit/8de0fd9971b6e07) wumpz *2020-01-05 22:08:03* + +**rewind #910** + + +[9ca4f](https://github.com/JSQLParser/JSqlParser/commit/9ca4f3e63b26353) wumpz *2020-01-03 00:03:35* + +**Adding support for simple expressions in INTERVAL expressions (#910)** + + +[ebac9](https://github.com/JSQLParser/JSqlParser/commit/ebac9dbcadb4df8) Tomer Shay (Shimshi) *2019-12-20 06:14:04* + +**removed null check** + + +[aba6f](https://github.com/JSQLParser/JSqlParser/commit/aba6f3ae2148d51) wumpz *2019-12-18 14:01:17* + +**Update README.md** + + +[6fd3c](https://github.com/JSQLParser/JSqlParser/commit/6fd3c9c0e6fa4b6) Tobias *2019-12-02 15:55:47* + +**** + + +[5be06](https://github.com/JSQLParser/JSqlParser/commit/5be0646d9004b6e) wumpz *2019-12-01 22:12:59* + +**** + + +[82d8f](https://github.com/JSQLParser/JSqlParser/commit/82d8f59db9f1c33) wumpz *2019-12-01 22:12:54* + +**Update README.md** + + +[f7ae7](https://github.com/JSQLParser/JSqlParser/commit/f7ae75ace8ecb98) Tobias *2019-11-27 20:26:12* + +**fixes #899** + +* switched to assertj from hamcrest + +[9707e](https://github.com/JSQLParser/JSqlParser/commit/9707e4f0aacff16) wumpz *2019-11-23 23:18:56* + +**Adding support for casting to SIGNED (#900)** + + +[73b3d](https://github.com/JSQLParser/JSqlParser/commit/73b3d44f16a57c9) Tomer Shay (Shimshi) *2019-11-20 09:39:47* + +**Support parsing SELECT FOR UPDATE NOWAIT - Refer to documents on https://docs.oracle.com/cd/E17952_01/mysql-8.0-en/innodb-locking-reads.html#innodb-locking-reads-nowait-skip-locked (#896)** + + +[596e6](https://github.com/JSQLParser/JSqlParser/commit/596e631ff985c10) Yoon Kyong Sik *2019-11-16 10:07:59* + +**added some doc to CCJSqlParserUtil** + + +[5242a](https://github.com/JSQLParser/JSqlParser/commit/5242a18d20a7c2a) wumpz *2019-11-13 08:31:40* + +**Adding support for STRAIGHT_JOIN in the select clause (#861)** + +* Adding support for straight_join in the select clause +* Renaming the field name to reflect that this is a MySQL hint + +[3cdea](https://github.com/JSQLParser/JSqlParser/commit/3cdea6bd3d9ce21) Tomer Shay (Shimshi) *2019-11-09 20:30:54* + +**Update README.md** + + +[a0077](https://github.com/JSQLParser/JSqlParser/commit/a0077a1e3b4c0c1) Tobias *2019-11-08 07:53:42* + +**** + + +[47a94](https://github.com/JSQLParser/JSqlParser/commit/47a944eb4571b02) wumpz *2019-11-06 22:36:04* + + +## jsqlparser-3.1 (2019-11-06) + +### Other changes + +**fixes #344** + + +[43862](https://github.com/JSQLParser/JSqlParser/commit/43862ddf607493d) wumpz *2019-11-06 22:23:56* + +**fixes #344** + + +[782de](https://github.com/JSQLParser/JSqlParser/commit/782de006989e787) wumpz *2019-11-06 22:23:06* + +**Adding support for complex expressions in the ORDER BY clause (#890)** + + +[678ac](https://github.com/JSQLParser/JSqlParser/commit/678ac96b5948175) Tomer Shay (Shimshi) *2019-10-31 07:19:03* + +**fixes #884** + + +[1d8a9](https://github.com/JSQLParser/JSqlParser/commit/1d8a9479ff3fc6f) wumpz *2019-10-26 21:38:48* + +**fixes #880** + + +[7746b](https://github.com/JSQLParser/JSqlParser/commit/7746bbb7ffa8fb4) wumpz *2019-10-26 21:25:47* + +**** + + +[552bf](https://github.com/JSQLParser/JSqlParser/commit/552bf605ec075ec) wumpz *2019-10-26 20:41:45* + +**Added support for Oracle UNPIVOT keyword. (#882)** + +* Added support for Oracle UNPIVOT keyword. +* Back to original version number. +* Updated imports. +* Added missing import. + +[bcc27](https://github.com/JSQLParser/JSqlParser/commit/bcc271870ad767f) Pascal Mulder *2019-10-26 20:35:43* + +**fixes #878** + + +[c2836](https://github.com/JSQLParser/JSqlParser/commit/c2836f6a276879e) wumpz *2019-10-26 20:27:03* + +**fixes #869** + + +[5b781](https://github.com/JSQLParser/JSqlParser/commit/5b78153ad5b8eb1) wumpz *2019-10-18 23:02:59* + +**fixes #876** + + +[144e6](https://github.com/JSQLParser/JSqlParser/commit/144e60b43fd24ab) wumpz *2019-10-18 21:19:50* + +**fixes #866** + + +[25e1d](https://github.com/JSQLParser/JSqlParser/commit/25e1dcc3fc83440) wumpz *2019-10-16 22:44:27* + +**fixes #862** + + +[51c92](https://github.com/JSQLParser/JSqlParser/commit/51c92d89389f780) wumpz *2019-10-16 21:40:42* + +**tests #874** + + +[1ecfc](https://github.com/JSQLParser/JSqlParser/commit/1ecfcbc4abfd054) wumpz *2019-10-16 20:46:13* + +**fixes #865** + + +[8a965](https://github.com/JSQLParser/JSqlParser/commit/8a965554e1005ca) wumpz *2019-10-14 21:12:05* + +**fixes #867** + + +[22229](https://github.com/JSQLParser/JSqlParser/commit/22229459fb65b6f) wumpz *2019-10-09 08:40:11* + +**fixes #867** + + +[6ef7e](https://github.com/JSQLParser/JSqlParser/commit/6ef7ebbad314090) wumpz *2019-10-09 08:38:23* + +**fixes #847** + + +[2147a](https://github.com/JSQLParser/JSqlParser/commit/2147a21b0caee90) wumpz *2019-10-05 22:41:29* + +**allowing start as keyword for column and tablenames** + + +[f9bba](https://github.com/JSQLParser/JSqlParser/commit/f9bba25386300ca) wumpz *2019-10-05 22:39:45* + +**allowing start as keyword for column and tablenames** + + +[cc6a4](https://github.com/JSQLParser/JSqlParser/commit/cc6a4c5cba1e523) wumpz *2019-10-05 22:37:57* + +**fixes #859** + + +[8e61a](https://github.com/JSQLParser/JSqlParser/commit/8e61a1884297af9) wumpz *2019-10-01 06:14:39* + +**Update README.md** + + +[c6441](https://github.com/JSQLParser/JSqlParser/commit/c6441e05b5d3c59) Tobias *2019-09-30 23:04:05* + +**Fixes linkage of SubSelect to Node** + + +[55783](https://github.com/JSQLParser/JSqlParser/commit/557831dc6621141) PGrafkin *2019-09-22 19:02:33* + +**fixes #845** + + +[d6b4e](https://github.com/JSQLParser/JSqlParser/commit/d6b4e4d7bec895a) wumpz *2019-09-20 15:01:04* + +**** + + +[56ddc](https://github.com/JSQLParser/JSqlParser/commit/56ddc2d8fe4e898) wumpz *2019-09-20 14:41:27* + +**fixes #849** + + +[62a03](https://github.com/JSQLParser/JSqlParser/commit/62a0341a35690fe) wumpz *2019-09-20 14:39:58* + +**fixes #848** + + +[1d2c2](https://github.com/JSQLParser/JSqlParser/commit/1d2c261721d0d61) wumpz *2019-09-20 13:05:40* + +**** + + +[484ea](https://github.com/JSQLParser/JSqlParser/commit/484ea9dd02a9c4c) wumpz *2019-09-20 13:05:14* + +**fixes #850** + + +[1cd3c](https://github.com/JSQLParser/JSqlParser/commit/1cd3c27f32aed64) wumpz *2019-09-20 12:26:44* + +**Update README.md** + + +[6191a](https://github.com/JSQLParser/JSqlParser/commit/6191ae0646e1e40) Tobias *2019-08-29 21:32:25* + + +## jsqlparser-3.0 (2019-08-29) + +### Other changes + +**fixes #842** + + +[516ea](https://github.com/JSQLParser/JSqlParser/commit/516ea8a3a6988b0) wumpz *2019-08-26 22:12:59* + +**fixes #750 - duplicate** + + +[dd7ed](https://github.com/JSQLParser/JSqlParser/commit/dd7eda0c4c6ab8c) wumpz *2019-08-19 08:07:41* + +**** + + +[55974](https://github.com/JSQLParser/JSqlParser/commit/55974c31d955565) wumpz *2019-08-14 15:23:23* + +**** + + +[c481c](https://github.com/JSQLParser/JSqlParser/commit/c481ce03c35ea0d) wumpz *2019-08-13 19:44:50* + +**fixes #677** + + +[695d5](https://github.com/JSQLParser/JSqlParser/commit/695d532571c02c1) wumpz *2019-08-13 19:33:14* + +**fixes #378** + + +[7a133](https://github.com/JSQLParser/JSqlParser/commit/7a133446d0c7fe4) wumpz *2019-08-13 19:26:13* + +**fixes #377** + + +[9b6c4](https://github.com/JSQLParser/JSqlParser/commit/9b6c46c376f4591) wumpz *2019-08-13 19:24:23* + +**fixes #489** + + +[27139](https://github.com/JSQLParser/JSqlParser/commit/27139a034edda7b) wumpz *2019-08-13 19:21:27* + +**fixes #648** + +* fixes #638 + +[74e02](https://github.com/JSQLParser/JSqlParser/commit/74e02267404da4e) wumpz *2019-08-13 19:19:12* + +**** + + +[36907](https://github.com/JSQLParser/JSqlParser/commit/36907e4e1295fc1) wumpz *2019-08-11 22:25:40* + +**** + + +[48dbd](https://github.com/JSQLParser/JSqlParser/commit/48dbd58c6ad38bc) wumpz *2019-08-11 20:54:19* + +**** + + +[089e6](https://github.com/JSQLParser/JSqlParser/commit/089e6b4667ca921) wumpz *2019-08-11 20:32:24* + +**** + + +[ca821](https://github.com/JSQLParser/JSqlParser/commit/ca821e5277c8ffd) wumpz *2019-08-11 20:31:58* + +**** + + +[b3cfd](https://github.com/JSQLParser/JSqlParser/commit/b3cfdac1a31a8de) wumpz *2019-08-11 08:36:52* + +**** + + +[d86cb](https://github.com/JSQLParser/JSqlParser/commit/d86cb90b0f0ff5b) wumpz *2019-08-11 08:08:22* + +**** + + +[68d01](https://github.com/JSQLParser/JSqlParser/commit/68d01212af90b3d) wumpz *2019-08-11 08:06:16* + +**fixes #838** + + +[1d1b6](https://github.com/JSQLParser/JSqlParser/commit/1d1b62507670a9b) wumpz *2019-08-09 21:22:53* + +**fixes #826** + + +[7567d](https://github.com/JSQLParser/JSqlParser/commit/7567d25fdabf631) wumpz *2019-08-09 20:59:36* + +**fixes #826** + + +[01296](https://github.com/JSQLParser/JSqlParser/commit/01296c302471a9c) wumpz *2019-08-09 20:49:18* + +**** + + +[30619](https://github.com/JSQLParser/JSqlParser/commit/30619d8f214d876) wumpz *2019-08-09 14:07:15* + +**Delete ISSUE_TEMPLATE.md** + + +[9bea1](https://github.com/JSQLParser/JSqlParser/commit/9bea1e3850e2078) Tobias *2019-08-09 06:31:24* + +**Update issue templates** + + +[1182e](https://github.com/JSQLParser/JSqlParser/commit/1182e8b792beac4) Tobias *2019-08-09 06:31:05* + +**fixes #828** + + +[5139f](https://github.com/JSQLParser/JSqlParser/commit/5139fb279960013) wumpz *2019-08-08 21:16:23* + +**fixes #828** + + +[8d0de](https://github.com/JSQLParser/JSqlParser/commit/8d0dec177748bdf) wumpz *2019-08-08 21:11:19* + +**** + + +[c766e](https://github.com/JSQLParser/JSqlParser/commit/c766ebce151708c) wumpz *2019-08-07 23:24:17* + +**** + + +[1a732](https://github.com/JSQLParser/JSqlParser/commit/1a732025a27872d) wumpz *2019-08-07 23:22:23* + +**** + + +[5c530](https://github.com/JSQLParser/JSqlParser/commit/5c5303eb8997f03) wumpz *2019-08-07 18:20:34* + +**Updated test** + + +[47457](https://github.com/JSQLParser/JSqlParser/commit/47457ed95a8e688) Tomer S *2019-08-05 20:14:23* + +**Fix issue of missing comma between joins in subjoin** + + +[92db2](https://github.com/JSQLParser/JSqlParser/commit/92db2d81fbed39d) Tomer S *2019-08-05 19:43:18* + +**Fix issue of missing comma between joins in subjoin** + + +[449c4](https://github.com/JSQLParser/JSqlParser/commit/449c4e89c2a9c6a) Tomer S *2019-08-05 19:32:41* + +**** + + +[e586f](https://github.com/JSQLParser/JSqlParser/commit/e586fa31e251221) t.warneke@gmx.net *2019-08-03 23:27:55* + +**Update latest version(1.4 => 2.1)** + + +[5768e](https://github.com/JSQLParser/JSqlParser/commit/5768ea92f63c2ab) yidasanqian *2019-08-02 09:29:48* + +**added linkast to table** + + +[9c5f5](https://github.com/JSQLParser/JSqlParser/commit/9c5f52f3dddb10c) wumpz *2019-08-01 06:44:58* + +**The duration part in INTERVAL expressions can contain a column and not only a constant - now supporting that use case** + + +[5492f](https://github.com/JSQLParser/JSqlParser/commit/5492f5105a75781) Tomer S *2019-07-26 17:15:25* + +**** + + +[1314c](https://github.com/JSQLParser/JSqlParser/commit/1314cd0e7f05543) wumpz *2019-07-22 22:00:36* + +**** + + +[2b944](https://github.com/JSQLParser/JSqlParser/commit/2b944807b6e9058) wumpz *2019-07-22 21:17:54* + +**** + + +[86693](https://github.com/JSQLParser/JSqlParser/commit/86693e0bf34fbf9) wumpz *2019-07-21 21:33:59* + +**proof of correct parsing for #829** + + +[12ff2](https://github.com/JSQLParser/JSqlParser/commit/12ff225b0afd16f) wumpz *2019-07-21 21:27:36* + +**fixes #830** + + +[a416b](https://github.com/JSQLParser/JSqlParser/commit/a416b96e7576dd0) wumpz *2019-07-21 21:11:51* + +**fixes #830** + + +[5fc7c](https://github.com/JSQLParser/JSqlParser/commit/5fc7ce8f6cfeef6) wumpz *2019-07-21 21:08:22* + +**** + + +[914ee](https://github.com/JSQLParser/JSqlParser/commit/914ee73b6de95ae) wumpz *2019-07-21 20:42:54* + +**** + + +[0b404](https://github.com/JSQLParser/JSqlParser/commit/0b404539ab6e985) wumpz *2019-07-21 20:42:38* + +**Update README.md** + + +[216bd](https://github.com/JSQLParser/JSqlParser/commit/216bd3733cacfee) Tobias *2019-07-19 06:23:59* + +**Update README.md** + + +[7077d](https://github.com/JSQLParser/JSqlParser/commit/7077d2148bf9e06) Tobias *2019-07-18 05:58:47* + +**Update README.md** + + +[6148a](https://github.com/JSQLParser/JSqlParser/commit/6148a895113ed5b) Tobias *2019-07-18 05:57:14* + +**Update README.md** + + +[f28b6](https://github.com/JSQLParser/JSqlParser/commit/f28b6252683d2d4) Tobias *2019-07-18 05:56:14* + +**** + + +[34014](https://github.com/JSQLParser/JSqlParser/commit/34014c2b9ac862f) wumpz *2019-07-17 22:46:55* + +**allow jdk 11 build** + + +[73be3](https://github.com/JSQLParser/JSqlParser/commit/73be39017363a4e) wumpz *2019-07-17 22:36:28* + +**allow jdk 11 build** + + +[2cf8e](https://github.com/JSQLParser/JSqlParser/commit/2cf8e15b8987458) wumpz *2019-07-17 22:35:51* + +**fixes limit as name for jdbc named parameters** + + +[7034c](https://github.com/JSQLParser/JSqlParser/commit/7034cb10c6abe11) wumpz *2019-07-17 22:03:55* + +**Update README.md** + + +[bf942](https://github.com/JSQLParser/JSqlParser/commit/bf942f92098f5cc) Tobias *2019-07-12 20:37:33* + +**Update FUNDING.yml** + + +[448da](https://github.com/JSQLParser/JSqlParser/commit/448da80f820a270) Tobias *2019-07-12 20:33:32* + +**Create FUNDING.yml** + + +[73c82](https://github.com/JSQLParser/JSqlParser/commit/73c82ad776db592) Tobias *2019-07-12 20:32:32* + +**** + + +[55f20](https://github.com/JSQLParser/JSqlParser/commit/55f20e07faa13ee) wumpz *2019-07-10 23:12:27* + +**** + + +[27552](https://github.com/JSQLParser/JSqlParser/commit/275522f53782871) wumpz *2019-07-10 21:43:51* + +**moved to java 8** + + +[bfb8e](https://github.com/JSQLParser/JSqlParser/commit/bfb8e274f247350) wumpz *2019-07-09 22:41:18* + +**** + + +[39c6a](https://github.com/JSQLParser/JSqlParser/commit/39c6a4885f7bd20) wumpz *2019-07-09 22:31:35* + +**** + + +[6001f](https://github.com/JSQLParser/JSqlParser/commit/6001fdecada77fa) wumpz *2019-07-09 21:15:42* + +**** + + +[cfc3f](https://github.com/JSQLParser/JSqlParser/commit/cfc3f64850410bc) wumpz *2019-07-09 21:12:01* + +**Support default mode in full text search** + + +[ecb54](https://github.com/JSQLParser/JSqlParser/commit/ecb5464ccb6bab4) Tomer S *2019-07-07 18:04:00* + +**** + + +[0022e](https://github.com/JSQLParser/JSqlParser/commit/0022ef4889f39de) wumpz *2019-07-07 12:11:44* + +**** + + +[694d0](https://github.com/JSQLParser/JSqlParser/commit/694d06ccf707494) wumpz *2019-07-04 21:51:34* + +**Add support for full text search (MATCH..AGAINST)** + + +[6750a](https://github.com/JSQLParser/JSqlParser/commit/6750a5360084439) Tomer S *2019-07-04 21:23:25* + +**** + + +[c88f5](https://github.com/JSQLParser/JSqlParser/commit/c88f5ba08f4ee41) wumpz *2019-07-04 20:51:01* + +**Adding support for IS [NOT] TRUE/FALSE expressions** + + +[00839](https://github.com/JSQLParser/JSqlParser/commit/0083971851df6d4) Tomer S *2019-07-02 21:39:16* + +**Adding support for the DIV operator** + + +[c8bbc](https://github.com/JSQLParser/JSqlParser/commit/c8bbc0f7ecf198e) Tomer S *2019-07-02 19:28:47* + +**fixes #200 - was already fixed, introduced test case** + + +[4d100](https://github.com/JSQLParser/JSqlParser/commit/4d100a7c011abda) wumpz *2019-07-02 12:43:46* + +**fixes #259 - was already fixed, introduced test case** + + +[500ee](https://github.com/JSQLParser/JSqlParser/commit/500ee6e5010fe79) wumpz *2019-07-02 12:40:33* + +**fixes #262 - was already fixed, introduced test case** + + +[dbdfb](https://github.com/JSQLParser/JSqlParser/commit/dbdfb4ea45121c9) wumpz *2019-07-02 12:36:31* + +**fixes #113** + + +[cd16a](https://github.com/JSQLParser/JSqlParser/commit/cd16a6d911fe8b2) wumpz *2019-07-02 12:28:02* + +**** + + +[424c8](https://github.com/JSQLParser/JSqlParser/commit/424c81ce91887d5) wumpz *2019-06-30 19:55:27* + +**** + + +[d6949](https://github.com/JSQLParser/JSqlParser/commit/d6949999cd77c97) wumpz *2019-06-30 17:08:23* + +**Add support for STRAIGHT_JOIN** + + +[89089](https://github.com/JSQLParser/JSqlParser/commit/890898806d2b6b3) Tomer S *2019-04-04 17:15:48* + + +## jsqlparser-2.1 (2019-06-30) + +### Other changes + +**fixes #812** + + +[38aad](https://github.com/JSQLParser/JSqlParser/commit/38aadee9b2a941b) wumpz *2019-06-25 23:07:07* + +**Update README.md** + + +[4763d](https://github.com/JSQLParser/JSqlParser/commit/4763d455148bb75) Tobias *2019-06-25 12:28:29* + +**Update README.md** + + +[334b5](https://github.com/JSQLParser/JSqlParser/commit/334b5498859733d) Tobias *2019-06-25 12:27:52* + +**Support KSQL's WINDOW** + +* Add support for KSQL's WINDOW (HOPPING, TUMBLING and SESSION window) + +[ef911](https://github.com/JSQLParser/JSqlParser/commit/ef9119806146f25) Suyash Garg *2019-06-21 12:00:06* + +**downgraded javacc version to allow java 7 build** + + +[6e7b9](https://github.com/JSQLParser/JSqlParser/commit/6e7b976d65d7eb6) wumpz *2019-06-19 07:33:53* + +**downgraded checkstyle version to allow java 7 build** + + +[a9c29](https://github.com/JSQLParser/JSqlParser/commit/a9c29ffceab9e58) wumpz *2019-06-19 07:29:55* + +**Update README.md** + + +[b5915](https://github.com/JSQLParser/JSqlParser/commit/b59151eae9d2ac5) Tobias *2019-06-16 22:11:11* + +**** + + +[afcc0](https://github.com/JSQLParser/JSqlParser/commit/afcc0a9b2063ade) wumpz *2019-06-16 21:49:09* + +**** + + +[1d203](https://github.com/JSQLParser/JSqlParser/commit/1d203850be1679c) wumpz *2019-06-16 21:06:13* + +**fixes #789** + + +[cdf80](https://github.com/JSQLParser/JSqlParser/commit/cdf805f4028b801) wumpz *2019-06-16 21:02:47* + +**fixes #450** + + +[83dba](https://github.com/JSQLParser/JSqlParser/commit/83dbac2d9841d21) wumpz *2019-06-13 22:11:29* + +**support postgresql create index syntax** + + +[9d74c](https://github.com/JSQLParser/JSqlParser/commit/9d74c6da03976ea) theodore johnson *2019-06-13 22:02:11* + +**fixes #705** + + +[9ce65](https://github.com/JSQLParser/JSqlParser/commit/9ce65cde0f25ae1) wumpz *2019-06-13 21:38:14* + +**site update** + + +[89f20](https://github.com/JSQLParser/JSqlParser/commit/89f202a3062b30a) wumpz *2019-05-29 13:40:18* + +**fixes #798** + + +[dd806](https://github.com/JSQLParser/JSqlParser/commit/dd806991c4283d0) wumpz *2019-05-24 21:09:13* + +**fixes #796** + + +[aecc4](https://github.com/JSQLParser/JSqlParser/commit/aecc41442a8dfd3) wumpz *2019-05-18 21:00:13* + +**fixes #785** + + +[f59f2](https://github.com/JSQLParser/JSqlParser/commit/f59f2b5c9b8e33e) wumpz *2019-05-04 22:54:28* + +**Fix #786 (#787)** + + +[f2aba](https://github.com/JSQLParser/JSqlParser/commit/f2aba0b4ef018a1) Ryan J Murphy *2019-04-22 22:28:38* + +**** + + +[44ff9](https://github.com/JSQLParser/JSqlParser/commit/44ff9ed6bd0d39d) wumpz *2019-04-22 22:28:10* + +**fixes #773 added nextval as a valid object name** + + +[94a2a](https://github.com/JSQLParser/JSqlParser/commit/94a2a40fa7f93a2) wumpz *2019-04-17 08:15:50* + +**** + + +[85a3e](https://github.com/JSQLParser/JSqlParser/commit/85a3e69fed2db1a) wumpz *2019-04-17 07:05:47* + +**** + + +[8d4b3](https://github.com/JSQLParser/JSqlParser/commit/8d4b32a28e3eac1) wumpz *2019-04-17 07:00:01* + +**** + + +[703a7](https://github.com/JSQLParser/JSqlParser/commit/703a7459a529343) wumpz *2019-04-17 06:43:37* + +**recreated "old" javadocs (without improving it)** + + +[74e2a](https://github.com/JSQLParser/JSqlParser/commit/74e2a4b4498088e) wumpz *2019-04-17 06:19:27* + +**recreated "old" javadocs (without improving it)** + + +[4fed7](https://github.com/JSQLParser/JSqlParser/commit/4fed7536c8036ed) wumpz *2019-04-16 07:59:20* + +**JavaDoc for Column#getTable (#782)** + + +[4f500](https://github.com/JSQLParser/JSqlParser/commit/4f500a48572234a) Andrea Arcuri *2019-04-15 12:01:37* + +**** + + +[e2168](https://github.com/JSQLParser/JSqlParser/commit/e2168407d929c77) wumpz *2019-04-13 23:57:14* + +**fixes #777** + + +[35a1c](https://github.com/JSQLParser/JSqlParser/commit/35a1c97f3609007) wumpz *2019-04-12 22:30:00* + +**tests #775** + +* removed some not flags from some classes + +[8dda4](https://github.com/JSQLParser/JSqlParser/commit/8dda4a60a8e558d) wumpz *2019-04-08 21:36:40* + +**tests #754** + + +[97797](https://github.com/JSQLParser/JSqlParser/commit/97797425f635621) wumpz *2019-03-31 21:22:51* + +**fixes #770** + + +[86ea6](https://github.com/JSQLParser/JSqlParser/commit/86ea6016636fe5b) wumpz *2019-03-28 22:19:33* + +**** + + +[f958f](https://github.com/JSQLParser/JSqlParser/commit/f958fa741dea3d0) wumpz *2019-03-20 22:41:16* + +**** + + +[b1da6](https://github.com/JSQLParser/JSqlParser/commit/b1da6e5225a2269) wumpz *2019-03-20 22:37:59* + +**fixes #766** + + +[1bb5c](https://github.com/JSQLParser/JSqlParser/commit/1bb5c3d5823560d) wumpz *2019-03-20 22:05:30* + +**fixes #755 - corrected error introduced due to corrected ExpressionDeParser.** + + +[0002c](https://github.com/JSQLParser/JSqlParser/commit/0002cb717106722) wumpz *2019-03-20 09:57:29* + +**fixes #755** + + +[a6905](https://github.com/JSQLParser/JSqlParser/commit/a690558d1d8f19d) wumpz *2019-03-20 09:38:36* + +**** + + +[aff50](https://github.com/JSQLParser/JSqlParser/commit/aff505390efcb9c) wumpz *2019-03-20 06:46:44* + +**** + + +[7da90](https://github.com/JSQLParser/JSqlParser/commit/7da901adcb0370d) wumpz *2019-03-20 06:45:31* + +**** + + +[18a3c](https://github.com/JSQLParser/JSqlParser/commit/18a3c4acb6f84bb) wumpz *2019-03-20 06:35:17* + +**activated new checkstyle plugin only if used java is at least 1.8** + + +[1b4e9](https://github.com/JSQLParser/JSqlParser/commit/1b4e9957ecd9daf) wumpz *2019-03-17 23:00:12* + +**** + + +[6ceb4](https://github.com/JSQLParser/JSqlParser/commit/6ceb4062d3ccb2c) wumpz *2019-03-16 22:56:17* + +**upgraded checkstyle due to security alert** + + +[cb172](https://github.com/JSQLParser/JSqlParser/commit/cb1726e478d39e6) wumpz *2019-03-16 22:40:36* + +**Fixed typos in README.md (#760)** + + +[67dce](https://github.com/JSQLParser/JSqlParser/commit/67dce2f40b4e484) alterdego *2019-03-14 12:20:26* + +**update README.md (#762)** + +* update latest version(1.4) + +[13d6a](https://github.com/JSQLParser/JSqlParser/commit/13d6a9fe183a5ab) r548 *2019-03-14 12:19:58* + +**** + + +[46323](https://github.com/JSQLParser/JSqlParser/commit/46323b4df4119e6) wumpz *2019-03-12 07:56:12* + + +## jsqlparser-2.0 (2019-03-16) + +### Other changes + +**** + + +[526b9](https://github.com/JSQLParser/JSqlParser/commit/526b90b8d353a01) wumpz *2019-03-16 22:16:01* + +**corrected test** + + +[4ad79](https://github.com/JSQLParser/JSqlParser/commit/4ad79d05b5306c2) wumpz *2019-03-04 18:46:57* + +**fixes #17** + + +[1ef39](https://github.com/JSQLParser/JSqlParser/commit/1ef39301666c3e3) wumpz *2019-03-04 00:26:21* + +**refactored group by expressions into separate class, first step to support grouping sets** + + +[82f3d](https://github.com/JSQLParser/JSqlParser/commit/82f3da8ce946d70) wumpz *2019-03-03 22:25:31* + +**** + + +[749ad](https://github.com/JSQLParser/JSqlParser/commit/749ad556d917a01) wumpz *2019-02-26 23:09:43* + +**Fixes 649 to add support for HOUR, MINUTE, SECOND date literals and support for identifiers as the interval parameter. (#756)** + + +[cbcf0](https://github.com/JSQLParser/JSqlParser/commit/cbcf0a73d516bfc) thebiguno *2019-02-25 22:23:16* + +**** + + +[c85e7](https://github.com/JSQLParser/JSqlParser/commit/c85e79b3cd75119) wumpz *2019-02-24 22:17:37* + +**** + + +[0f9bb](https://github.com/JSQLParser/JSqlParser/commit/0f9bb4e6272f71b) wumpz *2019-02-24 19:59:06* + +**fixes #649** + +* and implemented ! for not and extended not expression + +[10e8e](https://github.com/JSQLParser/JSqlParser/commit/10e8e2568eb7711) wumpz *2019-02-23 23:32:38* + +**** + + +[15297](https://github.com/JSQLParser/JSqlParser/commit/15297868572dba9) wumpz *2019-02-20 23:30:16* + +**** + + +[12c05](https://github.com/JSQLParser/JSqlParser/commit/12c056451444678) wumpz *2019-02-20 23:20:35* + +**** + + +[14f92](https://github.com/JSQLParser/JSqlParser/commit/14f92b13cc4503f) wumpz *2019-02-20 23:05:20* + +**fixes #164** + + +[8c057](https://github.com/JSQLParser/JSqlParser/commit/8c057ab735f0249) wumpz *2019-02-20 22:41:50* + +**fixes #169** + + +[e1193](https://github.com/JSQLParser/JSqlParser/commit/e1193a63a6551ba) wumpz *2019-02-20 21:43:45* + +**fixes #479** + + +[0b5f5](https://github.com/JSQLParser/JSqlParser/commit/0b5f586cf3f9250) wumpz *2019-02-19 22:29:58* + +**fixes #479** + + +[b029b](https://github.com/JSQLParser/JSqlParser/commit/b029bb5860b3ed3) wumpz *2019-02-19 22:28:06* + +**Update README.md** + + +[fa162](https://github.com/JSQLParser/JSqlParser/commit/fa1624165e80895) Tobias *2019-02-19 17:31:13* + +**Added support for DROP INDEX, ADD UNIQUE INDEX, ALGORITHM and USING (#752)** + +* Merge recent changes in the master from the master (#1) +* changed license header to represent the projects dual license +* changed license header to represent the projects dual license +* changed license header to represent the projects dual license +* changed license header to represent the projects dual license +* Added support for comment(s) for column definitions in CREATE TABLE s… (#743) +* Added support for comment(s) for column definitions in CREATE TABLE statements +* Added support for comment(s) for column definitions in CREATE TABLE statements #2 +* To increase code coverage +* To increase code coverage #2 +* Added support for 'ALTER TABLE CHANGE COLUMN' (#741) +* Added support for 'ALTER TABLE CHANGE COLUMN oldName newName columnDefinition'. Please see https://dev.mysql.com/doc/refman/8.0/en/alter-table.html for reference. +* Returned import ordering to avoid conflicts +* Improved the tests somewhat +* Now also test the getOptionalSpecifier() for both cases (null and not-null) +* Expanded tests for ALTER TABLE ... CHANGE +* implemented optimize for, fixes #348 +* implemented optimize for, fixes #348 +* Support for simple informix outer joins. (#745) +* added support for simple informix outer joins +* added some test code +* added support for simple informix outer joins +* added some test code +* more testing for better code coverage +* added support for simple informix outer joins +* added some test code +* more testing for better code coverage +* fixes #747 +* fixes #733 +* fixes #707 +* Update README.md +* Update README.md +* Fix handles the following cases: 1) DROP INDEX 2) ADD UNIQUE INDEX 3) ALGORITHM 4) USING <index type> + +[2830c](https://github.com/JSQLParser/JSqlParser/commit/2830c17ea226635) Prateek Gupta *2019-02-19 00:44:35* + +**fixes #753** + + +[3209a](https://github.com/JSQLParser/JSqlParser/commit/3209a16c55c1976) wumpz *2019-02-19 00:35:14* + +**Update README.md** + + +[4f74f](https://github.com/JSQLParser/JSqlParser/commit/4f74f6d110166a8) Tobias *2019-02-15 21:12:05* + +**Update README.md** + + +[f9609](https://github.com/JSQLParser/JSqlParser/commit/f960991759ed604) Tobias *2019-02-15 21:07:41* + +**fixes #707** + + +[a1c4f](https://github.com/JSQLParser/JSqlParser/commit/a1c4f4a7ddda62e) wumpz *2019-02-14 22:50:16* + +**** + + +[6c413](https://github.com/JSQLParser/JSqlParser/commit/6c413b404b1bd27) wumpz *2019-02-11 23:07:46* + +**fixes #733** + + +[6da69](https://github.com/JSQLParser/JSqlParser/commit/6da696b496eb794) wumpz *2019-02-10 23:11:54* + +**fixes #747** + + +[d3553](https://github.com/JSQLParser/JSqlParser/commit/d3553bc7f8c3b12) wumpz *2019-02-10 23:00:02* + +**** + + +[73305](https://github.com/JSQLParser/JSqlParser/commit/73305fe6a6efec1) wumpz *2019-02-10 22:55:01* + +**** + + +[f79f5](https://github.com/JSQLParser/JSqlParser/commit/f79f58d9f8f5c73) wumpz *2019-02-10 22:38:19* + +**** + + +[154cf](https://github.com/JSQLParser/JSqlParser/commit/154cf371d775b9b) wumpz *2019-02-10 21:54:45* + +**** + + +[80153](https://github.com/JSQLParser/JSqlParser/commit/80153dfdf60f9b4) wumpz *2019-02-10 21:14:10* + +**** + + +[04151](https://github.com/JSQLParser/JSqlParser/commit/0415140ecf58894) wumpz *2019-02-08 07:13:18* + +**Support for simple informix outer joins. (#745)** + +* added support for simple informix outer joins +* added some test code +* added support for simple informix outer joins +* added some test code +* more testing for better code coverage +* added support for simple informix outer joins +* added some test code +* more testing for better code coverage + +[53e24](https://github.com/JSQLParser/JSqlParser/commit/53e247bffdae557) Kurt Schwitters *2019-02-08 05:52:51* + +**** + + +[1a3d2](https://github.com/JSQLParser/JSqlParser/commit/1a3d289238eec35) wumpz *2019-02-07 23:30:55* + +**** + + +[9ec7d](https://github.com/JSQLParser/JSqlParser/commit/9ec7d8572ca0424) wumpz *2019-02-07 23:30:00* + +**** + + +[63477](https://github.com/JSQLParser/JSqlParser/commit/6347776ad571d92) wumpz *2019-02-07 23:25:29* + +**implemented optimize for, fixes #348** + + +[ff23d](https://github.com/JSQLParser/JSqlParser/commit/ff23dde74433355) wumpz *2019-02-07 23:21:22* + +**implemented optimize for, fixes #348** + + +[4b0b5](https://github.com/JSQLParser/JSqlParser/commit/4b0b5cb044bc973) wumpz *2019-02-07 23:19:46* + +**Added support for 'ALTER TABLE CHANGE COLUMN' (#741)** + +* Added support for 'ALTER TABLE CHANGE COLUMN oldName newName columnDefinition'. Please see https://dev.mysql.com/doc/refman/8.0/en/alter-table.html for reference. +* Returned import ordering to avoid conflicts +* Improved the tests somewhat +* Now also test the getOptionalSpecifier() for both cases (null and not-null) +* Expanded tests for ALTER TABLE ... CHANGE + +[bfb80](https://github.com/JSQLParser/JSqlParser/commit/bfb8023318c31b2) Simon *2019-02-07 14:49:28* + +**Added support for comment(s) for column definitions in CREATE TABLE s… (#743)** + +* Added support for comment(s) for column definitions in CREATE TABLE statements +* Added support for comment(s) for column definitions in CREATE TABLE statements #2 +* To increase code coverage +* To increase code coverage #2 + +[07b86](https://github.com/JSQLParser/JSqlParser/commit/07b86761d0b4aee) Prateek Gupta *2019-02-07 07:09:26* + +**changed license header to represent the projects dual license** + + +[b9023](https://github.com/JSQLParser/JSqlParser/commit/b90234f0fc39d34) wumpz *2019-02-06 20:53:15* + +**changed license header to represent the projects dual license** + + +[2adec](https://github.com/JSQLParser/JSqlParser/commit/2adec6ad552f770) wumpz *2019-02-06 20:48:58* + +**changed license header to represent the projects dual license** + + +[4ad99](https://github.com/JSQLParser/JSqlParser/commit/4ad996f778f043b) wumpz *2019-02-06 20:47:19* + +**changed license header to represent the projects dual license** + + +[373c6](https://github.com/JSQLParser/JSqlParser/commit/373c6cb59734091) wumpz *2019-02-05 23:04:45* + +**integrated some additional AST - Nodes for InExpression and SimpleExpressionList** + + +[cb0e0](https://github.com/JSQLParser/JSqlParser/commit/cb0e0b79564258a) wumpz *2019-02-04 01:17:35* + +**** + + +[4e0a7](https://github.com/JSQLParser/JSqlParser/commit/4e0a7326a9d9e9e) wumpz *2019-02-03 23:20:03* + +**case else corrected to allow conditions here as well** + + +[4f7a1](https://github.com/JSQLParser/JSqlParser/commit/4f7a1537e7ba368) wumpz *2019-02-03 22:53:22* + +**refactored outer not from sqlconditions, regularconditions to condition** + + +[aae36](https://github.com/JSQLParser/JSqlParser/commit/aae36da486303f8) wumpz *2019-02-03 21:07:08* + +**refactored outer not from sqlconditions, regularconditions to condition** + + +[1956b](https://github.com/JSQLParser/JSqlParser/commit/1956b84395fcab9) wumpz *2019-02-03 20:57:41* + +**strange not problem** + + +[ba3bf](https://github.com/JSQLParser/JSqlParser/commit/ba3bf2241c1021b) wumpz *2019-02-03 19:57:00* + +**named exec procedure parameters** + + +[82b28](https://github.com/JSQLParser/JSqlParser/commit/82b287dae64ac43) wumpz *2019-02-01 23:51:28* + +**finished multi value set** + + +[479ee](https://github.com/JSQLParser/JSqlParser/commit/479ee39d6efbb6d) wumpz *2019-01-27 00:37:33* + +**finished multi value set** + + +[ba4b0](https://github.com/JSQLParser/JSqlParser/commit/ba4b0ccee2cf20a) wumpz *2019-01-27 00:35:17* + +**started multivalue set** + + +[d991b](https://github.com/JSQLParser/JSqlParser/commit/d991bbe377418a1) wumpz *2019-01-26 00:44:59* + +**corrected typing error. Both licenses could not be applied at the same time.** + + +[7cd18](https://github.com/JSQLParser/JSqlParser/commit/7cd189c326d3d84) wumpz *2019-01-23 23:22:12* + +**allow top keyword as column / table / alias name** + +* implemented tests + +[9e81e](https://github.com/JSQLParser/JSqlParser/commit/9e81e1592200952) wumpz *2019-01-23 23:00:12* + +**allow top keyword as column / table / alias name** + +* implemented tests + +[ed95e](https://github.com/JSQLParser/JSqlParser/commit/ed95e877802f46e) wumpz *2019-01-23 22:58:39* + +**implemented _utf8** + + +[fe28e](https://github.com/JSQLParser/JSqlParser/commit/fe28e88d948dc7e) wumpz *2019-01-23 21:36:42* + +**implemented explain select** + + +[e5c6f](https://github.com/JSQLParser/JSqlParser/commit/e5c6ff6fdf3d4b2) wumpz *2019-01-22 23:28:33* + +**implemented explain select** + + +[fb45d](https://github.com/JSQLParser/JSqlParser/commit/fb45dd7c77ccff0) wumpz *2019-01-22 23:06:34* + +**Add support for casting to signed integer (#734)** + + +[5b00a](https://github.com/JSQLParser/JSqlParser/commit/5b00ace4d49b731) tomershay *2019-01-21 22:58:57* + +**corrected stackoverflow while tables extraction** + +* updated readme + +[04db1](https://github.com/JSQLParser/JSqlParser/commit/04db124b85dea22) wumpz *2019-01-20 22:33:51* + +**implemented DescribeStatement, corrected TableNamesFinder, corrected corresponding interfaces and adapters, implemented tests.** + + +[1c411](https://github.com/JSQLParser/JSqlParser/commit/1c411f490e91f16) wumpz *2019-01-20 22:24:47* + +**started describe** + +* some cleanup + +[25fa3](https://github.com/JSQLParser/JSqlParser/commit/25fa31153a9a2d0) wumpz *2019-01-20 21:48:12* + + +## jsqlparser-1.4 (2019-01-09) + +### Other changes + +**Support Alter Table Add Unique Constraint (#708)** + + +[a54ea](https://github.com/JSQLParser/JSqlParser/commit/a54ea143e7eeffe) Robert Scholte *2018-12-30 23:37:29* + +**corrected some failing tests** + +* included a regression test for oracle files + +[aa932](https://github.com/JSQLParser/JSqlParser/commit/aa932c4a28d8021) wumpz *2018-12-30 23:06:59* + +**Add 'SHOW COLUMNS FROM table' (#728)** + + +[f1724](https://github.com/JSQLParser/JSqlParser/commit/f1724a468577935) Ohad Shai *2018-12-28 11:45:53* + +**Support Alter Table Drop Constraint If Exists (#709)** + +* Support Alter Table Drop Constraint If Exists +* #709 add constraintIfExists flag + +[08fed](https://github.com/JSQLParser/JSqlParser/commit/08fedf752a3f99d) Robert Scholte *2018-12-13 07:14:10* + +**Support Alter Table Alter Column Type (#724)** + + +[b3263](https://github.com/JSQLParser/JSqlParser/commit/b3263c8cbae9296) Robert Scholte *2018-12-13 07:13:12* + +**Support KSQL's WITHIN (#722)** + +* Implements WITHIN for KSQL windowed joins +* Clean up +* Improve test +* Implements WITHIN ( before TimeUnit, after TimeUnit ) for KSQL +* Also restricts TimeUnit to units accepted by KSQL +* WITHIN should come before ON + +[ae665](https://github.com/JSQLParser/JSqlParser/commit/ae665e60655f45f) Lionel Montrieux *2018-12-11 21:53:07* + +**Add support for truncate table (#719)** + + +[11be7](https://github.com/JSQLParser/JSqlParser/commit/11be71561824c36) Bartosz Firyn *2018-12-06 06:41:30* + +**fixes #718** + + +[c0801](https://github.com/JSQLParser/JSqlParser/commit/c0801a742c57ea0) wumpz *2018-12-04 15:23:42* + +**added test for issue #716** + + +[f06b1](https://github.com/JSQLParser/JSqlParser/commit/f06b19769b2eb2a) wumpz *2018-11-22 21:11:12* + +**REPLACE VIEW as a synonym to ALTER VIEW (#711)** + + +[58d39](https://github.com/JSQLParser/JSqlParser/commit/58d3965914376bf) theodore johnson *2018-11-19 14:50:36* + +**Update README.md** + + +[7b6cf](https://github.com/JSQLParser/JSqlParser/commit/7b6cff1222e1314) Tobias *2018-10-26 19:39:58* + +**Update README.md** + + +[78ebf](https://github.com/JSQLParser/JSqlParser/commit/78ebf2093a98fb5) Tobias *2018-10-26 19:38:42* + +**** + + +[22c04](https://github.com/JSQLParser/JSqlParser/commit/22c04947e3834e6) wumpz *2018-10-26 11:12:37* + +**some cleaning up for pr #702** + + +[b7754](https://github.com/JSQLParser/JSqlParser/commit/b7754e8003adec6) wumpz *2018-10-25 12:40:09* + +**support named parameters (#702)** + + +[eacb1](https://github.com/JSQLParser/JSqlParser/commit/eacb161fe848237) theodore johnson *2018-10-25 10:52:41* + +**Added Oracle COMMENT statement (#685)** + + +[e79cc](https://github.com/JSQLParser/JSqlParser/commit/e79ccc61b5bc658) hishidama *2018-10-25 10:40:33* + +**fix JSQLParser/JSqlParser #679 (#703)** + + +[0e35e](https://github.com/JSQLParser/JSqlParser/commit/0e35e224766ebb7) softommy *2018-10-25 10:35:19* + +**fixes #694** + + +[48544](https://github.com/JSQLParser/JSqlParser/commit/48544387cf2e3b5) wumpz *2018-10-18 20:50:58* + +**fixes #675** + + +[d95e0](https://github.com/JSQLParser/JSqlParser/commit/d95e034f4c1b079) wumpz *2018-10-12 22:04:57* + +**** + + +[5aa63](https://github.com/JSQLParser/JSqlParser/commit/5aa6304559a5863) wumpz *2018-10-12 21:26:26* + +**** + + +[295c1](https://github.com/JSQLParser/JSqlParser/commit/295c1147e4ef513) wumpz *2018-10-10 21:02:12* + +**** + + +[a838f](https://github.com/JSQLParser/JSqlParser/commit/a838fec1051db27) wumpz *2018-10-06 23:43:29* + +**fixes #561** + + +[f5982](https://github.com/JSQLParser/JSqlParser/commit/f598213f071d205) wumpz *2018-10-05 20:17:59* + +**fixes #561** + + +[e170c](https://github.com/JSQLParser/JSqlParser/commit/e170c4f17dc9ad7) wumpz *2018-10-05 20:15:58* + +**integrated test for values query** + + +[96499](https://github.com/JSQLParser/JSqlParser/commit/964991c4207c3bf) wumpz *2018-10-04 23:19:12* + +**integrated values statement** + + +[c0327](https://github.com/JSQLParser/JSqlParser/commit/c032744b9e083e0) wumpz *2018-10-04 22:29:11* + +**fixes some lgtm alerts** + + +[de8ad](https://github.com/JSQLParser/JSqlParser/commit/de8ad10a791705e) wumpz *2018-10-04 08:14:00* + +**fixes #684 (second)** + + +[2742a](https://github.com/JSQLParser/JSqlParser/commit/2742a889c4c4f0b) wumpz *2018-10-03 19:40:47* + +**Update README.md** + + +[77026](https://github.com/JSQLParser/JSqlParser/commit/770264da8955512) Tobias *2018-10-02 22:17:03* + + +## jsqlparser-1.3 (2018-10-02) + +### Other changes + +**fixes #684** + + +[a8b3e](https://github.com/JSQLParser/JSqlParser/commit/a8b3e71a88735dc) wumpz *2018-10-02 21:59:16* + +**fixes #682** + + +[c2833](https://github.com/JSQLParser/JSqlParser/commit/c28331102e5754e) wumpz *2018-09-20 05:48:34* + +**Add LGTM.com code quality badges (#680)** + + +[3f620](https://github.com/JSQLParser/JSqlParser/commit/3f620c9e2ddeeb4) Xavier RENE-CORAIL *2018-09-15 21:17:16* + +**fixes #670** + +* added testcase, corrected deparser + +[455c5](https://github.com/JSQLParser/JSqlParser/commit/455c5f50671eed9) wumpz *2018-09-10 15:38:54* + +**#670 (#671)** + + +[3950b](https://github.com/JSQLParser/JSqlParser/commit/3950b1962f32043) mgierw *2018-09-10 15:21:40* + +**testcase for #670** + + +[e6b9a](https://github.com/JSQLParser/JSqlParser/commit/e6b9afdb205bf2b) wumpz *2018-09-10 15:13:58* + +**fixes #676** + + +[1786e](https://github.com/JSQLParser/JSqlParser/commit/1786e215474e8da) wumpz *2018-09-08 23:44:37* + +**fixes #676** + + +[e32c5](https://github.com/JSQLParser/JSqlParser/commit/e32c502f91ed04a) wumpz *2018-09-08 22:12:46* + +**** + + +[26b2c](https://github.com/JSQLParser/JSqlParser/commit/26b2c11df4c4ac5) wumpz *2018-09-07 21:59:47* + +**** + + +[0b03c](https://github.com/JSQLParser/JSqlParser/commit/0b03c858b897713) wumpz *2018-09-07 21:48:03* + +**Update README.md (#667)** + +* Fix a couple typos/grammar issues + +[a822f](https://github.com/JSQLParser/JSqlParser/commit/a822fead1b21793) Kai Presler-Marshall *2018-08-29 13:11:41* + +**fixes #665** + + +[b806e](https://github.com/JSQLParser/JSqlParser/commit/b806e9c1897a0f3) wumpz *2018-08-27 06:51:39* + +**fixes #367** + + +[14791](https://github.com/JSQLParser/JSqlParser/commit/1479149af6a0c5c) wumpz *2018-08-25 23:12:32* + +**fixes #367** + + +[f6abb](https://github.com/JSQLParser/JSqlParser/commit/f6abb9e7edec3f1) wumpz *2018-08-25 23:10:45* + +**fixes #367** + + +[01bcb](https://github.com/JSQLParser/JSqlParser/commit/01bcbd5255a0ebd) wumpz *2018-08-25 23:07:14* + +**** + + +[1a90b](https://github.com/JSQLParser/JSqlParser/commit/1a90b16e215ac80) wumpz *2018-08-23 22:11:35* + +**** + + +[bfbfc](https://github.com/JSQLParser/JSqlParser/commit/bfbfc76eb006201) wumpz *2018-08-23 20:26:56* + +**make the CreateTable deparser use the accept/visit schema instead of the toString path (#663)** + + +[68194](https://github.com/JSQLParser/JSqlParser/commit/68194bfd6bf57d1) theodore johnson *2018-08-23 04:21:10* + +**fixes #661** + + +[44ea8](https://github.com/JSQLParser/JSqlParser/commit/44ea8bd33e01f62) wumpz *2018-08-17 06:22:30* + +**Parse Cloud Spanner raw string and byte prefixes (#659)** + +* #656 parse cloud spanner raw string and byte literals +* #656 fixed raw byte string prefix +* #656 fixed test case +* fixed reported codacy issue + +[a57db](https://github.com/JSQLParser/JSqlParser/commit/a57db5d031a5229) Knut Olav Løite *2018-08-14 08:12:26* + +**** + + +[78ff2](https://github.com/JSQLParser/JSqlParser/commit/78ff2ad4bc7496b) wumpz *2018-08-14 08:08:17* + +**** + + +[1d138](https://github.com/JSQLParser/JSqlParser/commit/1d13897883c1448) wumpz *2018-07-26 19:58:18* + +**** + + +[62bfd](https://github.com/JSQLParser/JSqlParser/commit/62bfda765247f41) wumpz *2018-07-26 09:03:10* + +**fixes #643** + + +[dc779](https://github.com/JSQLParser/JSqlParser/commit/dc779cae57b993e) wumpz *2018-07-23 14:57:23* + +**add test, fix style** + + +[98f87](https://github.com/JSQLParser/JSqlParser/commit/98f873e244046ff) theodore johnson *2018-07-16 21:35:35* + +**added a test** + + +[cfa7e](https://github.com/JSQLParser/JSqlParser/commit/cfa7e8986c98701) theodore johnson *2018-07-16 20:09:34* + +**support teradata sortcut for Select** + + +[53c90](https://github.com/JSQLParser/JSqlParser/commit/53c90e9988aec49) theodore johnson *2018-07-11 18:46:52* + +**fix parsing and rendering of Truncate** + + +[f126d](https://github.com/JSQLParser/JSqlParser/commit/f126d1575bc2ea5) theodore johnson *2018-07-11 17:56:14* + +**fixes #273** + + +[6cd54](https://github.com/JSQLParser/JSqlParser/commit/6cd5481af400e20) wumpz *2018-07-06 08:44:03* + +**fixes #273** + + +[12b4a](https://github.com/JSQLParser/JSqlParser/commit/12b4a1ecaa1090c) wumpz *2018-07-06 08:31:55* + +**fixes #573** + + +[3a5a6](https://github.com/JSQLParser/JSqlParser/commit/3a5a625d15d7b30) wumpz *2018-07-06 07:01:12* + +**add support for && operator** + + +[b59b4](https://github.com/JSQLParser/JSqlParser/commit/b59b48ec2e7e88a) Tomer S *2018-07-03 14:19:34* + +**Extract "orderBy" and "Partition" classes from AnalyticExpression.** + + +[8da6e](https://github.com/JSQLParser/JSqlParser/commit/8da6e2e538ceea9) Assaf *2018-06-20 06:41:56* + +**Update README.md** + + +[aff65](https://github.com/JSQLParser/JSqlParser/commit/aff651624e6fb48) Tobias *2018-06-18 06:22:15* + +**fixes #608** + + +[d529c](https://github.com/JSQLParser/JSqlParser/commit/d529c82d24cbaba) wumpz *2018-06-17 09:57:15* + +**fixes #608** + + +[3f5e3](https://github.com/JSQLParser/JSqlParser/commit/3f5e3c9805bd2fe) wumpz *2018-06-17 09:48:18* + +**fixes #163** + + +[6d954](https://github.com/JSQLParser/JSqlParser/commit/6d95472726574cc) wumpz *2018-06-17 09:39:36* + +**fixes #163** + + +[1db3f](https://github.com/JSQLParser/JSqlParser/commit/1db3ff5f9b5837b) wumpz *2018-06-17 09:33:54* + +**first try dotted** + + +[2fab8](https://github.com/JSQLParser/JSqlParser/commit/2fab86081a56673) wumpz *2018-06-16 21:07:22* + +**fixes #620** + + +[645d0](https://github.com/JSQLParser/JSqlParser/commit/645d06e0a31206b) wumpz *2018-06-08 23:22:16* + +**fixes #612** + + +[36ee6](https://github.com/JSQLParser/JSqlParser/commit/36ee6c54c21965a) wumpz *2018-06-08 22:51:12* + +**fixes #612** + + +[60473](https://github.com/JSQLParser/JSqlParser/commit/60473edf4efbd85) wumpz *2018-06-08 22:50:02* + +**Update README.md** + + +[c5a0b](https://github.com/JSQLParser/JSqlParser/commit/c5a0b02b5f5c077) Tobias *2018-05-16 06:18:32* + +**Add javadoc badge** + + +[9c2c9](https://github.com/JSQLParser/JSqlParser/commit/9c2c96772ba9b5c) Jeremy Lin *2018-05-15 20:32:26* + +**add maven-central badge (#616)** + + +[4d67d](https://github.com/JSQLParser/JSqlParser/commit/4d67d10bbf9a033) Benedikt Waldvogel *2018-05-14 09:13:39* + +**fixes #614** + + +[32c4d](https://github.com/JSQLParser/JSqlParser/commit/32c4d8a04244fd5) wumpz *2018-05-12 22:51:33* + +**** + + +[094cc](https://github.com/JSQLParser/JSqlParser/commit/094cc8082e40442) wumpz *2018-05-02 21:16:26* + +**introduced junit annotations** + + +[d7c1e](https://github.com/JSQLParser/JSqlParser/commit/d7c1e438c8f0032) wumpz *2018-05-02 21:13:11* + +**fixes #611** + + +[35cf1](https://github.com/JSQLParser/JSqlParser/commit/35cf1d8b1b80d29) wumpz *2018-05-02 21:08:22* + +**fixes #610** + + +[5a60e](https://github.com/JSQLParser/JSqlParser/commit/5a60e1b57b7de4b) wumpz *2018-05-02 20:48:08* + +**fixes #610** + + +[c5c26](https://github.com/JSQLParser/JSqlParser/commit/c5c26ca4d18092b) wumpz *2018-05-02 20:45:56* + +**Update README.md** + + +[49b28](https://github.com/JSQLParser/JSqlParser/commit/49b2800bf7533e9) Tobias *2018-05-01 21:58:41* + +**Adding support for MySQL's SQL_NO_CACHE flag** + + +[403e7](https://github.com/JSQLParser/JSqlParser/commit/403e722e6ee12b4) Tomer S *2018-03-25 09:03:23* + + +## jsqlparser-1.2 (2018-05-01) + +### Other changes + +**fixes #605** + + +[6e309](https://github.com/JSQLParser/JSqlParser/commit/6e3099c50352966) wumpz *2018-04-22 21:49:56* + +**fixes #604** + + +[c8913](https://github.com/JSQLParser/JSqlParser/commit/c89139cfecb8e8d) wumpz *2018-04-20 22:38:48* + +**moved some jjt options from pom.xml to JSqlParserCC.jjt** + + +[e9a6c](https://github.com/JSQLParser/JSqlParser/commit/e9a6cd3b79ed501) wumpz *2018-04-19 13:29:22* + +**fixes #603** + + +[32930](https://github.com/JSQLParser/JSqlParser/commit/3293023e059de4d) wumpz *2018-04-19 08:35:31* + +**fixes #600** + + +[e80ea](https://github.com/JSQLParser/JSqlParser/commit/e80ea6803591783) wumpz *2018-04-13 07:55:00* + +**change standard to jdk 8 with java 1.7 file compliance** + + +[c28a5](https://github.com/JSQLParser/JSqlParser/commit/c28a549ef9895b4) wumpz *2018-04-13 07:46:19* + +**fixes #593** + + +[65276](https://github.com/JSQLParser/JSqlParser/commit/652766264a2bb61) wumpz *2018-04-08 22:37:28* + +**fixes #597** + + +[ac34e](https://github.com/JSQLParser/JSqlParser/commit/ac34efb0279a6af) wumpz *2018-04-08 21:17:12* + +**** + + +[4f63b](https://github.com/JSQLParser/JSqlParser/commit/4f63b1c085634f2) wumpz *2018-04-02 23:42:44* + +**fixes #592** + + +[1b5d2](https://github.com/JSQLParser/JSqlParser/commit/1b5d24dcf7d6fc8) wumpz *2018-04-02 22:37:47* + +**- allow parenthesis around from item** + +* - allow whitespace between bars from concat + +[2cea3](https://github.com/JSQLParser/JSqlParser/commit/2cea3ee94d83447) wumpz *2018-03-29 22:25:48* + +**- allow parenthesis around from item** + +* - allow whitespace between bars from concat + +[dabb0](https://github.com/JSQLParser/JSqlParser/commit/dabb03f0094e4c7) wumpz *2018-03-29 22:24:33* + +**** + + +[7d366](https://github.com/JSQLParser/JSqlParser/commit/7d36615ee5b5837) wumpz *2018-03-23 07:26:30* + +**fixes #588** + + +[a04cc](https://github.com/JSQLParser/JSqlParser/commit/a04ccb1c05204e5) wumpz *2018-03-17 00:40:36* + +**fixes #588** + + +[801cd](https://github.com/JSQLParser/JSqlParser/commit/801cd84c8dbb33f) wumpz *2018-03-17 00:40:06* + +**JSQLPARSER-584: adds support for MySQL (a,b,...)OP(c,d,...) expression (#585)** + +* JSQLPARSER-584: adds support for MySQL (a,b,...)OP(c,d,...) expression +* JSQLPARSER-584: adds some tests and rename MySQLValueListExpression to ValueListExpression + +[2c272](https://github.com/JSQLParser/JSqlParser/commit/2c272f440995b2c) Adrien Lesur *2018-03-05 23:08:55* + +**checked #266** + + +[72059](https://github.com/JSQLParser/JSqlParser/commit/7205906f58be21c) wumpz *2018-02-14 08:43:51* + +**fixes #583** + + +[76ed9](https://github.com/JSQLParser/JSqlParser/commit/76ed995ebef6bd1) wumpz *2018-02-14 08:37:38* + +**fixes #583** + + +[3768b](https://github.com/JSQLParser/JSqlParser/commit/3768b8d10789c70) wumpz *2018-02-14 08:36:26* + +**tested issue 582** + + +[84459](https://github.com/JSQLParser/JSqlParser/commit/84459536a13fa4b) wumpz *2018-02-09 07:18:06* + +**Create ISSUE_TEMPLATE.md** + + +[d5ec2](https://github.com/JSQLParser/JSqlParser/commit/d5ec2fe18e8f63b) Tobias *2018-02-08 07:12:19* + +**removed unneeded dependencies** + + +[445b1](https://github.com/JSQLParser/JSqlParser/commit/445b1a517e651de) wumpz *2018-02-07 10:46:12* + +**** + + +[feaea](https://github.com/JSQLParser/JSqlParser/commit/feaeaeb2c63b88c) wumpz *2018-02-02 12:46:17* + +**** + + +[18d01](https://github.com/JSQLParser/JSqlParser/commit/18d01811c592581) wumpz *2018-02-02 12:45:51* + +**Fix issue #563: subjoin allows only one inner join, this should be a … (#564)** + +* Fix issue #563: subjoin allows only one inner join, this should be a list +* Fix failing Oracle tests because of confusion between subjoin and subselect. + +[8456a](https://github.com/JSQLParser/JSqlParser/commit/8456acf7f228a46) Frits Jalvingh *2018-02-02 10:40:01* + +**fixes #320 (#576)** + +* fixes #320 + +[e6451](https://github.com/JSQLParser/JSqlParser/commit/e645193140f4271) Taner Mansur *2018-02-01 14:55:37* + +**** + + +[21e8b](https://github.com/JSQLParser/JSqlParser/commit/21e8bc4c549ea75) wumpz *2018-02-01 14:54:12* + +**fixes #566,#438,#267** + + +[bf951](https://github.com/JSQLParser/JSqlParser/commit/bf9515418475372) wumpz *2018-01-30 14:10:17* + +**fixes #566,#438,#267** + + +[ccbe9](https://github.com/JSQLParser/JSqlParser/commit/ccbe9ad0be27d78) wumpz *2018-01-30 14:09:12* + +**tests #572** + + +[5d609](https://github.com/JSQLParser/JSqlParser/commit/5d609ef208c6803) wumpz *2018-01-29 15:43:04* + +**corrected generics type** + + +[ed1a2](https://github.com/JSQLParser/JSqlParser/commit/ed1a297094cd85c) wumpz *2018-01-22 07:34:55* + +**fixes #567** + + +[0d4ae](https://github.com/JSQLParser/JSqlParser/commit/0d4aed3aadce638) wumpz *2018-01-12 07:36:54* + +**removed "removed" project bewa** + + +[dec98](https://github.com/JSQLParser/JSqlParser/commit/dec98caa839b0d6) wumpz *2018-01-08 07:44:24* + +**fixes #338** + + +[0e571](https://github.com/JSQLParser/JSqlParser/commit/0e571d14aed151c) wumpz *2018-01-05 23:29:00* + +**fixes #545** + + +[ab7e2](https://github.com/JSQLParser/JSqlParser/commit/ab7e29bba316f0d) wumpz *2018-01-05 23:16:29* + +**fixes #462** + + +[83844](https://github.com/JSQLParser/JSqlParser/commit/838449cb5163f19) wumpz *2017-12-28 00:50:29* + +**fixes #462** + + +[bc005](https://github.com/JSQLParser/JSqlParser/commit/bc005f89fd7d091) wumpz *2017-12-28 00:47:37* + +**Update README.md** + + +[5871c](https://github.com/JSQLParser/JSqlParser/commit/5871c573f69696d) Tobias *2017-12-27 20:04:29* + +**Update README.md** + + +[dd6bb](https://github.com/JSQLParser/JSqlParser/commit/dd6bbef26420dd0) Tobias *2017-12-07 10:25:11* + +**fixes #554** + + +[4ce98](https://github.com/JSQLParser/JSqlParser/commit/4ce98e492ce9d17) wumpz *2017-12-07 08:55:52* + +**** + + +[ee723](https://github.com/JSQLParser/JSqlParser/commit/ee723d50b08a54d) wumpz *2017-12-04 08:36:46* + +**fixes #543** + + +[bdc20](https://github.com/JSQLParser/JSqlParser/commit/bdc20ea7688c8c4) wumpz *2017-12-04 08:35:07* + +**fixes #551** + + +[a25fb](https://github.com/JSQLParser/JSqlParser/commit/a25fb7cb3ba02c1) wumpz *2017-12-04 08:14:06* + +**made some modifications to rlike fix** + + +[f0ffe](https://github.com/JSQLParser/JSqlParser/commit/f0ffe4c53edbcaa) wumpz *2017-11-16 22:29:53* + +**Added support for RLIKE expressions (#544)** + +* RLIKE is a synonym of REGEXP, therefore should be treated the same. + +[8a950](https://github.com/JSQLParser/JSqlParser/commit/8a950b3e09dce06) sh-tomer *2017-11-16 22:10:51* + +**jdk 1.7** + + +[8d4f2](https://github.com/JSQLParser/JSqlParser/commit/8d4f25c49c3975d) wumpz *2017-11-07 09:43:35* + +**modern template included** + + +[9ea8e](https://github.com/JSQLParser/JSqlParser/commit/9ea8e4c3f4e3ab7) wumpz *2017-11-07 07:31:58* + +**fixes #540,#526** + + +[8bc23](https://github.com/JSQLParser/JSqlParser/commit/8bc236e25ddbe8d) wumpz *2017-11-03 07:21:40* + +**fixes #540,#526** + + +[ab868](https://github.com/JSQLParser/JSqlParser/commit/ab868a627a6b72f) wumpz *2017-11-03 07:18:39* + +**corrected a lookahead issue** + + +[a2f81](https://github.com/JSQLParser/JSqlParser/commit/a2f81f3a299145a) wumpz *2017-10-31 22:37:41* + +**Add ability to support "NOT LIKE ..." expressions (#539)** + +* The parser is able to parse expressions such as "a NOT LIKE '%pattern%'", but is not able to parse expressions where the not is before the entire expression. For example: "NOT a LIKE '%pattern%'. +* When parsing the latter, the error is: +* Caused by: net.sf.jsqlparser.parser.ParseException: Encountered " "LIKE" "LIKE "" at line 1, column 32. +* Was expecting one of: ... +* The reason this is important is both because these syntaxes are both valid, and also because the deparser uses the second method. +* Therefore, if you parse a query with the first type of expression, then deparse it and parse again, you'll get the same error. + +[daea3](https://github.com/JSQLParser/JSqlParser/commit/daea33e73aa05c6) sh-tomer *2017-10-31 20:27:50* + +**** + + +[452ba](https://github.com/JSQLParser/JSqlParser/commit/452baffb2af8c21) wumpz *2017-10-29 23:20:57* + +**** + + +[14523](https://github.com/JSQLParser/JSqlParser/commit/1452360f9cca7aa) wumpz *2017-10-29 23:08:39* + +**** + + +[7c90a](https://github.com/JSQLParser/JSqlParser/commit/7c90a24bdf72994) wumpz *2017-10-29 22:59:21* + +**Linking structures to their AST nodes to have access to their positions (#534)** + +* Linking several structures to their AST nodes to have access to their positions +* This far there were only 3 types of structures linked to their AST nodes. Now adding some more expressions and literals to their AST node to have access to their token's position in the query. +* Added missing parts in JSQqlParserCC.jjt for AST linking to work +* Added missing parts in JSQqlParserCC.jjt to make sure all relevant code is created to generate and link AST nodes to the relevant structures. + +[514f2](https://github.com/JSQLParser/JSqlParser/commit/514f2588af97345) sh-tomer *2017-10-29 12:39:56* + +**add debug note (#531)** + +* added a link to the visualize parsing section to have a visible debug mode (so users that create an issue can try to get us better output) + +[b1abc](https://github.com/JSQLParser/JSqlParser/commit/b1abc6ff39e9c2a) Jan Monterrubio *2017-10-25 06:21:26* + +**fixes #525 (#530)** + +* fixes #525 +* Simply unit test. + +[1a1a1](https://github.com/JSQLParser/JSqlParser/commit/1a1a1aa53866787) Linyu Chen *2017-10-24 05:30:39* + +**simplified tests for SQL_CALC_FOUND_ROWS** + + +[e23d4](https://github.com/JSQLParser/JSqlParser/commit/e23d4bc09e5f6e4) wumpz *2017-10-20 07:32:58* + +**Implements #509 (#504)** + +* Supporting MySql hit SQL_CALC_FOUND_ROWS for selecting row count. +* Supporting MySql hit SQL_CALC_FOUND_ROWS for selecting row count. - refactoring +* Supporting MySql hit SQL_CALC_FOUND_ROWS for selecting row count. - missing copyright.ˆ +* Supporting MySql hit SQL_CALC_FOUND_ROWS for selecting row count. - Modify field type to boolean for prevent memory consumption by creating object and try assertSqlCanBeParsedAndDeparsed on unit test. + +[3e163](https://github.com/JSQLParser/JSqlParser/commit/3e16345815e45b5) Yoon Kyong Sik *2017-10-20 07:27:48* + +**fixes #522** + + +[45ac8](https://github.com/JSQLParser/JSqlParser/commit/45ac8c8a2bcff54) wumpz *2017-10-12 21:27:57* + +**fixes #522** + + +[2c69c](https://github.com/JSQLParser/JSqlParser/commit/2c69cc65f8bfd32) wumpz *2017-10-12 21:22:26* + +**fixes #510** + + +[f64ad](https://github.com/JSQLParser/JSqlParser/commit/f64ad89eec4ea53) wumpz *2017-10-09 23:51:46* + +**** + + +[1a771](https://github.com/JSQLParser/JSqlParser/commit/1a77106df128893) wumpz *2017-10-06 08:58:01* + +**fixes #508 including precedence** + + +[8037a](https://github.com/JSQLParser/JSqlParser/commit/8037af621f32f0a) wumpz *2017-10-06 08:36:57* + +**fixes #519** + +* fixes #520 + +[27217](https://github.com/JSQLParser/JSqlParser/commit/272177a37b9ee81) wumpz *2017-10-06 08:24:04* + +**transformed primary expression and sign parsing** + + +[51fcd](https://github.com/JSQLParser/JSqlParser/commit/51fcdea9f92c1ce) wumpz *2017-10-06 07:11:58* + +**corrected token definition order** + + +[64ce9](https://github.com/JSQLParser/JSqlParser/commit/64ce9ff2986d492) wumpz *2017-10-06 07:01:35* + +**waiting for https://github.com/javacc/javacc/issues/28** + + +[704e6](https://github.com/JSQLParser/JSqlParser/commit/704e6c84fb66150) wumpz *2017-10-02 09:14:01* + +**Fix test case** + + +[b2bb2](https://github.com/JSQLParser/JSqlParser/commit/b2bb2431c4dfae0) Nathaniel Camomot *2017-09-27 08:10:08* + +**Fix for some cases where TablNamesFinder can't find tables** + + +[395c3](https://github.com/JSQLParser/JSqlParser/commit/395c3b0049cd09f) Nathaniel Camomot *2017-09-27 06:21:21* + +**removed oraclejdk7 travis build due to https://github.com/travis-ci/travis-ci/issues/7964** + + +[812f9](https://github.com/JSQLParser/JSqlParser/commit/812f98fff951c4e) wumpz *2017-09-24 09:55:31* + +**** + + +[96b5d](https://github.com/JSQLParser/JSqlParser/commit/96b5d9f26ec7310) wumpz *2017-09-24 09:48:35* + +**** + + +[b847e](https://github.com/JSQLParser/JSqlParser/commit/b847e85c0dba19f) wumpz *2017-09-23 22:40:30* + +**Create LICENSE_LGPLV21** + + +[d2c87](https://github.com/JSQLParser/JSqlParser/commit/d2c87dac67436af) Tobias *2017-09-23 22:29:45* + +**Create LICENSE_APACHEV2** + + +[f9c1a](https://github.com/JSQLParser/JSqlParser/commit/f9c1a9f7fb91703) Tobias *2017-09-23 22:29:09* + +**fixes #515** + + +[c4b36](https://github.com/JSQLParser/JSqlParser/commit/c4b360e14a06201) wumpz *2017-09-23 22:20:51* + +**fixes #515** + + +[1afe7](https://github.com/JSQLParser/JSqlParser/commit/1afe7e6a9931f7e) wumpz *2017-09-23 22:18:35* + +**fixes #515** + + +[8388f](https://github.com/JSQLParser/JSqlParser/commit/8388f1e48355b4f) wumpz *2017-09-23 22:17:04* + +**Update README.md** + + +[3f734](https://github.com/JSQLParser/JSqlParser/commit/3f734f130da0a66) Tobias *2017-09-23 21:38:51* + +**fixes #514** + + +[8a459](https://github.com/JSQLParser/JSqlParser/commit/8a459ce9894ec36) wumpz *2017-09-23 21:32:10* + +**fixes #514** + + +[3e846](https://github.com/JSQLParser/JSqlParser/commit/3e84605a7a87948) wumpz *2017-09-23 21:29:52* + +**merge of within_group and analytic** + + +[26fab](https://github.com/JSQLParser/JSqlParser/commit/26faba8040636e8) wumpz *2017-09-23 21:24:18* + +**** + + +[c5a47](https://github.com/JSQLParser/JSqlParser/commit/c5a471f926c1d85) wumpz *2017-09-22 12:29:44* + +**#fixes 480** + + +[10352](https://github.com/JSQLParser/JSqlParser/commit/10352328d3d52f3) wumpz *2017-09-12 21:59:08* + +**#fixes 480** + + +[e60fa](https://github.com/JSQLParser/JSqlParser/commit/e60fa8cd305d154) wumpz *2017-09-12 21:58:39* + +**fixes #512** + + +[07a14](https://github.com/JSQLParser/JSqlParser/commit/07a14dc892d6003) wumpz *2017-09-07 22:20:01* + +**fixes #505** + + +[ef55f](https://github.com/JSQLParser/JSqlParser/commit/ef55ffba8b596aa) wumpz *2017-08-28 08:13:14* + +**fixes #502** + + +[6a440](https://github.com/JSQLParser/JSqlParser/commit/6a440ba583955b1) wumpz *2017-08-26 14:18:07* + +**fixes #502** + + +[41ea8](https://github.com/JSQLParser/JSqlParser/commit/41ea83d2757adee) wumpz *2017-08-26 14:14:13* + +**fixes #484** + + +[1a6f9](https://github.com/JSQLParser/JSqlParser/commit/1a6f9143ef491dd) wumpz *2017-08-23 20:41:06* + +**fixes #484** + + +[8f9b6](https://github.com/JSQLParser/JSqlParser/commit/8f9b62705ae094e) wumpz *2017-08-23 20:40:26* + +**replace support multiple values** + + +[93598](https://github.com/JSQLParser/JSqlParser/commit/93598bbe86aaa92) wanghai *2017-08-21 09:15:27* + +**fixed #491** + + +[147ec](https://github.com/JSQLParser/JSqlParser/commit/147ec4887639700) wumpz *2017-08-16 15:47:01* + +**fixed #491** + + +[24f23](https://github.com/JSQLParser/JSqlParser/commit/24f232c08edb86c) wumpz *2017-08-16 15:45:55* + +**checked issue #482** + + +[71692](https://github.com/JSQLParser/JSqlParser/commit/71692c5c6f85f0f) wumpz *2017-08-07 13:33:12* + +**fixes #485** + + +[64bc5](https://github.com/JSQLParser/JSqlParser/commit/64bc5e05d8086b4) wumpz *2017-08-03 05:57:10* + +**fix issue #424 (INSERT with SET) (#481)** + +* update insert with set language +* update insert with set +* update insert with set +* update insert test +* add removed lines + +[ca653](https://github.com/JSQLParser/JSqlParser/commit/ca6538a04dd7969) messfish *2017-07-28 06:23:33* + +**fixes #456** + + +[9c2cc](https://github.com/JSQLParser/JSqlParser/commit/9c2cc2c823b3d1e) wumpz *2017-07-27 11:14:26* + +**introduced partial / nonpartial parse for CCJSqlParserUtil methods** + + +[6b452](https://github.com/JSQLParser/JSqlParser/commit/6b452183f084652) wumpz *2017-07-27 05:47:13* + +**fixes #473** + + +[0aa22](https://github.com/JSQLParser/JSqlParser/commit/0aa229d3df996f6) wumpz *2017-07-18 06:24:20* + +**Update README.md** + + +[58c42](https://github.com/JSQLParser/JSqlParser/commit/58c42bcfbf717ee) Tobias *2017-06-29 21:37:30* + +**Update README.md** + + +[d235c](https://github.com/JSQLParser/JSqlParser/commit/d235ca3971a9a6e) Tobias *2017-06-29 21:34:47* + + +## jsqlparser-1.1 (2017-06-29) + +### Other changes + +**fixes #468** + + +[6cb45](https://github.com/JSQLParser/JSqlParser/commit/6cb459d747901ea) wumpz *2017-06-28 08:50:50* + +**** + + +[fb64e](https://github.com/JSQLParser/JSqlParser/commit/fb64e3295e91bca) wumpz *2017-06-11 21:50:53* + +**Add Upsert Grammer (#460)** + +* Add files via upload +* Add files via upload +* Add files via upload +* Add files via upload +* Add files via upload +* Add test for de parser +* Add files via upload +* Add files via upload +* Add files via upload +* Add files via upload +* Add files via upload +* Add files via upload +* Add files via upload +* Add files via upload +* Add files via upload + +[aaeb8](https://github.com/JSQLParser/JSqlParser/commit/aaeb8dfeb0c2a4e) messfish *2017-06-11 18:48:53* + +**introduced linking between Function and ASTNode** + + +[3e75c](https://github.com/JSQLParser/JSqlParser/commit/3e75c68c4bf769e) wumpz *2017-06-09 22:34:23* + +**introduced linking between Function and ASTNode** + + +[e96f4](https://github.com/JSQLParser/JSqlParser/commit/e96f48534ca3103) wumpz *2017-06-09 22:32:16* + +**fixes #457** + + +[2ae5e](https://github.com/JSQLParser/JSqlParser/commit/2ae5e76d69b1cbf) wumpz *2017-05-26 21:34:35* + +**** + + +[e4ef6](https://github.com/JSQLParser/JSqlParser/commit/e4ef6e231282b62) wumpz *2017-05-23 07:32:52* + +**Fix issue #442 (#451)** + +* Fix issue #442 for delete statements +* Fix issue #442 for insert statements +* Mock only when necessary +* E.g., interfaces, behavior needs to be verified, etc. +* Prefer the first style of testing +* As discussed in issue #442 +* Fix issue #442 for replace statements +* Improve readability of issue #442 tests +* Inject SelectDeParser as well +* As discussed in issue #442. +* Fix issue #442 for select statements +* Fix issue #442 for update statements +* Fix issue #442 for execute statements +* Fix issue #442 for set statements +* Fix PR code review issue +* https://www.codacy.com/app/wumpz/JSqlParser/file/6682733346/issues/source?bid=4162857&fileBranchId=4580866#l48 +* Skip PMD check for asserts in tests using Mockito +* As agreed upon in the discussion in PR #451. +* Use correct PMD check name + +[9d680](https://github.com/JSQLParser/JSqlParser/commit/9d680a6ec4b9f07) chrycheng *2017-05-22 07:13:41* + +**fixes #430** + + +[585cb](https://github.com/JSQLParser/JSqlParser/commit/585cbbd1377632b) wumpz *2017-05-16 22:04:19* + +**Fix issue #446 (#447)** + +* Test current behavior of ExecuteDeParser +* Fix issue #446 + +[275fb](https://github.com/JSQLParser/JSqlParser/commit/275fbbe87fa0ada) chrycheng *2017-05-16 20:46:29* + +**fixes #449** + + +[fe6da](https://github.com/JSQLParser/JSqlParser/commit/fe6dafea19fa236) wumpz *2017-05-16 14:12:50* + +**introduced test for 437** + + +[3e740](https://github.com/JSQLParser/JSqlParser/commit/3e740100498aa22) wumpz *2017-05-12 19:43:14* + +**test issue 445** + + +[fce59](https://github.com/JSQLParser/JSqlParser/commit/fce593dcf85c43e) wumpz *2017-05-11 08:37:49* + +**** + + +[1fbf6](https://github.com/JSQLParser/JSqlParser/commit/1fbf6c5bde81b41) wumpz *2017-05-08 12:32:25* + +**updated readme** + + +[1dabc](https://github.com/JSQLParser/JSqlParser/commit/1dabcbc56f9b158) wumpz *2017-05-07 20:37:31* + +**some minor changes** + + +[050b8](https://github.com/JSQLParser/JSqlParser/commit/050b8ba6434630d) wumpz *2017-05-07 20:35:15* + +**conversion to CNF (#434)** + +* Add files via upload +* Create foo +* All the files needed for the CNF conversion +* Delete foo +* Create foo +* Test cases for the CNF conversion +* Delete foo +* Add files via upload +* Add files via upload +* change some public methods to private +* Delete CNFConverter.java +* Delete CloneHelper.java +* Delete MultiAndExpression.java +* Delete MultiOrExpression.java +* Delete MultipleExpression.java +* Create foo +* Add files via upload +* Delete CNFTest.java +* Delete StepLastHelper.java +* Create foo +* Add files via upload +* Delete foo +* Delete foo +* Add files via upload +* Add files via upload +* Delete CNFConverter.java +* Delete CloneHelper.java +* Delete MultiAndExpression.java +* Delete MultiOrExpression.java +* Delete MultipleExpression.java +* Create foo +* Add files via upload +* Delete foo +* Delete CNFTest.java +* Create foo +* Add files via upload +* Delete foo +* Add files via upload +* Add files via upload + +[afe10](https://github.com/JSQLParser/JSqlParser/commit/afe1011bdd64696) messfish *2017-05-07 20:21:00* + +**** + + +[56497](https://github.com/JSQLParser/JSqlParser/commit/56497af552c53a4) wumpz *2017-05-02 06:06:33* + +**corrected bug within RelObjectNameExt processing** + + +[7b2b0](https://github.com/JSQLParser/JSqlParser/commit/7b2b0f649b1702a) wumpz *2017-05-02 06:00:44* + +**Update README.md** + + +[2c0f2](https://github.com/JSQLParser/JSqlParser/commit/2c0f2ff0f6c7814) Tobias *2017-04-28 07:37:09* + +**Update README.md** + + +[80c98](https://github.com/JSQLParser/JSqlParser/commit/80c98055bc969a0) Tobias *2017-04-28 07:35:42* + +**** + + +[59310](https://github.com/JSQLParser/JSqlParser/commit/5931045d807559e) wumpz *2017-04-24 13:25:21* + +**Introduce support for mysql index hints (fixing issue #374) (#429)** + +* Introduce support for mysql index hints (fixing issue #374) +* Fix checkstyle errors +* -Converted indent tabs to spaces +* -Added missing {} on single-line if statement + +[6db15](https://github.com/JSQLParser/JSqlParser/commit/6db15d2c6218d06) Joey Mart *2017-04-18 06:22:25* + +**#425 ADD CONSTRAINT also support state such as DEFERRABLE, VALIDATE... (#426)** + + +[f1113](https://github.com/JSQLParser/JSqlParser/commit/f11133c0bdd7a6b) Christophe Moine *2017-04-17 23:40:45* + +**Addressing #427 (#428)** + +* updating readme with Maven requirements +* removing ticks + +[0fddc](https://github.com/JSQLParser/JSqlParser/commit/0fddc73e2eee1b2) AnEmortalKid *2017-04-17 23:39:05* + +**going back to checkstyle 6.x due to java7 incompatibilities** + + +[564ac](https://github.com/JSQLParser/JSqlParser/commit/564acc288fa0294) wumpz *2017-04-17 23:27:10* + +**Update README.md** + + +[30b09](https://github.com/JSQLParser/JSqlParser/commit/30b0924742068f0) Tobias *2017-04-17 23:09:06* + +**Update README.md** + + +[2b5c8](https://github.com/JSQLParser/JSqlParser/commit/2b5c84552963ec3) Tobias *2017-04-17 23:05:07* + +**checkstyle source check included. configuration done** + + +[12377](https://github.com/JSQLParser/JSqlParser/commit/12377c784a3fa53) wumpz *2017-04-17 23:01:42* + +**checkstyle source check included. configuration done** + + +[1bdf5](https://github.com/JSQLParser/JSqlParser/commit/1bdf5b9515b5af3) wumpz *2017-04-17 22:57:12* + +**improved StatementVistorAdaptor to process all statements.** + + +[27119](https://github.com/JSQLParser/JSqlParser/commit/2711900eb3ebf83) wumpz *2017-04-11 07:47:22* + +**removed linefeed check, due to multiple git checkout configurations regarding linefeeds** + + +[aab56](https://github.com/JSQLParser/JSqlParser/commit/aab569bf4c6376f) wumpz *2017-03-31 08:04:24* + +**** + + +[2f5a1](https://github.com/JSQLParser/JSqlParser/commit/2f5a1eacf3e9f5a) wumpz *2017-03-29 06:07:20* + +**corrected source files regarding checkstyle errors** + + +[0d6fa](https://github.com/JSQLParser/JSqlParser/commit/0d6faeb8b411e53) wumpz *2017-03-28 09:46:55* + +**introduced some more checkstyle rules** + + +[c7a86](https://github.com/JSQLParser/JSqlParser/commit/c7a8601b84695e4) wumpz *2017-03-28 09:30:00* + +**removed problematic profile "check.sources" activation, excluded generated-sources, included test-sources** + + +[e2cc2](https://github.com/JSQLParser/JSqlParser/commit/e2cc2210c364f6c) wumpz *2017-03-27 11:48:50* + +**removed problematic profile "check.sources" activation, excluded generated-sources, included test-sources** + + +[e941f](https://github.com/JSQLParser/JSqlParser/commit/e941fd96a2caade) wumpz *2017-03-27 11:45:39* + +**removed problematic profile "check.sources" activation, excluded generated-sources, included test-sources** + + +[dd23f](https://github.com/JSQLParser/JSqlParser/commit/dd23f27516db63b) wumpz *2017-03-27 11:14:44* + +**removed auto activation due to travis problems, included test sources** + + +[759e7](https://github.com/JSQLParser/JSqlParser/commit/759e751b85c5a16) wumpz *2017-03-27 10:53:46* + +**checkstyle** + + +[62505](https://github.com/JSQLParser/JSqlParser/commit/625054295a7700b) wumpz *2017-03-27 09:16:11* + +**Update README.md** + + +[da9ac](https://github.com/JSQLParser/JSqlParser/commit/da9acf59e308d2b) Tobias *2017-03-25 22:21:59* + + +## jsqlparser-1.0 (2017-03-25) + +### Other changes + +**** + + +[32e8f](https://github.com/JSQLParser/JSqlParser/commit/32e8fa02ecfadc4) wumpz *2017-03-25 22:00:13* + +**** + + +[a31b2](https://github.com/JSQLParser/JSqlParser/commit/a31b219baadb001) wumpz *2017-03-25 21:52:19* + +**** + + +[f731f](https://github.com/JSQLParser/JSqlParser/commit/f731fa4cf726036) wumpz *2017-03-25 21:47:42* + +**reformating hole sourcecode** + + +[4146f](https://github.com/JSQLParser/JSqlParser/commit/4146f869cb01151) wumpz *2017-03-22 07:36:17* + +**Fix #407 by enhancing grammar (#410)** + +* Fix #407 by enhancing grammar +* Change LF and tabs + +[5d901](https://github.com/JSQLParser/JSqlParser/commit/5d9018657df6b22) Christophe Moine *2017-03-22 07:36:14* + +**removed dependencies** + + +[dd1b3](https://github.com/JSQLParser/JSqlParser/commit/dd1b334e3bc4675) wumpz *2017-03-20 10:22:55* + +**fixes #406** + + +[06619](https://github.com/JSQLParser/JSqlParser/commit/066199cfeb97ea4) wumpz *2017-03-17 11:55:11* + +**update to JavaCC 7.0.2** + + +[c12f7](https://github.com/JSQLParser/JSqlParser/commit/c12f7ac457d92c3) wumpz *2017-03-15 10:28:17* + +**Update README.md** + + +[6312f](https://github.com/JSQLParser/JSqlParser/commit/6312f3aaf9aa46e) Tobias *2017-03-15 08:55:03* + +**update readme** + + +[03746](https://github.com/JSQLParser/JSqlParser/commit/03746a8ddf0c14e) wumpz *2017-03-15 08:45:24* + +**update readme** + + +[5bbfe](https://github.com/JSQLParser/JSqlParser/commit/5bbfeb76bf7deab) wumpz *2017-03-15 08:44:22* + +**** + + +[6e72b](https://github.com/JSQLParser/JSqlParser/commit/6e72b99ee4b0ba0) wumpz *2017-03-14 11:41:26* + +**corrected merge conflict** + + +[1211d](https://github.com/JSQLParser/JSqlParser/commit/1211dcf1209f3a4) wumpz *2017-03-14 11:39:30* + +**corrected case when expressions** + + +[12cc4](https://github.com/JSQLParser/JSqlParser/commit/12cc4059ddef291) wumpz *2017-03-14 11:12:53* + +**rewrote some lookaheads** + + +[2a440](https://github.com/JSQLParser/JSqlParser/commit/2a4405a6a0821cc) wumpz *2017-03-14 10:33:21* + +**replace some junit pre 4.x artifacts** + + +[7dd85](https://github.com/JSQLParser/JSqlParser/commit/7dd857e5000f09a) wumpz *2017-03-14 09:55:42* + +**first rewrite of SelectBody** + + +[49127](https://github.com/JSQLParser/JSqlParser/commit/49127be715d029a) wumpz *2017-03-14 09:43:25* + +**** + + +[5dcef](https://github.com/JSQLParser/JSqlParser/commit/5dcefcefd07755a) wumpz *2017-03-10 22:13:02* + +**Support FOR UPDATE WAIT (#405)** + +* Adding FOR UPDATE WAIT support +* removing final peppered everywhere +* updating formatting, fixing codacy test names +* updating asserts to use static import +* reverting changes +* reverting line feeds +* adding tests and deparser code back without formatting + +[45b39](https://github.com/JSQLParser/JSqlParser/commit/45b392f4b93714c) AnEmortalKid *2017-03-10 22:06:53* + +**add support for LIMIT with only one row count JDBC parameter (#404)** + +* small but powerfull change 👍 + +[42318](https://github.com/JSQLParser/JSqlParser/commit/42318531bb72279) zhushaoping *2017-03-03 07:06:08* + +**merged** + + +[c3eed](https://github.com/JSQLParser/JSqlParser/commit/c3eed13096c0019) wumpz *2017-03-03 07:03:08* + +**fixes #401** + + +[1315d](https://github.com/JSQLParser/JSqlParser/commit/1315d035dbc5008) wumpz *2017-03-01 08:20:55* + +**fixes #402** + + +[6fb15](https://github.com/JSQLParser/JSqlParser/commit/6fb15a104debe95) wumpz *2017-03-01 07:55:25* + +**release 0.9.7** + + +[46720](https://github.com/JSQLParser/JSqlParser/commit/46720ef029cf8aa) wumpz *2017-02-26 23:13:50* + + +## jsqlparser-0.9.7 (2017-02-26) + +### Other changes + +**updated readme** + + +[e2dc3](https://github.com/JSQLParser/JSqlParser/commit/e2dc36897178155) wumpz *2017-02-21 08:49:56* + +**commented an issue test** + + +[4fe4c](https://github.com/JSQLParser/JSqlParser/commit/4fe4ce206296ea1) wumpz *2017-02-21 08:46:38* + +**set statemet with optional equals** + + +[ec6ce](https://github.com/JSQLParser/JSqlParser/commit/ec6cef2e803d87a) wumpz *2017-02-11 23:57:32* + +**fixes #393** + + +[320f6](https://github.com/JSQLParser/JSqlParser/commit/320f64a9a4aa687) wumpz *2017-02-10 09:34:47* + +**** + + +[42f32](https://github.com/JSQLParser/JSqlParser/commit/42f3242cc13fac6) wumpz *2017-02-08 08:17:40* + +**removed unused imports** + + +[c66cc](https://github.com/JSQLParser/JSqlParser/commit/c66cc6973753c3a) wumpz *2017-02-08 08:15:51* + +**minor code improvements** + + +[e3fd2](https://github.com/JSQLParser/JSqlParser/commit/e3fd2c6df3444ae) wumpz *2017-02-08 08:13:58* + +**Update README.md** + + +[3d05e](https://github.com/JSQLParser/JSqlParser/commit/3d05e16c6c09a05) Tobias *2017-02-07 18:09:26* + +**fixes #390** + + +[546b7](https://github.com/JSQLParser/JSqlParser/commit/546b71d84eb8b45) wumpz *2017-02-01 15:27:48* + +**** + + +[d4396](https://github.com/JSQLParser/JSqlParser/commit/d439643bbf1cd02) wumpz *2017-01-27 20:53:20* + +**fixes #389** + + +[71c32](https://github.com/JSQLParser/JSqlParser/commit/71c32d905fbd4cb) wumpz *2017-01-27 20:39:25* + +**included LOOKAHEAD** + + +[6776e](https://github.com/JSQLParser/JSqlParser/commit/6776eb5fd0224e4) wumpz *2017-01-20 23:12:17* + +**updated readme** + + +[b5f6e](https://github.com/JSQLParser/JSqlParser/commit/b5f6e9efac23dca) wumpz *2017-01-20 22:10:59* + +**updated readme** + + +[1abd2](https://github.com/JSQLParser/JSqlParser/commit/1abd224a3e2ff0f) wumpz *2017-01-20 22:00:07* + +**Increase test coverage on AlterExpression.java** + +* getOperation +* getFkColumns +* getFkSourceTable +* getFkSourceColumns +* getConstraintName +* tried getPkColumns but it does not behave as I expected. +* placed TODO in AlterTest.testAlterTablePK for this +* getIndex().getColumnNames + +[5a799](https://github.com/JSQLParser/JSqlParser/commit/5a79964714b13f7) jthomas *2017-01-19 19:43:24* + +**Enhance AlterExpression grammar:** + +* 1. optional "COLUMN" keyword in ADD alter operation +* 2. new alter operation: MODIFY +* 3. add column specs to alter table column definitions + +[24177](https://github.com/JSQLParser/JSqlParser/commit/241779b26973b47) jthomas *2017-01-19 17:32:21* + +**support to add jdbc name parameter after LIMIT and TOP keywords** + + +[e25e2](https://github.com/JSQLParser/JSqlParser/commit/e25e247dd5e9131) zhushaoping *2017-01-13 02:55:52* + +**fixes #288** + + +[091c5](https://github.com/JSQLParser/JSqlParser/commit/091c5dd5ab5ce93) zhushaoping *2017-01-12 07:09:57* + +**tests for issue 379 included** + + +[f7c27](https://github.com/JSQLParser/JSqlParser/commit/f7c27ad6492a636) wumpz *2017-01-04 07:22:19* + +**tests for issue 379 included** + + +[14a9b](https://github.com/JSQLParser/JSqlParser/commit/14a9b3e372b664a) wumpz *2017-01-04 06:49:43* + +**updated readme** + + +[1899c](https://github.com/JSQLParser/JSqlParser/commit/1899cbffb915992) wumpz *2017-01-02 13:32:56* + +**fixes #375** + +* fixes #371 + +[957f3](https://github.com/JSQLParser/JSqlParser/commit/957f39c496a7fac) wumpz *2017-01-02 13:30:09* + +**fixed NPE in ExpressionVisitorAdapter when SubSelect doesn't has withItemsList** + + +[28979](https://github.com/JSQLParser/JSqlParser/commit/2897935037560db) Donghang Lin *2016-12-21 07:14:48* + +**** + + +[5bc1f](https://github.com/JSQLParser/JSqlParser/commit/5bc1fc3669d52f0) wumpz *2016-12-06 22:08:00* + +**fixed #363** + + +[66e44](https://github.com/JSQLParser/JSqlParser/commit/66e44c956be7481) wumpz *2016-12-01 06:52:45* + +**integrated some tests** + + +[5937b](https://github.com/JSQLParser/JSqlParser/commit/5937bace81bd20c) wumpz *2016-11-14 11:47:43* + +**corrected fix #311 and fix #332, introduced unaliased fqn of column** + + +[88804](https://github.com/JSQLParser/JSqlParser/commit/888041d1971257e) wumpz *2016-09-26 12:33:24* + +**fixes #341** + + +[b3faf](https://github.com/JSQLParser/JSqlParser/commit/b3faf8eb8680484) wumpz *2016-09-20 21:53:32* + +**Update README.md** + + +[98ded](https://github.com/JSQLParser/JSqlParser/commit/98ded4dfd487b7e) Tobias *2016-09-17 14:34:21* + +**corrected some lookaheads** + + +[7c157](https://github.com/JSQLParser/JSqlParser/commit/7c1572febc89ae1) wumpz *2016-09-16 11:52:08* + +**Updated header and removed unused methods.** + + +[2bfc9](https://github.com/JSQLParser/JSqlParser/commit/2bfc9ab124086b9) Peter Borissow *2016-09-15 15:28:59* + +**Added json parsing tests.** + + +[7c740](https://github.com/JSQLParser/JSqlParser/commit/7c740854852d725) Peter Borissow *2016-09-15 14:59:01* + +**Added support for PostgreSQL JSON Functions and Operators.** + + +[a5504](https://github.com/JSQLParser/JSqlParser/commit/a5504819c1d93f0) Peter Borissow *2016-09-14 02:28:01* + +**Add support for more Postgres Create Table options** + + +[04c56](https://github.com/JSQLParser/JSqlParser/commit/04c56f283d24b44) Rob Story *2016-09-09 21:02:57* + +**fixes #334** + + +[21a0d](https://github.com/JSQLParser/JSqlParser/commit/21a0df961b4dc70) wumpz *2016-09-01 07:45:04* + +**** + + +[8e229](https://github.com/JSQLParser/JSqlParser/commit/8e22953b3bdcf85) wumpz *2016-09-01 06:50:59* + +**** + + +[e6e7e](https://github.com/JSQLParser/JSqlParser/commit/e6e7ea7bd407e30) wumpz *2016-09-01 06:46:49* + +**Support additional Postgres column types for alter table statements** + + +[42181](https://github.com/JSQLParser/JSqlParser/commit/42181b00cace324) Rob Story *2016-08-30 14:22:55* + +**fixes #330** + + +[03a34](https://github.com/JSQLParser/JSqlParser/commit/03a344d221abc9b) wumpz *2016-08-29 07:13:00* + +**fixes #329** + + +[3df49](https://github.com/JSQLParser/JSqlParser/commit/3df492bb5cadaee) wumpz *2016-08-28 21:06:08* + +**updated readme** + + +[2acae](https://github.com/JSQLParser/JSqlParser/commit/2acaee03959f798) wumpz *2016-08-23 20:02:35* + + +## jsqlparser-0.9.6 (2016-08-23) + +### Other changes + +**#modify net.sf.jsqlparser.statement.insert.Insert Method:toString() if itemsList and useSelectBrackets together not null will error** + +* #modify PlainSelect.getStringList change sql append to StringBuilder + +[471b9](https://github.com/JSQLParser/JSqlParser/commit/471b94495623ee2) zheng.liu@baifendian.com *2016-08-15 06:22:23* + +**corrected some lookaheads parsing delete statements** + + +[57890](https://github.com/JSQLParser/JSqlParser/commit/578909f24136b04) wumpz *2016-08-14 12:59:27* + +**some cleanup** + + +[d34eb](https://github.com/JSQLParser/JSqlParser/commit/d34ebcab6ac939f) wumpz *2016-08-13 22:20:27* + +**Update Alter and add AlterExpression class for multiple ADD/DROP expressions in a single ALTER statement** + +* Update .jjt file to break out the AlterExpression into its own class and for Alter to compose multiple AlterExpressions +* Update AlterTest for new AlterExpressions and test for multiple ADD/DROP statements in a single ALTER + +[e8d1c](https://github.com/JSQLParser/JSqlParser/commit/e8d1cf2cb1db16c) Rob Story *2016-08-11 19:24:41* + +**Support for parse delete from table using join to another table like:** + +* DELETE posts +* FROM posts +* INNER JOIN projects ON projects.project_id = posts.project_id +* WHERE projects.client_id = :client_id +* This necessitated some changes to the DeleteTest class, +* specifically: +* JSqlParserCC.jjt - changes on grammar of Delete statements. +* Delete toString and DeleteDeParser. + +[b6eb5](https://github.com/JSQLParser/JSqlParser/commit/b6eb57b61f7b205) Lucas Oliveira *2016-08-06 16:28:11* + +**fix bug of TablesNamesFinder when SubSlect has withItemsList, add corresponding test case** + + +[276dd](https://github.com/JSQLParser/JSqlParser/commit/276ddc8a4dd8bf7) Xin Quan *2016-08-04 01:44:08* + +**fixes #309** + + +[37f06](https://github.com/JSQLParser/JSqlParser/commit/37f061014e21f01) wumpz *2016-08-03 22:02:45* + +**fixes #309** + + +[acd16](https://github.com/JSQLParser/JSqlParser/commit/acd16e59b8d8378) wumpz *2016-08-03 22:02:04* + +**fixes #303** + + +[043a5](https://github.com/JSQLParser/JSqlParser/commit/043a5cb59727cda) wumpz *2016-08-03 21:31:11* + +**fixes #303** + + +[76982](https://github.com/JSQLParser/JSqlParser/commit/76982f7b00b54f7) wumpz *2016-08-03 21:30:04* + +**intruced new test for oracle join syntax** + + +[cb8dd](https://github.com/JSQLParser/JSqlParser/commit/cb8ddd71254a640) wumpz *2016-08-03 21:05:38* + +**fixes #246** + + +[822bb](https://github.com/JSQLParser/JSqlParser/commit/822bbbe78cc8481) wumpz *2016-07-31 20:56:56* + +**fixes #247** + + +[42636](https://github.com/JSQLParser/JSqlParser/commit/4263651d43d4c60) wumpz *2016-07-28 20:13:41* + +**test for issue 265** + + +[59f7e](https://github.com/JSQLParser/JSqlParser/commit/59f7ec2a2a432de) wumpz *2016-07-24 22:28:08* + +**fixes #292** + + +[f0b35](https://github.com/JSQLParser/JSqlParser/commit/f0b350d13756b1f) wumpz *2016-07-24 22:13:37* + +**fixes #299** + + +[d2ad3](https://github.com/JSQLParser/JSqlParser/commit/d2ad3dfe936c8ce) wumpz *2016-07-24 22:05:14* + +**fixes #311** + + +[dfd2f](https://github.com/JSQLParser/JSqlParser/commit/dfd2fe55f0ad2bb) wumpz *2016-07-22 07:25:01* + +**** + + +[84bf0](https://github.com/JSQLParser/JSqlParser/commit/84bf0650e8f7d55) wumpz *2016-07-21 14:08:19* + +**first try of error recovery for statement and statements** + + +[a7247](https://github.com/JSQLParser/JSqlParser/commit/a7247eb48369472) wumpz *2016-07-21 07:33:49* + +**some refactoring** + + +[1e307](https://github.com/JSQLParser/JSqlParser/commit/1e30760dce107d9) wumpz *2016-07-18 16:50:28* + +**The previous pull request broke the build. Besides being a keyword, 'double' is also a function name. Add K_DOUBLE to the RelObjectNameExt() function to pick up this distinction.** + + +[8bfc1](https://github.com/JSQLParser/JSqlParser/commit/8bfc1583f12049c) Tom Moore *2016-07-11 19:14:06* + +**Add a double precision cast type** + + +[60ad1](https://github.com/JSQLParser/JSqlParser/commit/60ad18ed1a10328) Tom Moore *2016-07-11 17:59:53* + +**removed one lookahead and improved parenthesis parsing** + + +[84a88](https://github.com/JSQLParser/JSqlParser/commit/84a883614af908a) wumpz *2016-06-30 18:41:06* + +**removed one lookahead and improved parenthesis parsing** + + +[51b39](https://github.com/JSQLParser/JSqlParser/commit/51b39c55aaaa58c) wumpz *2016-06-30 18:37:23* + +**fixes #296** + +* refactored getTableList method of TableNamesFinder + +[3ccca](https://github.com/JSQLParser/JSqlParser/commit/3ccca01bbc85778) wumpz *2016-06-28 12:16:39* + +**fixes #295** + + +[b877d](https://github.com/JSQLParser/JSqlParser/commit/b877da0a425c01f) wumpz *2016-06-28 08:19:36* + +**fixes #293** + + +[c1d0b](https://github.com/JSQLParser/JSqlParser/commit/c1d0b2f5283d8bb) wumpz *2016-06-28 00:11:15* + +**introduced OSGi metadata** + + +[89daf](https://github.com/JSQLParser/JSqlParser/commit/89dafaedeb69d6a) wumpz *2016-06-23 21:58:22* + +**fixes #291** + + +[63fa2](https://github.com/JSQLParser/JSqlParser/commit/63fa2f66b537731) wumpz *2016-06-23 21:40:57* + +**fixes #291** + + +[da42b](https://github.com/JSQLParser/JSqlParser/commit/da42b1dce108dd9) wumpz *2016-06-23 21:37:51* + +**fixes #278** + + +[12341](https://github.com/JSQLParser/JSqlParser/commit/1234127a47199e6) wumpz *2016-06-21 23:02:11* + +**fixes #278** + + +[faf8c](https://github.com/JSQLParser/JSqlParser/commit/faf8c6adea9bb28) wumpz *2016-06-21 22:58:40* + +**fixes #287** + + +[b1bea](https://github.com/JSQLParser/JSqlParser/commit/b1bea0273c5557a) wumpz *2016-06-21 20:50:02* + +**fixes #270** + + +[37c83](https://github.com/JSQLParser/JSqlParser/commit/37c8313e46e45a7) wumpz *2016-06-21 20:12:55* + +**** + + +[d3d66](https://github.com/JSQLParser/JSqlParser/commit/d3d66f819662698) wumpz *2016-06-20 07:08:58* + +**** + + +[0d1d1](https://github.com/JSQLParser/JSqlParser/commit/0d1d1c066d77ded) wumpz *2016-06-19 21:15:55* + +**fixes #284** + + +[8e7ba](https://github.com/JSQLParser/JSqlParser/commit/8e7ba38a39c6f85) wumpz *2016-06-19 20:09:07* + +**Implemented table check constraint for named constraints.** + +* 1. Added named constraint to create table. +* 2. Added check constraint to alter table statement. +* 3. Added CheckConstraint type. +* Tests: +* 4. Added create table test. +* 5. Added alter table test. + +[401d2](https://github.com/JSQLParser/JSqlParser/commit/401d279ef7e6ef9) Megan Woods *2016-06-16 14:56:01* + +**** + + +[04fc3](https://github.com/JSQLParser/JSqlParser/commit/04fc3aa9b53c8a9) wumpz *2016-06-15 20:50:52* + +**** + + +[bddbe](https://github.com/JSQLParser/JSqlParser/commit/bddbe588a759dd0) wumpz *2016-06-15 20:45:51* + +**Implemented:** + +* 1. UPDATE .. RETURNING col, col as Alias +* 2. UPDATE .. RETURNING * +* Tested: +* 3. UPDATE .. ORDER BY .. LIMIT .. RETURNING +* 4. UPDATE .. RETURNING +* Item 4 represents the PostgreSQL UPDATE .. RETURNING Syntax without ORDER BY and LIMIT. +* See: https://www.postgresql.org/docs/9.5/static/sql-update.html + +[f4526](https://github.com/JSQLParser/JSqlParser/commit/f452638f0f04f99) Megan Woods *2016-06-15 09:12:14* + +**** + + +[40aba](https://github.com/JSQLParser/JSqlParser/commit/40aba736f79c495) wumpz *2016-06-12 11:12:57* + +**-- added scalar time functions of ANSI SQL** + + +[f51df](https://github.com/JSQLParser/JSqlParser/commit/f51df4b5f7d51e2) ChrissW-R1 *2016-06-08 12:57:26* + +**** + + +[24c87](https://github.com/JSQLParser/JSqlParser/commit/24c874afad3110f) wumpz *2016-06-06 21:50:44* + +**updated readme** + + +[3bc31](https://github.com/JSQLParser/JSqlParser/commit/3bc316df743ab09) wumpz *2016-05-24 09:45:34* + +**Add a test-case for Hive's LEFT SEMI JOIN** + + +[e56fb](https://github.com/JSQLParser/JSqlParser/commit/e56fbe984cfab98) Vu Nhan *2016-05-19 04:53:22* + +**Add support for Hive's LEFT SEMI JOIN** + + +[fd03a](https://github.com/JSQLParser/JSqlParser/commit/fd03ad4f6bdd06a) Vu Nhan *2016-05-19 04:05:43* + +**fixes #243** + + +[bb978](https://github.com/JSQLParser/JSqlParser/commit/bb978c45b4d744d) wumpz *2016-05-16 20:49:58* + +**fixes #243** + + +[780ba](https://github.com/JSQLParser/JSqlParser/commit/780ba125a5807b2) wumpz *2016-05-16 20:47:32* + +**fixes #261** + + +[10e68](https://github.com/JSQLParser/JSqlParser/commit/10e68b5c3c58296) wumpz *2016-05-16 20:03:07* + +**updated readme** + + +[77ba3](https://github.com/JSQLParser/JSqlParser/commit/77ba380cfb639c4) wumpz *2016-05-06 06:06:33* + +**** + + +[57145](https://github.com/JSQLParser/JSqlParser/commit/5714516d314f31d) wumpz *2016-04-28 22:15:18* + +**Added ability to have operators like '>=' or '<=' separated by a space.** + +* This includes: +* Modifying the JJT syntax to support the 'space in the middle' versions +* of operators (any quantity of whitespace is supported). +* Modifying the various operators to inherit from a new +* 'ComparisonOperator' class, which handles the (previously NotEqualsTo- +* only) logic for capturing the form of the operator. +* Giving each of the various operators a constructor that accepts the +* syntax used. +* Modifying TestUtils to strip comments out before comparing SQL text +* (necessary because condition07.sql is now passing, and has a comment). +* Updating SpecialOracleTest to indicate 130 tests passing now +* (condition7.sql now passes). +* Adding a new test specifically for operators into SpecialOracleTest. +* NOTE: Because the "! =" form of the 'not equals' operator means something +* different in PostgresSQL (factorial of previous argument + equals), we do +* NOT include that case. + +[9886b](https://github.com/JSQLParser/JSqlParser/commit/9886b02975d1749) Dave Lindquist *2016-04-28 13:28:58* + +**Corrected "MERGE INTO" parsing for more complicated statements.** + +* Specifically: +* Changed "Condition" to "Expression" for the "ON" clause -- this is +* needed to handle "ON" clauses that have "a = y AND b = z" or other +* more complicated expressions (basically the same as the "ON" clause +* in a SELECT query). +* Also changed the "WHERE" and "DELETE WHERE" clauses in the same +* fashion ('Condition' becomes 'Expression'), as they too support +* multiple conditions. +* Corrected the toString on the MergeUpdate clause, which was missing a +* comma between the fields. +* Added a new, more complicated MERGE INTO statement to the MergeTest +* class. + +[7efd5](https://github.com/JSQLParser/JSqlParser/commit/7efd58f7704a0ff) Dave Lindquist *2016-04-28 13:19:34* + +**added for update test** + + +[d54b8](https://github.com/JSQLParser/JSqlParser/commit/d54b82ba62f1133) wumpz *2016-04-27 14:23:55* + +**fixes #253** + + +[75be4](https://github.com/JSQLParser/JSqlParser/commit/75be42659dc3a76) wumpz *2016-04-26 06:11:13* + +**fixed #245** + + +[01287](https://github.com/JSQLParser/JSqlParser/commit/012874f905adabe) wumpz *2016-04-15 22:01:56* + +**fixes #244** + + +[2204a](https://github.com/JSQLParser/JSqlParser/commit/2204a5fc85fb99d) wumpz *2016-04-15 20:10:32* + +**Update README.md** + + +[ac4a5](https://github.com/JSQLParser/JSqlParser/commit/ac4a56151b46d0b) Tobias *2016-04-14 19:30:09* + +**fixes #240** + +* fixes #241 + +[7f8b5](https://github.com/JSQLParser/JSqlParser/commit/7f8b59b31e44521) wumpz *2016-04-05 06:25:57* + +**small modifications, reduces some semantic lookaheads** + + +[7f5b6](https://github.com/JSQLParser/JSqlParser/commit/7f5b61e60bf037b) wumpz *2016-03-29 11:34:17* + +**fixed #228** + + +[3dfae](https://github.com/JSQLParser/JSqlParser/commit/3dfae9c62615711) wumpz *2016-03-17 08:40:24* + +**fixed #228** + + +[8f9b2](https://github.com/JSQLParser/JSqlParser/commit/8f9b2b905c00c68) wumpz *2016-03-17 08:38:35* + +**fixed #232 without correction of order of update and insert** + + +[7e2e7](https://github.com/JSQLParser/JSqlParser/commit/7e2e7200ce48672) wumpz *2016-03-17 08:28:47* + +**fixed some whitespace differences between deparser and toString regarding NOT expression** + + +[f4b25](https://github.com/JSQLParser/JSqlParser/commit/f4b25599a8919d4) wumpz *2016-03-17 08:16:24* + +**Update README.md** + + +[12009](https://github.com/JSQLParser/JSqlParser/commit/120096068fa4b3d) Tobias *2016-03-17 07:51:11* + +**update release info** + + +[eccd6](https://github.com/JSQLParser/JSqlParser/commit/eccd66f01f924f8) wumpz *2016-03-14 00:27:18* + +**Fixing uncaught exception** + + +[4fad4](https://github.com/JSQLParser/JSqlParser/commit/4fad4af810aef8d) emopers *2016-01-12 19:30:52* + + +## jsqlparser-0.9.5 (2016-03-13) + +### Other changes + +**no message** + + +[ffcfe](https://github.com/JSQLParser/JSqlParser/commit/ffcfe41096bca29) wumpz *2016-03-13 23:55:09* + +**** + + +[3c863](https://github.com/JSQLParser/JSqlParser/commit/3c8635280dbd959) wumpz *2016-03-13 23:35:37* + +**introduced boolean values within conditions** + + +[36a62](https://github.com/JSQLParser/JSqlParser/commit/36a62e9de7ec65e) wumpz *2016-03-10 21:19:22* + +**introduced boolean values within conditions** + + +[a8333](https://github.com/JSQLParser/JSqlParser/commit/a8333bf9310355b) wumpz *2016-03-10 21:16:28* + +**introduced boolean values within conditions** + + +[68e5b](https://github.com/JSQLParser/JSqlParser/commit/68e5b53e834f02f) wumpz *2016-03-10 21:11:01* + +**fixes #230** + + +[19915](https://github.com/JSQLParser/JSqlParser/commit/1991507179224f0) wumpz *2016-03-07 23:17:40* + +**multiple code improvements: squid:S1905, squid:S00122, squid:S1155, squid:S00105** + + +[905b2](https://github.com/JSQLParser/JSqlParser/commit/905b28d34771d15) George Kankava *2016-03-03 11:40:31* + +**fixed #226** + + +[67b17](https://github.com/JSQLParser/JSqlParser/commit/67b178b533128ae) wumpz *2016-02-27 13:54:58* + +**fixes #223** + + +[04e5c](https://github.com/JSQLParser/JSqlParser/commit/04e5c8b354f149d) wumpz *2016-02-11 21:23:51* + +**reduces a bunch of dynamic lookaheads to fixed ones** + + +[4c764](https://github.com/JSQLParser/JSqlParser/commit/4c764f54da7d820) wumpz *2016-02-11 20:51:02* + +**integrated changes of #225** + + +[eb5d7](https://github.com/JSQLParser/JSqlParser/commit/eb5d7a29737c6c5) wumpz *2016-02-11 20:41:23* + +**Multiple code improvements fix 1: squid:S1199, squid:S1066, squid:S1854, squid:S1165** + + +[af5d3](https://github.com/JSQLParser/JSqlParser/commit/af5d3cddf3564cf) George Kankava *2016-02-10 16:11:10* + +**Update README.md** + + +[e455c](https://github.com/JSQLParser/JSqlParser/commit/e455ce024f53779) Tobias *2016-02-10 06:43:04* + +**improved parsing performance** + + +[c78aa](https://github.com/JSQLParser/JSqlParser/commit/c78aa03d1af2cfe) wumpz *2016-02-09 22:30:20* + +**fixes #221** + + +[579f0](https://github.com/JSQLParser/JSqlParser/commit/579f0bc159aa053) wumpz *2016-02-04 22:10:43* + +**fixes #221** + + +[4a12d](https://github.com/JSQLParser/JSqlParser/commit/4a12dc10014ec51) wumpz *2016-02-04 22:07:12* + +**cleaned up some lookaheads** + + +[0cc80](https://github.com/JSQLParser/JSqlParser/commit/0cc809ea7de5238) wumpz *2016-02-04 08:58:52* + +**** + + +[36a4a](https://github.com/JSQLParser/JSqlParser/commit/36a4a0f9918ef9e) wumpz *2016-02-02 06:45:45* + +**fixes #217** + + +[de61c](https://github.com/JSQLParser/JSqlParser/commit/de61c0b92a25e03) wumpz *2016-02-02 06:21:59* + +**Added reference options foreign keys support (ON UPDATE/DELETE NO ACTION/CASCADE) and Full text indexes (FULLTEXT idx(text1))** + + +[c2956](https://github.com/JSQLParser/JSqlParser/commit/c29565bcaed42b1) pabloa *2016-02-01 21:57:27* + +**multiple code improvements 1** + + +[e6bec](https://github.com/JSQLParser/JSqlParser/commit/e6becde1df91db5) George Kankava *2016-02-01 07:35:08* + +**Support of mysql create statements with timestamp column with ON UPDATE. Example: CREATE TABLE test (applied timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP)** + + +[9dcaa](https://github.com/JSQLParser/JSqlParser/commit/9dcaaee63e4b2b3) pabloa98@gmail.com *2016-01-24 08:37:38* + +**fixes #151** + + +[f5b51](https://github.com/JSQLParser/JSqlParser/commit/f5b515be9351c77) wumpz *2016-01-06 09:12:54* + +**corrected lookahead for tablefunctions** + + +[8036e](https://github.com/JSQLParser/JSqlParser/commit/8036edd80628410) wumpz *2015-12-09 22:01:02* + +**TableFunction extends FunctionItem** + + +[17371](https://github.com/JSQLParser/JSqlParser/commit/17371ae38e0384e) tfedkiv *2015-12-08 08:39:07* + +**added TableFunction alias suppurt** + +* added TableFunction unit tests + +[88edd](https://github.com/JSQLParser/JSqlParser/commit/88eddaf50dada22) tfedkiv *2015-12-07 15:27:02* + +**fixed verion** + + +[a5a5f](https://github.com/JSQLParser/JSqlParser/commit/a5a5f9ee5b0d28d) ftaras *2015-12-07 14:25:07* + +**added support of SELECT FROM table function (h2)** + + +[0403f](https://github.com/JSQLParser/JSqlParser/commit/0403fdda2918311) tfedkiv *2015-12-07 14:23:39* + +**replaced size() with isEmpty()** + + +[1d634](https://github.com/JSQLParser/JSqlParser/commit/1d6348126dceec7) wumpz *2015-12-06 22:03:20* + +**jdk 8 build included into travis** + + +[830be](https://github.com/JSQLParser/JSqlParser/commit/830be49c4de1311) wumpz *2015-11-27 22:12:36* + +**increased version of maven-javadoc-plugin** + + +[1b842](https://github.com/JSQLParser/JSqlParser/commit/1b842f891e8b370) wumpz *2015-11-26 07:34:47* + +**** + + +[01d25](https://github.com/JSQLParser/JSqlParser/commit/01d25deaae72ba2) wumpz *2015-11-26 07:24:43* + +**Issue 198: add profile to ensure doclint is turned off with Java 8+. Without this, the project won't build on Java 8. (You can run mvn test successfully, but not mvn package.)** + + +[bb3ef](https://github.com/JSQLParser/JSqlParser/commit/bb3ef6188982b9b) James Heather *2015-11-25 13:43:57* + +**fixes #193** + + +[5d7bd](https://github.com/JSQLParser/JSqlParser/commit/5d7bdb9b254bc19) wumpz *2015-11-25 06:37:36* + +**fixes #195** + + +[ab1ad](https://github.com/JSQLParser/JSqlParser/commit/ab1ad25b6862e08) wumpz *2015-11-25 06:22:12* + +**Issue 195:** + +* Add support for ORDER BY and LIMIT in UPDATE and DELETE statements (as supported by MySQL). +* LimitDeparser and OrderByDeParser have been pulled out into separate classes to avoid code duplication from SelectDeParser. + +[a3133](https://github.com/JSQLParser/JSqlParser/commit/a31333a65141e27) James Heather *2015-11-24 14:57:04* + +**corrects parsing error** + + +[975cd](https://github.com/JSQLParser/JSqlParser/commit/975cddfb85bd0b3) wumpz *2015-11-20 22:44:01* + +**** + + +[f1d21](https://github.com/JSQLParser/JSqlParser/commit/f1d213636786e0a) wumpz *2015-11-20 14:27:19* + +**fixes #194** + + +[f1c98](https://github.com/JSQLParser/JSqlParser/commit/f1c9835bd34d3f1) wumpz *2015-11-18 21:17:49* + +**support INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] ...** + + +[00c18](https://github.com/JSQLParser/JSqlParser/commit/00c18698acb0316) wanghai *2015-11-18 09:10:31* + +**corrected lookahead** + + +[a97e9](https://github.com/JSQLParser/JSqlParser/commit/a97e9c94fef03c6) wumpz *2015-11-17 22:24:57* + +**fixes #192, fixes #191** + + +[2fddf](https://github.com/JSQLParser/JSqlParser/commit/2fddf8c8bf4072c) wumpz *2015-11-14 23:56:53* + +**replaceDeParser parser itemList** + + +[3c605](https://github.com/JSQLParser/JSqlParser/commit/3c6057b1f8d6311) wanghai *2015-11-13 08:45:21* + +**support insert ... on duplicate key update...** + + +[7d7fa](https://github.com/JSQLParser/JSqlParser/commit/7d7fae8a31abc3c) wanghai *2015-11-13 08:43:57* + +**fixes #181, added drop deparser** + + +[44091](https://github.com/JSQLParser/JSqlParser/commit/44091c622316769) wumpz *2015-11-09 22:33:56* + +**alter table support improved** + + +[ad0dd](https://github.com/JSQLParser/JSqlParser/commit/ad0dd23e8951e27) wumpz *2015-10-27 22:37:56* + +**fixes #180** + + +[0bb23](https://github.com/JSQLParser/JSqlParser/commit/0bb2358eaff8956) wumpz *2015-10-21 06:44:00* + +**#182** + + +[a3695](https://github.com/JSQLParser/JSqlParser/commit/a369537d0d3f51c) wumpz *2015-10-21 05:56:19* + +**Support for alter table drop column/constraint** + +* Fix for Issue #184 + +[58dd2](https://github.com/JSQLParser/JSqlParser/commit/58dd28aaf9b9273) schweighart *2015-10-20 21:34:51* + +**updated readme** + + +[e570a](https://github.com/JSQLParser/JSqlParser/commit/e570a919f24d385) wumpz *2015-10-19 13:16:54* + +**Improved required coverage** + + +[41cbd](https://github.com/JSQLParser/JSqlParser/commit/41cbd7f96ab9139) Rapševičius Valdas *2015-10-14 11:05:36* + +**Refactored Oracle Hint tests, added set selects** + + +[7b4fe](https://github.com/JSQLParser/JSqlParser/commit/7b4feb00cd4d312) Rapševičius Valdas *2015-10-13 22:37:29* + +**Added OracleHint class, grammar and model support, tests** + + +[f7f8d](https://github.com/JSQLParser/JSqlParser/commit/f7f8d03bfac9e09) Rapševičius Valdas *2015-10-13 22:06:16* + +**resolved choice conflict** + + +[b6f71](https://github.com/JSQLParser/JSqlParser/commit/b6f71e619c1a24d) wumpz *2015-10-08 11:11:42* + +**fixes #178, merged upstream** + + +[11dbd](https://github.com/JSQLParser/JSqlParser/commit/11dbda3b999d82b) Gabor Bota *2015-10-08 09:20:15* + +**added restrict and set null for alter statement** + + +[36379](https://github.com/JSQLParser/JSqlParser/commit/36379b2f646326c) wumpz *2015-10-07 21:38:53* + +**fixes #178** + + +[cb267](https://github.com/JSQLParser/JSqlParser/commit/cb2674e2b94ee95) Gabor Bota *2015-10-07 13:00:53* + +**fixes #174** + + +[da1e0](https://github.com/JSQLParser/JSqlParser/commit/da1e074b308d74a) wumpz *2015-10-06 21:18:27* + +**fixes #174** + + +[8d419](https://github.com/JSQLParser/JSqlParser/commit/8d419d31bb8be29) wumpz *2015-10-06 21:15:40* + +**simple merge implementation** + + +[bc4bc](https://github.com/JSQLParser/JSqlParser/commit/bc4bc9e52192b21) wumpz *2015-10-01 22:52:36* + +**simple merge implementation** + + +[af5a0](https://github.com/JSQLParser/JSqlParser/commit/af5a09078134f6c) wumpz *2015-10-01 22:44:50* + +**fixes #176** + + +[c6e93](https://github.com/JSQLParser/JSqlParser/commit/c6e9389599ed161) wumpz *2015-10-01 21:50:13* + +**fixes #176** + + +[fb4d4](https://github.com/JSQLParser/JSqlParser/commit/fb4d43b5a41d66b) wumpz *2015-10-01 21:45:44* + +**fixes #177** + + +[9999c](https://github.com/JSQLParser/JSqlParser/commit/9999c50ef3908a3) wumpz *2015-10-01 21:11:43* + +**** + + +[1fb42](https://github.com/JSQLParser/JSqlParser/commit/1fb426e08300adf) wumpz *2015-10-01 20:24:27* + +**merge impl started** + + +[8d8c0](https://github.com/JSQLParser/JSqlParser/commit/8d8c0e4ce70d944) wumpz *2015-09-24 22:23:11* + +**fixes #172** + + +[c690f](https://github.com/JSQLParser/JSqlParser/commit/c690f7f1efa5815) wumpz *2015-09-22 05:33:16* + +**** + + +[ae2c8](https://github.com/JSQLParser/JSqlParser/commit/ae2c87f5a19d9b0) wumpz *2015-09-16 18:55:58* + +**** + + +[03a4f](https://github.com/JSQLParser/JSqlParser/commit/03a4fc7d339cbb0) wumpz *2015-09-16 05:53:18* + +**fixes #167** + + +[57f30](https://github.com/JSQLParser/JSqlParser/commit/57f3099b869cc43) wumpz *2015-09-16 05:52:27* + +**fixes #167** + + +[71d9f](https://github.com/JSQLParser/JSqlParser/commit/71d9fd97fd92fbc) wumpz *2015-09-16 05:49:45* + +**fixes #77** + + +[0e51d](https://github.com/JSQLParser/JSqlParser/commit/0e51dacc2a0df3a) wumpz *2015-09-16 05:46:49* + +**fixes #170** + + +[cf9bf](https://github.com/JSQLParser/JSqlParser/commit/cf9bf8453791662) wumpz *2015-09-13 21:26:48* + + +## jsqlparser-0.9.4 (2015-09-13) + +### Other changes + +**** + + +[e9024](https://github.com/JSQLParser/JSqlParser/commit/e9024106aa5d994) wumpz *2015-09-07 19:26:26* + +**fixes #165** + + +[28101](https://github.com/JSQLParser/JSqlParser/commit/28101309a3502db) wumpz *2015-09-03 20:03:48* + +**fixes #165** + + +[bf06e](https://github.com/JSQLParser/JSqlParser/commit/bf06e6ccc269efa) wumpz *2015-09-03 20:02:25* + +**fixes #166** + + +[c244c](https://github.com/JSQLParser/JSqlParser/commit/c244ccb5cd00d0d) wumpz *2015-09-03 14:02:17* + +**fixed #162** + + +[46381](https://github.com/JSQLParser/JSqlParser/commit/463817b435ffdd5) wumpz *2015-08-07 20:48:55* + +**fixed #162** + + +[e3b73](https://github.com/JSQLParser/JSqlParser/commit/e3b73a35afbcb74) wumpz *2015-08-07 20:48:00* + +**fixed #160** + + +[432c0](https://github.com/JSQLParser/JSqlParser/commit/432c0ef9a7d462d) wumpz *2015-08-07 20:24:40* + +**no message** + + +[e91e0](https://github.com/JSQLParser/JSqlParser/commit/e91e074d8c773a6) wumpz *2015-08-05 20:44:25* + +**Add support for variable support to "SELECT SKIP FIRST ..." construct** + +* The grammar for the construct in informix [1] mentions the possibility, that <ROWCOUNT> can be either +* an integer or a host variable or local SPL variable storing the value of max. The case for plain integers and +* jdbc variables is covered by the first commit While this commit adds support for constructs using SPL +* variables. SPL variables must follow identifier rules [2][3]. +* [1] http://www-01.ibm.com/support/knowledgecenter/SSGU8G_12.1.0/com.ibm.sqls.doc/ids_sqs_0156.htm +* [2] http://www-01.ibm.com/support/knowledgecenter/SSGU8G_12.1.0/com.ibm.sqls.doc/ids_sqs_1306.htm?lang=de +* [3] http://www-01.ibm.com/support/knowledgecenter/SSGU8G_12.1.0/com.ibm.sqls.doc/ids_sqs_1660.htm%23ids_sqs_1660?lang=de + +[9e77b](https://github.com/JSQLParser/JSqlParser/commit/9e77b6bd55ce242) Matthias Bläsing *2015-08-02 14:03:23* + +**simplified lookahead** + + +[a44ac](https://github.com/JSQLParser/JSqlParser/commit/a44acb7a785394b) wumpz *2015-08-01 21:42:46* + +**simplified lookahead** + + +[0fc8e](https://github.com/JSQLParser/JSqlParser/commit/0fc8e29a3a5df3d) wumpz *2015-08-01 21:33:31* + +**Update README.md** + + +[b3d76](https://github.com/JSQLParser/JSqlParser/commit/b3d76e7847c6f90) Tobias *2015-07-31 05:27:21* + +**** + + +[6f2a1](https://github.com/JSQLParser/JSqlParser/commit/6f2a1323d03ae00) wumpz *2015-07-30 21:35:13* + +**added another testcase for #154** + + +[e889c](https://github.com/JSQLParser/JSqlParser/commit/e889cf345a84b8d) wumpz *2015-07-29 10:50:10* + +**Implement support for "SELECT SKIP FIRST ..." construct** + + +[4a33d](https://github.com/JSQLParser/JSqlParser/commit/4a33d8c380260d2) Matthias Bläsing *2015-07-25 19:16:23* + +**test for #154 included** + + +[001d6](https://github.com/JSQLParser/JSqlParser/commit/001d665d32c6df5) wumpz *2015-07-23 09:49:24* + +**** + + +[157ee](https://github.com/JSQLParser/JSqlParser/commit/157eebf7a07e23c) wumpz *2015-07-15 20:55:25* + +**fixes #150** + + +[5b3ec](https://github.com/JSQLParser/JSqlParser/commit/5b3ec5ac9f502d4) wumpz *2015-07-15 20:42:54* + +**fixes #149** + + +[d2b07](https://github.com/JSQLParser/JSqlParser/commit/d2b0706e6f175db) wumpz *2015-07-15 20:20:14* + +**Fix inline usage of foreign keys in CREATE TABLE statements** + + +[23c19](https://github.com/JSQLParser/JSqlParser/commit/23c19a53fd72c26) Georg Semmler *2015-07-09 15:41:39* + +**fixes #146** + + +[978b6](https://github.com/JSQLParser/JSqlParser/commit/978b60ebd0ffbbd) wumpz *2015-07-03 13:19:54* + +**reincluded Apache 2.0 license** + + +[83899](https://github.com/JSQLParser/JSqlParser/commit/83899f824659012) wumpz *2015-07-02 20:54:03* + +**reincluded Apache 2.0 license** + + +[7e52d](https://github.com/JSQLParser/JSqlParser/commit/7e52dd7cb474bc3) wumpz *2015-07-02 20:52:04* + +**corrected deparser** + + +[cc4a5](https://github.com/JSQLParser/JSqlParser/commit/cc4a5fa149aeac4) wumpz *2015-07-01 20:51:03* + +**updated readme** + + +[44716](https://github.com/JSQLParser/JSqlParser/commit/4471653646f286e) wumpz *2015-07-01 20:04:46* + +**fixes #138 and AnyComparisionExpression** + + +[ab2b2](https://github.com/JSQLParser/JSqlParser/commit/ab2b2c07759af48) wumpz *2015-07-01 19:55:02* + +**null toString used** + + +[e425d](https://github.com/JSQLParser/JSqlParser/commit/e425dc2528cc4d3) wumpz *2015-06-24 21:20:29* + +**completed any and all comparisions** + + +[fc076](https://github.com/JSQLParser/JSqlParser/commit/fc076e89580ca78) wumpz *2015-06-24 20:59:45* + +**Exceptions skiped during coverage tests** + + +[1849c](https://github.com/JSQLParser/JSqlParser/commit/1849c5b3f5ca03f) wumpz *2015-06-10 05:50:43* + +**Update README.md** + + +[d561d](https://github.com/JSQLParser/JSqlParser/commit/d561d8ad60b84fc) Tobias *2015-06-09 21:39:04* + +**** + + +[a17d6](https://github.com/JSQLParser/JSqlParser/commit/a17d6280b1ecdf6) wumpz *2015-06-09 21:29:55* + +**coveralls** + + +[5858a](https://github.com/JSQLParser/JSqlParser/commit/5858aa7a2215300) wumpz *2015-06-09 21:03:49* + +**** + + +[1d71c](https://github.com/JSQLParser/JSqlParser/commit/1d71c51a934dd1e) wumpz *2015-06-08 20:14:29* + +**completed ExpressionVisitorAdapter** + + +[8ec0b](https://github.com/JSQLParser/JSqlParser/commit/8ec0b195ba8da00) wumpz *2015-06-07 22:37:50* + +**completed ExpressionVisitorAdapter** + + +[cf703](https://github.com/JSQLParser/JSqlParser/commit/cf703d8225908d9) wumpz *2015-06-05 22:32:50* + +**completed ExpressionVisitorAdapter** + + +[348fd](https://github.com/JSQLParser/JSqlParser/commit/348fd7ffce92125) wumpz *2015-06-05 22:29:30* + +**updated some plugin versions** + + +[94c63](https://github.com/JSQLParser/JSqlParser/commit/94c63556b9d92a1) wumpz *2015-06-05 21:08:48* + +**fixes #143** + +* some refactorings done + +[4d2a0](https://github.com/JSQLParser/JSqlParser/commit/4d2a0a1151faff1) wumpz *2015-06-05 20:50:28* + +**fixes #143** + +* some refactorings done + +[f71c3](https://github.com/JSQLParser/JSqlParser/commit/f71c307f15c4cde) wumpz *2015-06-05 20:48:45* + +**fixes #142** + + +[3d340](https://github.com/JSQLParser/JSqlParser/commit/3d340377b37ddd9) wumpz *2015-06-05 20:28:28* + +**fixes #141** + + +[b78ed](https://github.com/JSQLParser/JSqlParser/commit/b78ed4b46472902) wumpz *2015-06-05 20:09:32* + +**** + + +[5123f](https://github.com/JSQLParser/JSqlParser/commit/5123fe295a4142b) wumpz *2015-06-05 20:07:12* + +**root nodes established but not linked** + + +[71305](https://github.com/JSQLParser/JSqlParser/commit/71305d9cbdc0e5b) wumpz *2015-05-31 20:39:43* + +**root nodes established but not linked** + + +[edd0c](https://github.com/JSQLParser/JSqlParser/commit/edd0c765ea34898) wumpz *2015-05-31 19:54:52* + +**astnodes for columns and tables** + + +[d66a9](https://github.com/JSQLParser/JSqlParser/commit/d66a93a4066ccff) wumpz *2015-05-29 22:49:13* + +**simple jjtree start** + + +[e594e](https://github.com/JSQLParser/JSqlParser/commit/e594e591e79f555) wumpz *2015-05-27 22:34:35* + +**simple jjtree start** + + +[d9f5f](https://github.com/JSQLParser/JSqlParser/commit/d9f5fef5f9d43e1) wumpz *2015-05-24 21:08:32* + +**fixes #134 - preserve order of query** + + +[59470](https://github.com/JSQLParser/JSqlParser/commit/594705ae61fd1b5) wumpz *2015-05-24 20:28:51* + +**fixes #136** + + +[5adeb](https://github.com/JSQLParser/JSqlParser/commit/5adebeee953bd2a) tejksat *2015-05-24 10:00:31* + +**fixes #134** + + +[d99e6](https://github.com/JSQLParser/JSqlParser/commit/d99e603e0e968f8) wumpz *2015-05-21 21:10:44* + +**fixes #72** + + +[8b540](https://github.com/JSQLParser/JSqlParser/commit/8b540614d7dbe9e) wumpz *2015-05-21 20:28:50* + +**fixes #72** + + +[3aaf1](https://github.com/JSQLParser/JSqlParser/commit/3aaf11d348e0b16) wumpz *2015-05-21 20:26:15* + +**group_concat started** + + +[adca3](https://github.com/JSQLParser/JSqlParser/commit/adca3efe84aaeb3) wumpz *2015-05-20 21:48:36* + +**** + + +[3563c](https://github.com/JSQLParser/JSqlParser/commit/3563c2188f4ffde) wumpz *2015-05-12 22:32:17* + + +## jsqlparser-0.9.3 (2015-05-12) + +### Other changes + +**fixes #69** + + +[16034](https://github.com/JSQLParser/JSqlParser/commit/16034878352a0fe) wumpz *2015-05-10 22:11:41* + +**fixes #69** + + +[35164](https://github.com/JSQLParser/JSqlParser/commit/35164e58c437fdc) wumpz *2015-05-10 22:02:24* + +**fixes #90** + + +[536ba](https://github.com/JSQLParser/JSqlParser/commit/536ba9d091fbe75) wumpz *2015-05-07 22:53:42* + +**fixes #90** + + +[db4a2](https://github.com/JSQLParser/JSqlParser/commit/db4a27e284ace55) wumpz *2015-05-07 22:50:35* + +**** + + +[55b8e](https://github.com/JSQLParser/JSqlParser/commit/55b8e7a4c9c947b) wumpz *2015-05-07 18:41:22* + +**fixes #129** + + +[45132](https://github.com/JSQLParser/JSqlParser/commit/45132a7e3d57b15) wumpz *2015-04-30 19:07:21* + +**fixes #128** + + +[aa291](https://github.com/JSQLParser/JSqlParser/commit/aa2913da90a4a05) wumpz *2015-04-27 21:59:00* + +**Update README.md** + + +[c4f24](https://github.com/JSQLParser/JSqlParser/commit/c4f24e6a30b0b9d) Tobias *2015-04-23 08:56:37* + +**fixes #126 - allows brackets around select** + + +[64b22](https://github.com/JSQLParser/JSqlParser/commit/64b22e45987284e) wumpz *2015-04-22 22:03:21* + +**fixes #125 - added values as a column name** + + +[ac785](https://github.com/JSQLParser/JSqlParser/commit/ac785a405697df4) wumpz *2015-04-16 21:01:18* + +**fixes #110 - first implementation** + + +[94195](https://github.com/JSQLParser/JSqlParser/commit/941952f58f5b5be) wumpz *2015-04-11 17:32:48* + +**updated readme** + + +[f2d48](https://github.com/JSQLParser/JSqlParser/commit/f2d48cf28f452d4) wumpz *2015-04-09 21:52:40* + +**solved some oracle test sql parsings** + + +[b76ba](https://github.com/JSQLParser/JSqlParser/commit/b76baa31439f841) wumpz *2015-04-09 21:45:16* + +**fixes #122** + + +[46f51](https://github.com/JSQLParser/JSqlParser/commit/46f51972cf47885) wumpz *2015-04-09 21:02:10* + +**fixes #123** + + +[68f47](https://github.com/JSQLParser/JSqlParser/commit/68f47dc7c49c1b2) wumpz *2015-04-09 20:23:50* + +**refactoring** + + +[26e1c](https://github.com/JSQLParser/JSqlParser/commit/26e1c0ac1c9221f) wumpz *2015-04-08 21:20:40* + +**refactoring** + + +[a9768](https://github.com/JSQLParser/JSqlParser/commit/a97686797e77480) wumpz *2015-04-08 21:17:30* + +**fixes #120** + + +[c3995](https://github.com/JSQLParser/JSqlParser/commit/c39954916a0ab71) wumpz *2015-04-08 06:11:06* + +**first try to fix #114** + + +[a0d87](https://github.com/JSQLParser/JSqlParser/commit/a0d8733b6c57055) wumpz *2015-04-07 00:48:55* + +**** + + +[73822](https://github.com/JSQLParser/JSqlParser/commit/738226709622311) wumpz *2015-04-06 20:53:58* + +**Update README.md** + + +[ad91b](https://github.com/JSQLParser/JSqlParser/commit/ad91b733c8b495c) Tobias *2015-04-06 20:34:30* + +**travis** + + +[ade82](https://github.com/JSQLParser/JSqlParser/commit/ade827e1eda7248) wumpz *2015-04-06 20:04:47* + +**** + + +[673e0](https://github.com/JSQLParser/JSqlParser/commit/673e00b1996eaac) wumpz *2015-04-06 19:08:34* + +**fixes #109** + + +[a3285](https://github.com/JSQLParser/JSqlParser/commit/a32854822885741) wumpz *2015-04-02 23:08:59* + +**fixes #119** + + +[c9b58](https://github.com/JSQLParser/JSqlParser/commit/c9b58b2b2dfba67) wumpz *2015-04-01 20:31:03* + +**fixes #117** + + +[a3fc1](https://github.com/JSQLParser/JSqlParser/commit/a3fc1f23701d6d6) wumpz *2015-03-28 20:02:28* + +**fixes #117** + + +[b3d91](https://github.com/JSQLParser/JSqlParser/commit/b3d91de4d54153f) wumpz *2015-03-28 19:50:20* + +**** + + +[f194b](https://github.com/JSQLParser/JSqlParser/commit/f194b7cb7cc810d) wumpz *2015-03-04 23:26:13* + +**corrected lookup** + + +[8598d](https://github.com/JSQLParser/JSqlParser/commit/8598da5760028d6) wumpz *2015-03-04 22:33:16* + +**updated readme** + + +[5472e](https://github.com/JSQLParser/JSqlParser/commit/5472e2d60e95590) wumpz *2015-03-04 22:28:45* + +**fixes #115** + + +[a3e02](https://github.com/JSQLParser/JSqlParser/commit/a3e024a0b002ad0) wumpz *2015-03-04 22:18:59* + +**fixes #116** + + +[c916f](https://github.com/JSQLParser/JSqlParser/commit/c916f14c1e5f82c) wumpz *2015-03-04 21:55:29* + +**Update README.md** + + +[18089](https://github.com/JSQLParser/JSqlParser/commit/18089564f2b9efb) Tobias *2015-02-12 22:54:15* + + +## jsqlparser-0.9.2 (2015-02-12) + +### Other changes + +**updated readme** + + +[13d29](https://github.com/JSQLParser/JSqlParser/commit/13d29e0d545bbaa) wumpz *2015-02-12 21:43:13* + +**introduced user variables: fixes #107** + + +[0c288](https://github.com/JSQLParser/JSqlParser/commit/0c2889ca34c88fd) wumpz *2015-02-11 21:21:24* + +**maybe not correct alter statement** + + +[ab001](https://github.com/JSQLParser/JSqlParser/commit/ab00181f492820a) wumpz *2015-02-04 22:53:06* + +**fixes #102** + + +[d603e](https://github.com/JSQLParser/JSqlParser/commit/d603e41768a49fd) wumpz *2015-02-04 21:16:18* + +**Update README.md** + + +[66517](https://github.com/JSQLParser/JSqlParser/commit/6651771afb0754f) Tobias *2015-02-01 20:03:21* + +**fixes #91** + + +[495a7](https://github.com/JSQLParser/JSqlParser/commit/495a7f2590703db) wumpz *2015-02-01 00:07:07* + +**Update README.md** + + +[d0ce4](https://github.com/JSQLParser/JSqlParser/commit/d0ce413581ace0d) Tobias *2015-01-30 21:30:28* + +**fixes #89** + + +[4ac85](https://github.com/JSQLParser/JSqlParser/commit/4ac85f0b27c21ba) wumpz *2015-01-21 20:15:55* + +**pivot function test** + + +[3cc5a](https://github.com/JSQLParser/JSqlParser/commit/3cc5acd2ee83f76) wumpz *2015-01-16 23:33:19* + +**Update README.md** + + +[3bec5](https://github.com/JSQLParser/JSqlParser/commit/3bec524f829975b) Tobias *2015-01-11 10:37:55* + +**fixes #99** + + +[d4bc7](https://github.com/JSQLParser/JSqlParser/commit/d4bc726944700c1) wumpz *2015-01-10 23:10:04* + +**fixes #99** + + +[5ac27](https://github.com/JSQLParser/JSqlParser/commit/5ac27a7ceb6166d) wumpz *2015-01-10 23:08:28* + +**small grammar cleanup** + + +[e4756](https://github.com/JSQLParser/JSqlParser/commit/e47566636b7fd83) wumpz *2014-12-18 21:24:23* + +**fixes #93** + + +[02be9](https://github.com/JSQLParser/JSqlParser/commit/02be9cdbca314f6) wumpz *2014-12-10 23:33:19* + +**fixes #92** + + +[e902a](https://github.com/JSQLParser/JSqlParser/commit/e902a41c71e1b44) wumpz *2014-12-10 23:17:40* + +**updated readme** + + +[32bf3](https://github.com/JSQLParser/JSqlParser/commit/32bf3a2f1798270) wumpz *2014-12-10 21:56:12* + +**add group ba additions to SelectUtils** + + +[dd77b](https://github.com/JSQLParser/JSqlParser/commit/dd77b6c4f2a1f24) wumpz *2014-12-08 22:51:59* + +**** + + +[adcaf](https://github.com/JSQLParser/JSqlParser/commit/adcaf0fe83dad8c) wumpz *2014-12-07 21:54:35* + +**fixes #88** + + +[0d5cc](https://github.com/JSQLParser/JSqlParser/commit/0d5cc58237dbaae) wumpz *2014-12-03 23:45:07* + +**oracle colls started** + + +[e8a18](https://github.com/JSQLParser/JSqlParser/commit/e8a18cc8b76c6bd) wumpz *2014-11-30 20:41:53* + +**options** + + +[2e85a](https://github.com/JSQLParser/JSqlParser/commit/2e85a16ebf7bfe3) wumpz *2014-11-25 00:11:17* + +**updated readme** + + +[72340](https://github.com/JSQLParser/JSqlParser/commit/72340e55d94f68e) wumpz *2014-11-24 20:17:52* + +**added create table parameters to deparser** + + +[05967](https://github.com/JSQLParser/JSqlParser/commit/05967cce8c528db) wumpz *2014-11-24 20:10:48* + +**added create parameters to include into deparser** + + +[6f89e](https://github.com/JSQLParser/JSqlParser/commit/6f89e35e4544112) wumpz *2014-11-23 23:36:35* + +**added commit keyword** + + +[f276b](https://github.com/JSQLParser/JSqlParser/commit/f276b33528821ad) wumpz *2014-11-23 23:26:40* + +**fixes #87** + + +[2056c](https://github.com/JSQLParser/JSqlParser/commit/2056cb064dffb3f) wumpz *2014-11-22 00:27:01* + +**simple cleanup** + + +[6a98d](https://github.com/JSQLParser/JSqlParser/commit/6a98d2bd8dd504b) wumpz *2014-11-20 20:42:39* + +**withitem - deparsing merged and modified** + + +[20e0f](https://github.com/JSQLParser/JSqlParser/commit/20e0f48c1a56da4) wumpz *2014-11-03 22:54:58* + +**use accept() instead of toString() on StatementDeParser** + + +[67497](https://github.com/JSQLParser/JSqlParser/commit/674974ac08f822d) reed1 *2014-11-02 06:53:07* + +**fixes #84** + + +[a5031](https://github.com/JSQLParser/JSqlParser/commit/a5031b403af80e4) wumpz *2014-10-31 22:57:23* + +**for update selects implemented** + + +[92efe](https://github.com/JSQLParser/JSqlParser/commit/92efe5b962ede77) wumpz *2014-10-30 23:59:42* + +**allow 'key' as object name** + + +[32b0a](https://github.com/JSQLParser/JSqlParser/commit/32b0a67999cf9ca) wumpz *2014-10-30 23:19:30* + +**update readme** + + +[d9951](https://github.com/JSQLParser/JSqlParser/commit/d9951d7bc5129da) wumpz *2014-10-22 22:03:20* + +**little housekeeping** + + +[5fb21](https://github.com/JSQLParser/JSqlParser/commit/5fb21dc2f605f81) wumpz *2014-10-22 21:51:37* + +**Manage OFFSET and FETCH clauses in dedicated classes and rules in** + +* jsqlparsercc.jj +* Manage also jdbc parameter in these clauses. + +[26524](https://github.com/JSQLParser/JSqlParser/commit/26524ac850461cb) LionelNirva *2014-10-10 14:38:20* + +**added test for wrong top distinct order.** + + +[ccefb](https://github.com/JSQLParser/JSqlParser/commit/ccefbeb29ac6693) wumpz *2014-10-09 19:23:52* + +**Add support for new SQL Server 2012 and Oracle 12c versions of LIMIT** + +* (equivalent to MySql and PostgreSQL LIMIT ... OFFSET ... clauses) for +* parsing and deparsing. + +[dc215](https://github.com/JSQLParser/JSqlParser/commit/dc215bb6b8cf70b) LionelNirva *2014-10-08 12:38:04* + +**Unit test for the fix Bug when Deparsing SQL Server request having TOP** + +* and DISTINCT clauses. + +[c2ad9](https://github.com/JSQLParser/JSqlParser/commit/c2ad9d2b2c2ee9f) LionelNirva *2014-10-07 14:31:43* + +**little housekeeping** + + +[fd25a](https://github.com/JSQLParser/JSqlParser/commit/fd25ab4b9279003) wumpz *2014-10-05 21:44:57* + +**little housekeeping** + + +[c3ec6](https://github.com/JSQLParser/JSqlParser/commit/c3ec64d426102cc) wumpz *2014-10-05 21:38:24* + +**compile error corrected** + + +[8ae4b](https://github.com/JSQLParser/JSqlParser/commit/8ae4bead1868ac7) wumpz *2014-10-05 21:15:34* + +**Fix Bug when Deparsing SQL Server request having TOP and DISTINCT** + +* clauses. SQL Server requires the DISTINCT clause to be the first. + +[7ac70](https://github.com/JSQLParser/JSqlParser/commit/7ac7002d1276f01) LionelNirva *2014-10-03 16:34:49* + +**Update UpdateTest.java** + +* Add an SQL test for Update with Select + +[aec82](https://github.com/JSQLParser/JSqlParser/commit/aec82516c9d0db6) CeeKayGit *2014-10-01 21:34:51* + +**Update UpdateDeParser.java** + + +[f2fec](https://github.com/JSQLParser/JSqlParser/commit/f2fecb7b62f5882) CeeKayGit *2014-10-01 21:18:33* + +**Update UpdateDeParser.java** + + +[e31ac](https://github.com/JSQLParser/JSqlParser/commit/e31ac1ad7090fc2) CeeKayGit *2014-10-01 20:51:26* + +**Update Update.java** + +* Add necessary Select import for Update with Select + +[8321a](https://github.com/JSQLParser/JSqlParser/commit/8321aae44a6adce) CeeKayGit *2014-10-01 20:37:42* + +**Update UpdateDeParser.java** + +* Extend the deparser to support DB2 Updates with Select clause + +[3a7bf](https://github.com/JSQLParser/JSqlParser/commit/3a7bf9d520ead88) CeeKayGit *2014-10-01 20:12:14* + +**Update JSqlParserCC.jj** + +* For DB2 "$" is also a standard letter, so handle "$" as #LETTER. + +[a6383](https://github.com/JSQLParser/JSqlParser/commit/a6383a52ccee448) CeeKayGit *2014-09-30 20:56:13* + +**Update Update.java** + +* Add support for DB2 Updates with Select clause + +[1bdb6](https://github.com/JSQLParser/JSqlParser/commit/1bdb69b8891ee26) CeeKayGit *2014-09-30 20:52:21* + +**Update JSqlParserCC.jj** + +* Add support for DB2 Updates with Select clause + +[17e3d](https://github.com/JSQLParser/JSqlParser/commit/17e3d539a4ce6bd) CeeKayGit *2014-09-30 20:47:54* + +**Update README.md** + + +[23279](https://github.com/JSQLParser/JSqlParser/commit/232795fc575cdf1) Tobias *2014-09-23 20:32:34* + + +## jsqlparser-0.9.1 (2014-09-23) + +### Other changes + +**Update README.md** + + +[267b4](https://github.com/JSQLParser/JSqlParser/commit/267b443e23b95a2) Tobias *2014-09-22 07:25:49* + +**corrected typo** + + +[90c93](https://github.com/JSQLParser/JSqlParser/commit/90c932332a6b8ed) wumpz *2014-09-07 20:28:38* + +**refactored join processor to be more restrictive** + + +[f1544](https://github.com/JSQLParser/JSqlParser/commit/f154446364fd5db) wumpz *2014-09-06 20:24:16* + +**simple execute clause support** + + +[531d6](https://github.com/JSQLParser/JSqlParser/commit/531d6177dfc03d1) wumpz *2014-08-14 21:46:11* + +**simple start for execute** + + +[d6f01](https://github.com/JSQLParser/JSqlParser/commit/d6f0101b9a3d2e4) wumpz *2014-08-13 23:17:08* + +**simple start for execute** + + +[406a1](https://github.com/JSQLParser/JSqlParser/commit/406a138cf3af9f7) wumpz *2014-08-13 23:08:35* + +**updated readme** + + +[1532d](https://github.com/JSQLParser/JSqlParser/commit/1532d15c3dad9ff) wumpz *2014-08-12 14:33:26* + +**correced select into parsing and deparsing** + + +[0b7f3](https://github.com/JSQLParser/JSqlParser/commit/0b7f3007dac51cb) wumpz *2014-08-12 14:29:46* + +**refactored grammar a bit** + + +[096e8](https://github.com/JSQLParser/JSqlParser/commit/096e8742b6fff86) wumpz *2014-08-05 20:58:15* + +**improved insert clause** + + +[a4de6](https://github.com/JSQLParser/JSqlParser/commit/a4de602442a73da) wumpz *2014-08-04 22:09:19* + +**corrected a failing test** + + +[24dc0](https://github.com/JSQLParser/JSqlParser/commit/24dc08db8b9f536) wumpz *2014-07-30 20:47:49* + +**updated readme** + + +[fc0ba](https://github.com/JSQLParser/JSqlParser/commit/fc0ba6a535c3f30) wumpz *2014-07-30 20:43:23* + +**limit 0 and limit null included** + + +[50d3e](https://github.com/JSQLParser/JSqlParser/commit/50d3e8b4224bbaf) wumpz *2014-07-30 20:41:40* + +**Add support for LIMIT 0 and LIMIT NULL statements** + + +[6db00](https://github.com/JSQLParser/JSqlParser/commit/6db009418e925ca) Michaël Cervera *2014-07-29 21:58:29* + +**unlogged inlucded in deparser** + + +[e9939](https://github.com/JSQLParser/JSqlParser/commit/e9939fdfdfca726) wumpz *2014-07-27 21:42:18* + +**Add support for 'UNLOGGED' tables** + +* Support the PostgreSQL 9.1+ ‘UNLOGGED’ table feature + +[eb05c](https://github.com/JSQLParser/JSqlParser/commit/eb05ce30cb90b93) Michaël Cervera *2014-07-27 20:49:00* + +**create table implemented version 2** + + +[98903](https://github.com/JSQLParser/JSqlParser/commit/989033d24e9b3a9) wumpz *2014-07-26 19:56:53* + +**recent changes made more oracle tests succeed** + + +[bbf36](https://github.com/JSQLParser/JSqlParser/commit/bbf360e5620b073) wumpz *2014-07-24 20:04:01* + +**updated readme** + + +[262d4](https://github.com/JSQLParser/JSqlParser/commit/262d48922d66d0f) wumpz *2014-07-24 19:59:25* + +**replaced column list in expression list for partition by of analytic expressions** + + +[2ebaa](https://github.com/JSQLParser/JSqlParser/commit/2ebaaf03602a13b) wumpz *2014-07-24 19:53:17* + +**updated readme** + + +[55e68](https://github.com/JSQLParser/JSqlParser/commit/55e68bfb4f84fa5) wumpz *2014-07-22 20:49:45* + +**implemented create table .. as select ..** + + +[23b93](https://github.com/JSQLParser/JSqlParser/commit/23b938c096eaf67) wumpz *2014-07-22 20:48:00* + +**simple improvements** + + +[5b3ea](https://github.com/JSQLParser/JSqlParser/commit/5b3ea032ff50712) wumpz *2014-07-16 20:27:54* + +**added lookahead for regexp binary** + + +[75aed](https://github.com/JSQLParser/JSqlParser/commit/75aeded181a6f88) Sarah Komla-Ebri *2014-07-16 15:05:30* + +**Added support for MySQL REGEXP BINARY (for case insensitivity)** + + +[ec0dc](https://github.com/JSQLParser/JSqlParser/commit/ec0dc88bc9b4280) Sarah Komla-Ebri *2014-07-16 13:50:37* + +**Added support for MySQL REGEXP insensitivity case** + + +[4d9e4](https://github.com/JSQLParser/JSqlParser/commit/4d9e46198e0a679) Sarah Komla-Ebri *2014-07-16 13:27:25* + +**simple first json syntax** + + +[cb674](https://github.com/JSQLParser/JSqlParser/commit/cb674bfa5937757) wumpz *2014-06-24 21:20:58* + +**simple first json syntax** + + +[45ce9](https://github.com/JSQLParser/JSqlParser/commit/45ce94eb9c0c62a) wumpz *2014-06-24 21:19:04* + +**returning implemented, column as identifier allowed** + + +[0020c](https://github.com/JSQLParser/JSqlParser/commit/0020c798f32c586) wumpz *2014-06-20 23:04:02* + +**returning implemented, column as identifier allowed** + + +[733ff](https://github.com/JSQLParser/JSqlParser/commit/733ff6da5d59ac1) wumpz *2014-06-20 22:58:28* + +**Update README.md** + + +[e12b8](https://github.com/JSQLParser/JSqlParser/commit/e12b8644326d3d2) Tobias *2014-06-04 20:50:35* + +**Update README.md** + + +[e8927](https://github.com/JSQLParser/JSqlParser/commit/e8927d40ab55bdd) Tobias *2014-06-04 20:47:38* + +**Update README.md** + + +[fb8ad](https://github.com/JSQLParser/JSqlParser/commit/fb8add01cb28b85) Tobias *2014-06-04 20:46:03* + +**Update README.md** + + +[08c6a](https://github.com/JSQLParser/JSqlParser/commit/08c6a48b3180db4) Tobias *2014-06-04 20:45:22* + +**fixes #56 : multitable updates** + + +[dfda1](https://github.com/JSQLParser/JSqlParser/commit/dfda1395c4275f6) wumpz *2014-05-25 20:16:31* + +**fixes #56 : multitable updates** + + +[9c183](https://github.com/JSQLParser/JSqlParser/commit/9c183ed34760126) wumpz *2014-05-25 20:06:04* + +**fixes #57: brackets were not handled properly** + + +[00367](https://github.com/JSQLParser/JSqlParser/commit/003674787cfa982) wumpz *2014-05-25 19:10:28* + +**readme updated** + + +[55634](https://github.com/JSQLParser/JSqlParser/commit/5563419fd15e430) wumpz *2014-05-22 22:08:32* + +**junit annotations** + + +[57154](https://github.com/JSQLParser/JSqlParser/commit/57154b37c22abfb) wumpz *2014-05-22 21:05:22* + +**Unit test** + + +[8cc03](https://github.com/JSQLParser/JSqlParser/commit/8cc036b4a99117a) shuyangzhou *2014-05-20 21:52:29* + +**TablesNamesFinder.getTableList(Delete) throws NPE when the sql does not have a where clause** + + +[6d828](https://github.com/JSQLParser/JSqlParser/commit/6d8287fcf9dd1ee) shuyangzhou *2014-05-20 21:52:24* + +**upgrade to JavaCC 6.1.2** + + +[c3404](https://github.com/JSQLParser/JSqlParser/commit/c3404e01e59b8d5) wumpz *2014-05-16 06:49:21* + +**Update README.md** + + +[67af4](https://github.com/JSQLParser/JSqlParser/commit/67af4cd64bf0af0) Tobias *2014-05-08 19:35:00* + + +## jsqlparser-0.9 (2014-05-08) + +### Other changes + +**support for some keywords as objectnames** + + +[60f2b](https://github.com/JSQLParser/JSqlParser/commit/60f2bc4345ad0c8) wumpz *2014-05-07 21:19:09* + +**support for some keywords as objectnames** + + +[c126e](https://github.com/JSQLParser/JSqlParser/commit/c126e1e511d2deb) wumpz *2014-05-07 20:57:32* + +**support for named pks included** + + +[3aabf](https://github.com/JSQLParser/JSqlParser/commit/3aabff2d744315e) wumpz *2014-04-20 23:56:06* + +**support for named pks included** + + +[9e683](https://github.com/JSQLParser/JSqlParser/commit/9e683d3662350ce) wumpz *2014-04-20 23:51:10* + +**util for conditional expression parsing included** + + +[ffeb7](https://github.com/JSQLParser/JSqlParser/commit/ffeb7b7013afaf4) wumpz *2014-04-07 21:29:42* + +**util for conditional expression parsing included** + + +[bc5a6](https://github.com/JSQLParser/JSqlParser/commit/bc5a6a459533b4e) wumpz *2014-04-07 21:21:58* + +**updated readme** + + +[01a82](https://github.com/JSQLParser/JSqlParser/commit/01a82c2e2da9ffb) wumpz *2014-03-23 21:21:41* + +**updated readme** + + +[84979](https://github.com/JSQLParser/JSqlParser/commit/849796360b04aa1) wumpz *2014-03-22 22:43:53* + +**changed configuration** + + +[96be5](https://github.com/JSQLParser/JSqlParser/commit/96be5d779bbf0bb) wumpz *2014-03-22 21:42:11* + +**readme updated** + + +[986c8](https://github.com/JSQLParser/JSqlParser/commit/986c87e1c61f332) wumpz *2014-03-18 21:35:28* + +**removed stachtrace printing for problematic sql scripts** + + +[7ff12](https://github.com/JSQLParser/JSqlParser/commit/7ff12fb4fded358) wumpz *2014-03-18 20:52:15* + +**corrected some sql test scripts to be deparseable** + +* corrected pivot handling in SelectDeParser + +[8ac25](https://github.com/JSQLParser/JSqlParser/commit/8ac250d9f90144d) wumpz *2014-03-12 23:24:47* + +**site descriptor** + + +[a6265](https://github.com/JSQLParser/JSqlParser/commit/a626532c854c35b) wumpz *2014-03-12 19:56:37* + +**pivot test sqls a little tweaked so parseing deparsing will work** + + +[dcd97](https://github.com/JSQLParser/JSqlParser/commit/dcd97c16a007c31) wumpz *2014-03-08 00:00:29* + +**pivot for subquery corrected** + + +[eb480](https://github.com/JSQLParser/JSqlParser/commit/eb480d73dc02c5c) wumpz *2014-03-07 23:48:52* + +**!= usage corrected** + +* deparser for oracle hierarchical expressions corrected +* order by asc/desc corrected + +[d4f74](https://github.com/JSQLParser/JSqlParser/commit/d4f744c761fffe9) wumpz *2014-03-06 22:27:11* + +**ALL processing corrected** + + +[68938](https://github.com/JSQLParser/JSqlParser/commit/68938c79b0394e0) wumpz *2014-03-06 20:46:49* + +**lax tests improved** + + +[ab578](https://github.com/JSQLParser/JSqlParser/commit/ab578af86ca2c26) wumpz *2014-03-05 23:17:40* + +**toString for windowing elements corrected** + +* lax equality test implemented +* included oracle test sqls +* included @ and # for identifiers + +[884dc](https://github.com/JSQLParser/JSqlParser/commit/884dcafa73ecfd2) wumpz *2014-03-05 23:01:03* + +**First version of all *Visitor adapters + simple test** + + +[cdc42](https://github.com/JSQLParser/JSqlParser/commit/cdc42110478506b) aalmiray *2014-03-05 20:45:57* + +**character set implemented** + + +[90048](https://github.com/JSQLParser/JSqlParser/commit/90048e535baa2f0) wumpz *2014-03-01 00:11:04* + +**character set implemented** + + +[e7114](https://github.com/JSQLParser/JSqlParser/commit/e7114e3c53230c6) wumpz *2014-03-01 00:05:59* + +**Update README.md** + + +[2c22b](https://github.com/JSQLParser/JSqlParser/commit/2c22b60433c9a51) Tobias *2014-02-20 22:51:32* + + +## jsqlparser-0.8.9 (2014-02-20) + +### Other changes + +**Update README.md** + + +[d6edd](https://github.com/JSQLParser/JSqlParser/commit/d6eddfd7e5d8a6b) Tobias *2014-02-15 22:11:51* + +**readme** + + +[f82d8](https://github.com/JSQLParser/JSqlParser/commit/f82d8316f00c581) wumpz *2014-02-14 22:01:31* + +**first statements version** + + +[4be27](https://github.com/JSQLParser/JSqlParser/commit/4be2700c2b5e0cd) wumpz *2014-02-14 21:56:27* + +**update readme** + + +[ff94a](https://github.com/JSQLParser/JSqlParser/commit/ff94a3ded2c295c) wumpz *2014-02-11 00:13:16* + +**** + + +[c91d1](https://github.com/JSQLParser/JSqlParser/commit/c91d153020b588c) wumpz *2014-02-11 00:08:31* + +**update readme** + + +[3b219](https://github.com/JSQLParser/JSqlParser/commit/3b21988a4857273) wumpz *2014-02-11 00:01:11* + +**corrected some styling issues** + + +[a3a7f](https://github.com/JSQLParser/JSqlParser/commit/a3a7ff934980b41) wumpz *2014-02-10 23:44:22* + +**backported analytic expressions from fork** + + +[43d97](https://github.com/JSQLParser/JSqlParser/commit/43d97ea79f1e48a) wumpz *2014-02-10 23:36:24* + +**order by clause improved nulls first last** + + +[ce45f](https://github.com/JSQLParser/JSqlParser/commit/ce45fbcf7f2d3e3) wumpz *2014-02-09 23:59:29* + +**added versions to pom** + + +[06bbd](https://github.com/JSQLParser/JSqlParser/commit/06bbda82b813e7b) wumpz *2014-02-08 11:01:56* + +**** + + +[9b2c2](https://github.com/JSQLParser/JSqlParser/commit/9b2c295a8552cf6) wumpz *2014-02-07 22:25:13* + +**Updated most of the Maven dependencies;** + + +[e6aaf](https://github.com/JSQLParser/JSqlParser/commit/e6aaf8b260fadd7) Pap Lőrinc *2014-02-07 07:59:11* + +**Added PERCENT support for the TOP statement;** + + +[5e127](https://github.com/JSQLParser/JSqlParser/commit/5e127196a96ced3) Pap Lőrinc *2014-02-07 07:58:51* + +**Update README.md** + + +[53aab](https://github.com/JSQLParser/JSqlParser/commit/53aab5737c61d1e) Tobias *2014-02-06 21:18:20* + +**readme updated** + + +[96654](https://github.com/JSQLParser/JSqlParser/commit/966541e5b90dbb8) wumpz *2014-02-06 21:14:04* + +**added testcase, little refactoring** + + +[4f766](https://github.com/JSQLParser/JSqlParser/commit/4f76615cf3bbd9b) wumpz *2014-02-06 21:08:18* + +**Modified the TOP expression to accept parentheses also;** + + +[b5849](https://github.com/JSQLParser/JSqlParser/commit/b5849b63d24bef3) Pap Lőrinc *2014-02-06 09:39:31* + +**updated readme** + + +[e143a](https://github.com/JSQLParser/JSqlParser/commit/e143abbd6c6374f) wumpz *2014-02-04 22:57:24* + +**removed Exception logging for false multipart name test** + + +[7a94f](https://github.com/JSQLParser/JSqlParser/commit/7a94fa7b57a085b) wumpz *2014-02-04 22:48:24* + +**** + + +[e1f06](https://github.com/JSQLParser/JSqlParser/commit/e1f06bb0204fe43) wumpz *2014-02-04 22:14:12* + +**included maven site generation** + + +[fc016](https://github.com/JSQLParser/JSqlParser/commit/fc016126850b1ac) wumpz *2014-02-02 23:47:06* + +**extended multipart identifier tests** + + +[a3e0f](https://github.com/JSQLParser/JSqlParser/commit/a3e0f9de56c4441) wumpz *2014-02-02 00:04:28* + +**** + + +[13f3c](https://github.com/JSQLParser/JSqlParser/commit/13f3c0c64f785fb) wumpz *2014-02-01 23:23:43* + +**removed possibility of empty tablename** + + +[9a819](https://github.com/JSQLParser/JSqlParser/commit/9a819eb5ceae1f9) wumpz *2014-02-01 23:17:35* + +**removed some changes** + + +[7fa4f](https://github.com/JSQLParser/JSqlParser/commit/7fa4f8501cc4453) wumpz *2014-02-01 22:55:57* + +**signed expressions tests improved** + + +[a78ab](https://github.com/JSQLParser/JSqlParser/commit/a78ab94cd60353f) wumpz *2014-02-01 22:18:32* + +**Replaced a leftover StringBuffer with StringBuilder;** + + +[9b8d7](https://github.com/JSQLParser/JSqlParser/commit/9b8d72739d464cc) Pap Lőrinc *2014-01-28 17:26:00* + +**Corrected Sql Server multi-part table and column names (database.schema.table.column) in the select statement to accept 4 levels with empty inner parts;** + + +[ba6c5](https://github.com/JSQLParser/JSqlParser/commit/ba6c54de7da2efa) Pap Lőrinc *2014-01-28 17:23:37* + +**Renamed getWholeColumnName and getWholeTableName to getFullyQualifiedName;** + + +[b4d54](https://github.com/JSQLParser/JSqlParser/commit/b4d547eeb04cb9a) Pap Lőrinc *2014-01-28 17:14:09* + +**Corrected the signed expression behaviors and renamed InverseExpression to SignedExpression;** + + +[d1e71](https://github.com/JSQLParser/JSqlParser/commit/d1e7185633bf840) Pap Lőrinc *2014-01-28 08:36:06* + +**Removed the leading and trailing whitespaces in the JavaCC parser file;** + +* Organized the declared imports in order to ease further changes in the file and to remove unused ones; +* Renamed the S_INTEGER token to S_LONG to be in sync with the S_DOUBLE token; + +[5d151](https://github.com/JSQLParser/JSqlParser/commit/5d151c7bdbe08fd) Pap Lőrinc *2014-01-28 08:24:04* + +**fixes #34** + + +[144ca](https://github.com/JSQLParser/JSqlParser/commit/144ca3a140d1024) wumpz *2014-01-23 22:14:58* + +**Update README.md** + + +[7024b](https://github.com/JSQLParser/JSqlParser/commit/7024bc7c1d1f553) Tobias *2014-01-22 23:23:54* + + +## jsqlparser-0.8.8 (2014-01-22) + +### Other changes + +**problem with git v1.8.5 adressed** + + +[9b12d](https://github.com/JSQLParser/JSqlParser/commit/9b12d17a4cb9744) wumpz *2014-01-22 23:05:23* + +**version 0.8.8-SNAPSHOT** + + +[810ca](https://github.com/JSQLParser/JSqlParser/commit/810cabdafe2012a) wumpz *2014-01-22 22:41:41* + +**version 0.8.8-SNAPSHOT** + + +[fdd3a](https://github.com/JSQLParser/JSqlParser/commit/fdd3a71426e473a) wumpz *2014-01-22 22:29:11* + +**Update README.md** + + +[d4083](https://github.com/JSQLParser/JSqlParser/commit/d40837361354a27) Tobias *2014-01-21 23:37:41* + +**addJoin introduced** + + +[c19f8](https://github.com/JSQLParser/JSqlParser/commit/c19f83f768a5e4a) wumpz *2014-01-21 23:35:34* + +**readme updated** + + +[d3675](https://github.com/JSQLParser/JSqlParser/commit/d367559442a98ab) wumpz *2014-01-14 22:29:07* + +**started simple utility function for select statement modification** + + +[bf454](https://github.com/JSQLParser/JSqlParser/commit/bf454e9a261cd4d) wumpz *2014-01-14 22:18:43* + +**started simple utility function for select statement modification** + + +[6b5e2](https://github.com/JSQLParser/JSqlParser/commit/6b5e29af117e04e) wumpz *2014-01-14 22:11:13* + +**update readme** + + +[311d6](https://github.com/JSQLParser/JSqlParser/commit/311d63639bda4a4) wumpz *2014-01-14 21:07:21* + +**little housekeeping** + + +[1c927](https://github.com/JSQLParser/JSqlParser/commit/1c927884749b032) wumpz *2014-01-14 21:01:05* + +**Alias class implemented and integrated** + + +[ce339](https://github.com/JSQLParser/JSqlParser/commit/ce3390677746faf) wumpz *2014-01-14 20:58:03* + +**Added one simple insert SQL to test** + + +[2db02](https://github.com/JSQLParser/JSqlParser/commit/2db02ada400cd99) wumpz *2014-01-11 15:05:50* + +**** + + +[f58ca](https://github.com/JSQLParser/JSqlParser/commit/f58ca061b25ba5b) wumpz *2013-12-08 20:13:04* + +**update readme** + + +[068b1](https://github.com/JSQLParser/JSqlParser/commit/068b19d17d9dba4) wumpz *2013-12-07 23:59:34* + +**start alter statement** + + +[75575](https://github.com/JSQLParser/JSqlParser/commit/7557524708d0ce0) wumpz *2013-12-07 23:57:27* + +**PostgresSQL regular expression match operators** + + +[e5e48](https://github.com/JSQLParser/JSqlParser/commit/e5e488d60c316f3) wumpz *2013-11-12 21:37:43* + +**Update README.md** + + +[259dd](https://github.com/JSQLParser/JSqlParser/commit/259dd566a55a9b6) Tobias *2013-11-08 23:38:09* + +**PostgresSQL regular expression case sensitive match** + + +[db923](https://github.com/JSQLParser/JSqlParser/commit/db923d53c5ceee7) wumpz *2013-11-08 23:33:46* + +**PostgresSQL regular expression case sensitive match** + + +[88b5a](https://github.com/JSQLParser/JSqlParser/commit/88b5aa81b405d45) wumpz *2013-11-08 23:27:30* + +**simple modifier cleanup** + + +[0528e](https://github.com/JSQLParser/JSqlParser/commit/0528ecca9768cf7) wumpz *2013-11-06 21:11:27* + +**Update README.md** + + +[2a4bb](https://github.com/JSQLParser/JSqlParser/commit/2a4bbe5391e4dfd) Tobias *2013-10-30 22:37:09* + +**update readme** + + +[e3b0e](https://github.com/JSQLParser/JSqlParser/commit/e3b0e6c4b5b7e48) wumpz *2013-10-30 22:31:03* + + +## jsqlparser-0.8.6 (2013-10-30) + +### Other changes + +**a little cleanup** + + +[bdc81](https://github.com/JSQLParser/JSqlParser/commit/bdc81933ab76b01) wumpz *2013-10-24 21:46:52* + +**version not needed anymore** + + +[7a737](https://github.com/JSQLParser/JSqlParser/commit/7a737e70a76616d) wumpz *2013-10-24 21:34:14* + +**Update README.md** + + +[f14e3](https://github.com/JSQLParser/JSqlParser/commit/f14e3c98917bc24) Tobias *2013-10-08 22:42:11* + +**Update README.md** + + +[22c3e](https://github.com/JSQLParser/JSqlParser/commit/22c3ee9379b4f7c) Tobias *2013-10-08 22:37:23* + +**update readme.md** + + +[d2dcf](https://github.com/JSQLParser/JSqlParser/commit/d2dcfaece51ceda) wumpz *2013-10-08 22:35:21* + +**merge oracle hierarchical syntax into main** + + +[a0b21](https://github.com/JSQLParser/JSqlParser/commit/a0b21c36e5d2008) wumpz *2013-10-08 22:23:30* + +**merge oracle hierarchical syntax into main** + + +[6c300](https://github.com/JSQLParser/JSqlParser/commit/6c30062bd7e9a59) wumpz *2013-10-08 22:22:19* + +**OracleHierarchicalExpression implemented** + + +[b48f2](https://github.com/JSQLParser/JSqlParser/commit/b48f26e48a00f03) wumpz *2013-10-08 22:07:03* + +**OracleHierarchicalExpression implemented** + + +[afa6e](https://github.com/JSQLParser/JSqlParser/commit/afa6e2d73d237f0) wumpz *2013-10-08 00:15:32* + +**Update README.md** + + +[3901b](https://github.com/JSQLParser/JSqlParser/commit/3901bc6bf380099) Tobias *2013-10-07 12:09:23* + +**Update README.md** + + +[9eb5f](https://github.com/JSQLParser/JSqlParser/commit/9eb5fa11dad1733) Tobias *2013-10-06 14:12:55* + +**parser updated oracle recursives** + + +[aff53](https://github.com/JSQLParser/JSqlParser/commit/aff53603149d42c) wumpz *2013-10-01 19:07:16* + +**begin implementation of oracle recursive queries** + + +[a7566](https://github.com/JSQLParser/JSqlParser/commit/a7566a7371bdca0) wumpz *2013-09-19 20:33:18* + + +## jsqlparser-0.8.5 (2013-10-06) + +### Other changes + +**preparing release of 0.8.5** + + +[7abce](https://github.com/JSQLParser/JSqlParser/commit/7abce433ce56bab) wumpz *2013-10-06 13:23:53* + +**preparing release of 0.8.5** + + +[0e13b](https://github.com/JSQLParser/JSqlParser/commit/0e13b77a827dfb5) wumpz *2013-10-06 12:55:48* + +**readme updated** + + +[3e68f](https://github.com/JSQLParser/JSqlParser/commit/3e68fa4928d5115) wumpz *2013-09-19 21:08:23* + +**problems solved with postgresqls data type "character varying"** + + +[c84e5](https://github.com/JSQLParser/JSqlParser/commit/c84e59eadd380e0) wumpz *2013-09-19 21:05:18* + +**problems solved with postgresqls data type "character varying"** + + +[f5af3](https://github.com/JSQLParser/JSqlParser/commit/f5af3053102af19) wumpz *2013-09-19 21:00:19* + +**corrected version infos** + + +[9da72](https://github.com/JSQLParser/JSqlParser/commit/9da728241feb44b) wumpz *2013-09-17 21:49:19* + +**Update README.md** + + +[da809](https://github.com/JSQLParser/JSqlParser/commit/da809493f5d6dbb) Tobias *2013-09-17 21:36:47* + +**first snapshot deployed to sonatype** + + +[62970](https://github.com/JSQLParser/JSqlParser/commit/629705cc0a3d758) wumpz *2013-09-17 21:27:05* + +**pom modification to publish to public repository** + + +[e60bc](https://github.com/JSQLParser/JSqlParser/commit/e60bc0e9fac79ee) wumpz *2013-09-17 12:14:43* + +**pom modification to publish to public repository** + + +[085d4](https://github.com/JSQLParser/JSqlParser/commit/085d4970d2a56c8) wumpz *2013-09-17 09:11:36* + +**CastExpression favours cast keyword instead of ::** + + +[68d12](https://github.com/JSQLParser/JSqlParser/commit/68d12944d835777) wumpz *2013-09-17 07:17:39* + +**CastExpression favours cast keyword instead of ::** + + +[8cf8b](https://github.com/JSQLParser/JSqlParser/commit/8cf8b4b7733dbd4) wumpz *2013-09-17 07:16:27* + +**removed unused modifiers** + + +[b3ee7](https://github.com/JSQLParser/JSqlParser/commit/b3ee75103cba4ec) wumpz *2013-08-29 20:22:48* + +**improved function test** + + +[35608](https://github.com/JSQLParser/JSqlParser/commit/35608babd2caae1) wumpz *2013-08-29 19:32:20* + +**workaround for mySql truncate function** + + +[c3b40](https://github.com/JSQLParser/JSqlParser/commit/c3b4046f8833357) wumpz *2013-08-29 19:22:57* + + +## jsqlparser-0.8.4 (2013-08-27) + +### Other changes + +**JJDoc output included in site configuration** + + +[b2688](https://github.com/JSQLParser/JSqlParser/commit/b2688799ada5918) wumpz *2013-08-25 19:30:45* + +**Update README.md** + + +[891dd](https://github.com/JSQLParser/JSqlParser/commit/891dd0a8e7e3086) Tobias *2013-08-22 20:29:48* + +**update readme** + + +[d375a](https://github.com/JSQLParser/JSqlParser/commit/d375ac9a51bc51e) wumpz *2013-08-22 20:20:29* + +**update readme** + + +[e25d0](https://github.com/JSQLParser/JSqlParser/commit/e25d0be44a8223a) wumpz *2013-08-22 20:13:19* + +**some minor additions to named parameters** + + +[8bff2](https://github.com/JSQLParser/JSqlParser/commit/8bff2c911467e84) wumpz *2013-08-22 20:11:19* + +**added ability to parse named parameters** + + +[284ec](https://github.com/JSQLParser/JSqlParser/commit/284ec72cd00a574) audrium *2013-08-22 13:47:39* + +**added changes to readme** + + +[6ab75](https://github.com/JSQLParser/JSqlParser/commit/6ab75599642eb23) wumpz *2013-08-14 21:34:21* + +**added some test cases** + + +[00f76](https://github.com/JSQLParser/JSqlParser/commit/00f76fe1a853843) wumpz *2013-08-14 21:25:47* + +**removed PivotForColumn** + + +[18904](https://github.com/JSQLParser/JSqlParser/commit/18904dd44c915d2) wumpz *2013-08-11 23:43:07* + +**regexp_like transfered into a general boolean function** + + +[410a2](https://github.com/JSQLParser/JSqlParser/commit/410a2d125db963e) wumpz *2013-08-11 21:26:33* + +**Add support old oracle join syntax to more expressions (simple comparisons and IN)** + + +[55f42](https://github.com/JSQLParser/JSqlParser/commit/55f42ea3712cf4d) Jonathan Burnhams *2013-08-02 07:52:05* + +**Add support for lag and lead with offset and default value parameters** + + +[99b46](https://github.com/JSQLParser/JSqlParser/commit/99b46bf1e7b18ec) Jonathan Burnhams *2013-08-01 14:00:15* + +**Added regexp_like support** + + +[33f4f](https://github.com/JSQLParser/JSqlParser/commit/33f4f66dbdd693d) Jonathan Burnhams *2013-08-01 13:26:05* + +**Finished adding pivot support** + + +[43fe8](https://github.com/JSQLParser/JSqlParser/commit/43fe8ca9c71afff) Jonathan Burnhams *2013-08-01 08:56:50* + +**Started to add pivot support** + + +[a9716](https://github.com/JSQLParser/JSqlParser/commit/a97160a801585fa) Jonathan Burnhams *2013-07-31 15:15:42* + +**Ignore intellij** + + +[51783](https://github.com/JSQLParser/JSqlParser/commit/517839aa4734e24) Jonathan Burnhams *2013-07-31 13:25:20* + +**Update README.md** + + +[3a8ea](https://github.com/JSQLParser/JSqlParser/commit/3a8eacabad85274) Tobias *2013-07-18 13:06:09* + +**removed release plugin dryrun** + + +[6e45a](https://github.com/JSQLParser/JSqlParser/commit/6e45a4fb22fe72a) wumpz *2013-07-05 20:55:50* + +**Update README.md** + + +[b53e7](https://github.com/JSQLParser/JSqlParser/commit/b53e74d3b50c5d5) Tobias *2013-07-05 05:58:12* + +**maven release plugin for local git repository** + + +[bd05e](https://github.com/JSQLParser/JSqlParser/commit/bd05eab93f7303b) wumpz *2013-07-04 19:54:39* + +**more sonar issues corrected** + + +[7fea9](https://github.com/JSQLParser/JSqlParser/commit/7fea946f0ea664e) wumpz *2013-07-04 19:23:29* + +**Update README.md** + + +[79f32](https://github.com/JSQLParser/JSqlParser/commit/79f322aca2246bc) Tobias *2013-07-04 19:04:02* + +**create table can now have foreign key definitions** + +* fixes #14 + +[0c41f](https://github.com/JSQLParser/JSqlParser/commit/0c41f27165a2f41) wumpz *2013-06-24 23:28:29* + +**removed some unused imports** + + +[8c37c](https://github.com/JSQLParser/JSqlParser/commit/8c37ca2628188ac) wumpz *2013-06-20 21:59:24* + +**more sonar identified stuff cleaned** + + +[51791](https://github.com/JSQLParser/JSqlParser/commit/5179164dc6d54b5) wumpz *2013-06-20 21:12:48* + +**cleanup violations found by sonar** + + +[51d0b](https://github.com/JSQLParser/JSqlParser/commit/51d0ba3b1eec349) Ivan Vasyliev *2013-06-14 14:44:01* + +**more sonar identified stuff cleaned** + + +[c84ed](https://github.com/JSQLParser/JSqlParser/commit/c84ed36f9555aa0) wumpz *2013-06-13 20:53:57* + +**corrected Method names mentioned by Sonar** + + +[16e2d](https://github.com/JSQLParser/JSqlParser/commit/16e2d8dd4a3e7ac) wumpz *2013-06-13 20:46:02* + +**cleaned up more critical points (sonar)** + + +[ad96c](https://github.com/JSQLParser/JSqlParser/commit/ad96cbb9c65e39f) wumpz *2013-06-13 20:42:40* + +**solved critical "Performance - Method concatenates strings using + in a loop"** + + +[9b86e](https://github.com/JSQLParser/JSqlParser/commit/9b86e368e4b3b67) wumpz *2013-06-09 23:40:10* + +**Update README.md** + + +[5c36d](https://github.com/JSQLParser/JSqlParser/commit/5c36da78eb4cc3d) Tobias *2013-06-08 22:14:15* + +**Update README.md** + + +[cdbec](https://github.com/JSQLParser/JSqlParser/commit/cdbec9bc2194147) Tobias *2013-06-08 21:55:29* + +**fixes #30** + + +[22f83](https://github.com/JSQLParser/JSqlParser/commit/22f839045489e20) wumpz *2013-05-30 20:11:44* + +**** + + +[4ebb5](https://github.com/JSQLParser/JSqlParser/commit/4ebb568f83de703) wumpz *2013-05-26 22:47:27* + +**added readme entry** + + +[afc0e](https://github.com/JSQLParser/JSqlParser/commit/afc0e2957c5c52c) wumpz *2013-05-26 22:21:36* + +**multi value IN expression introduced (a,b,c) in ...** + +* fixes #30 + +[3c443](https://github.com/JSQLParser/JSqlParser/commit/3c44391bf5f168f) wumpz *2013-05-26 22:19:03* + +**introduces Interval expression** + + +[fc5e6](https://github.com/JSQLParser/JSqlParser/commit/fc5e6050533e34d) wumpz *2013-05-26 20:44:44* + +**new version** + + +[f97c5](https://github.com/JSQLParser/JSqlParser/commit/f97c5a27faecc7b) wumpz *2013-05-23 22:03:06* + +**new version** + + +[a470a](https://github.com/JSQLParser/JSqlParser/commit/a470ae965d06ab4) wumpz *2013-05-22 19:57:51* + +**release** + + +[1366c](https://github.com/JSQLParser/JSqlParser/commit/1366caba4b4d087) wumpz *2013-05-22 19:57:21* + +**readme** + + +[4a620](https://github.com/JSQLParser/JSqlParser/commit/4a620031bcbef1e) wumpz *2013-05-22 19:49:11* + +**introduced generic list** + + +[8af04](https://github.com/JSQLParser/JSqlParser/commit/8af04647982fc78) wumpz *2013-05-22 19:38:36* + +**refactored some test utility methods out into a new class** + + +[c6bc4](https://github.com/JSQLParser/JSqlParser/commit/c6bc4c3ae5fad83) wumpz *2013-05-22 19:33:05* + +**improved test** + + +[5e106](https://github.com/JSQLParser/JSqlParser/commit/5e1069523441f0f) wumpz *2013-05-22 19:16:18* + +**- corrected S_DOUBLE parsing** + + +[6e3dc](https://github.com/JSQLParser/JSqlParser/commit/6e3dce2af7f2edd) wumpz *2013-05-16 22:22:01* + +**- solved critical grammar bug regarding concat expressions and parenthesis parsing** + +* - introduced some tests to cover the above +* - corrected ExpressionDeparser to deliver same result as toString for substractions + +[51365](https://github.com/JSQLParser/JSqlParser/commit/51365239ead790b) wumpz *2013-05-16 21:53:04* + +**added simple delete sql check** + + +[45fad](https://github.com/JSQLParser/JSqlParser/commit/45fad04b620704c) wumpz *2013-05-03 20:36:31* + +**add simple materialized view parsing without additional parameters** + + +[6b339](https://github.com/JSQLParser/JSqlParser/commit/6b339fc1e6478cc) wumpz *2013-04-24 20:48:16* + +**add simple materialized view parsing without additional parameters** + + +[fa5da](https://github.com/JSQLParser/JSqlParser/commit/fa5daaa3cd8430b) wumpz *2013-04-24 20:45:22* + +**Update README.md** + + +[1d923](https://github.com/JSQLParser/JSqlParser/commit/1d92374962fc745) Tobias *2013-04-24 06:03:14* + +**** + + +[a6615](https://github.com/JSQLParser/JSqlParser/commit/a661593121f07ac) wumpz *2013-04-23 21:14:24* + +**- corrected TableNamesFinder to work properly on update statements** + + +[eab74](https://github.com/JSQLParser/JSqlParser/commit/eab747b7891cbd8) wumpz *2013-04-23 21:07:32* + +**- Create View corrected in using set operations** + + +[97c03](https://github.com/JSQLParser/JSqlParser/commit/97c03337c1a2deb) wumpz *2013-04-23 20:42:51* + +**- from clause can now be used in update statements** + + +[b24c1](https://github.com/JSQLParser/JSqlParser/commit/b24c1c727cd1f81) wumpz *2013-04-21 21:34:26* + +**- from clause can now be used in update statements** + + +[b5c4c](https://github.com/JSQLParser/JSqlParser/commit/b5c4ce66d751579) wumpz *2013-04-21 21:31:30* + +**- insertet toString in Update** + +* - modified Update deparser to deliver better results + +[e2e4d](https://github.com/JSQLParser/JSqlParser/commit/e2e4d80675d525d) wumpz *2013-04-21 21:18:48* + +**added cross join syntax support** + + +[777a0](https://github.com/JSQLParser/JSqlParser/commit/777a08b2afeb495) wumpz *2013-04-18 22:28:32* + +**allow more complex expressions in extract clause** + + +[e551a](https://github.com/JSQLParser/JSqlParser/commit/e551a1603b1e2e6) wumpz *2013-04-18 21:49:45* + +**allow more complex expressions in extract clause** + + +[ab2ab](https://github.com/JSQLParser/JSqlParser/commit/ab2ab73f08d4fc8) wumpz *2013-04-18 21:46:29* + +**allow complete type in cast expression** + + +[8562d](https://github.com/JSQLParser/JSqlParser/commit/8562d7870a1c8c7) wumpz *2013-04-18 20:47:12* + +**allow complete type in cast expression** + + +[905a6](https://github.com/JSQLParser/JSqlParser/commit/905a62377b3bedd) wumpz *2013-04-18 20:40:49* + +**create view .. as (select ..) implemented** + + +[1b3c5](https://github.com/JSQLParser/JSqlParser/commit/1b3c507c922dd3a) wumpz *2013-04-18 20:23:19* + +**corrected comma list to partition by** + + +[d82c7](https://github.com/JSQLParser/JSqlParser/commit/d82c7a189f1b579) wumpz *2013-04-18 20:01:55* + +**corrected comma list to partition by** + + +[eafea](https://github.com/JSQLParser/JSqlParser/commit/eafea98e54e9b2e) wumpz *2013-04-18 19:59:20* + +**corrected comma list to partition by** + + +[5d40d](https://github.com/JSQLParser/JSqlParser/commit/5d40d7f384935ee) wumpz *2013-04-18 19:55:03* + +**added column names list to create view statement** + + +[b3a63](https://github.com/JSQLParser/JSqlParser/commit/b3a6354b5248884) wumpz *2013-04-17 22:15:38* + +**added column names list to create view statement** + + +[b7e73](https://github.com/JSQLParser/JSqlParser/commit/b7e738a071c28d8) wumpz *2013-04-17 22:11:15* + +**added more testcases** + + +[eae84](https://github.com/JSQLParser/JSqlParser/commit/eae84f640ba9619) wumpz *2013-04-07 21:08:13* + +**Update README.md** + + +[f2765](https://github.com/JSQLParser/JSqlParser/commit/f27659d74fad122) Tobias *2013-04-05 19:34:33* + +**support listing tables from other operations** + + +[1d09b](https://github.com/JSQLParser/JSqlParser/commit/1d09b0cd2a68fc5) Raymond Auge *2013-04-05 15:39:59* + +**support for create index** + + +[dca7d](https://github.com/JSQLParser/JSqlParser/commit/dca7d9be7a6d63f) Raymond Auge *2013-04-05 13:54:56* + +**added more tool functions to new tool class CCJSqlParserUtil** + + +[83a1e](https://github.com/JSQLParser/JSqlParser/commit/83a1e9590471581) wumpz *2013-03-23 22:31:09* + +**added more tool functions to new tool class CCJSqlParserUtil** + + +[90341](https://github.com/JSQLParser/JSqlParser/commit/90341f89642659e) wumpz *2013-03-23 22:28:35* + +**added more tool functions to new tool class CCJSqlParserUtil** + + +[56fe6](https://github.com/JSQLParser/JSqlParser/commit/56fe6558e978d8f) wumpz *2013-03-23 22:27:32* + +**added more tool functions** + + +[71daa](https://github.com/JSQLParser/JSqlParser/commit/71daa4ceee100c0) wumpz *2013-03-23 22:20:20* + +**switch to unicode parsing** + + +[886b7](https://github.com/JSQLParser/JSqlParser/commit/886b72c16d95a5a) wumpz *2013-03-21 22:58:37* + +**ignoring jedit backup files** + + +[da1e3](https://github.com/JSQLParser/JSqlParser/commit/da1e319210c431b) Tobias Warneke *2013-03-20 20:33:35* + +**Added automatic license header generation. The link to the original project was moved to the poms description.** + +* Format of all sources done. + +[01f7a](https://github.com/JSQLParser/JSqlParser/commit/01f7a4c92670794) wumpz *2013-03-19 21:30:50* + +**automatically create license header** + + +[8206d](https://github.com/JSQLParser/JSqlParser/commit/8206dea9caf33f9) wumpz *2013-03-19 21:05:27* + +**** + + +[26e3a](https://github.com/JSQLParser/JSqlParser/commit/26e3a8334563108) wumpz *2013-03-19 20:50:59* + +**** + + +[f37b7](https://github.com/JSQLParser/JSqlParser/commit/f37b7285295ec0a) wumpz *2013-03-19 20:38:04* + +**wildcard extension for analytic expression** + + +[d36fd](https://github.com/JSQLParser/JSqlParser/commit/d36fd2bd7f17dba) wumpz *2013-03-19 20:18:46* + +**readme updated** + + +[27be9](https://github.com/JSQLParser/JSqlParser/commit/27be9c57d64a2d3) wumpz *2013-03-19 00:16:05* + +**analytic expressions updated** + + +[9d62c](https://github.com/JSQLParser/JSqlParser/commit/9d62c21b2553b9c) wumpz *2013-03-19 00:12:06* + +**- additional test case for values** + +* - additional test cases for analytical expressions + +[15fc8](https://github.com/JSQLParser/JSqlParser/commit/15fc834bf78ae91) wumpz *2013-03-18 23:59:07* + +**Update README.md** + + +[d7f9f](https://github.com/JSQLParser/JSqlParser/commit/d7f9f39ab2b5e3c) Tobias *2013-03-17 00:32:02* + +**additional test case** + + +[e7dc8](https://github.com/JSQLParser/JSqlParser/commit/e7dc8d0cb5bb192) wumpz *2013-03-17 00:26:21* + +**multi value expression for select included** + + +[6b51f](https://github.com/JSQLParser/JSqlParser/commit/6b51f26b6025532) wumpz *2013-03-17 00:21:17* + +**Update README.md** + + +[15a8d](https://github.com/JSQLParser/JSqlParser/commit/15a8d0dd8053881) Tobias *2013-03-14 21:43:12* + +**multi value expression for insert included** + + +[898f3](https://github.com/JSQLParser/JSqlParser/commit/898f36937a9ad05) wumpz *2013-03-14 21:40:42* + +**multi value expression for insert included** + + +[8f21c](https://github.com/JSQLParser/JSqlParser/commit/8f21c6608eacd56) wumpz *2013-03-14 21:36:44* + +**corrected InsertDeParser to deliver same results like toString** + + +[95527](https://github.com/JSQLParser/JSqlParser/commit/955274b969983f6) wumpz *2013-03-12 22:15:07* + +**test for lateral and TableNamesFinder** + + +[a3ec5](https://github.com/JSQLParser/JSqlParser/commit/a3ec55aa297eade) wumpz *2013-03-03 00:46:19* + +**corrected readme** + + +[966d8](https://github.com/JSQLParser/JSqlParser/commit/966d8a7747becd1) wumpz *2013-02-27 23:27:02* + +**corrected readme** + + +[20275](https://github.com/JSQLParser/JSqlParser/commit/202756d18453b25) wumpz *2013-02-27 23:13:22* + +**** + + +[3d72a](https://github.com/JSQLParser/JSqlParser/commit/3d72a4f45f7cdad) wumpz *2013-02-27 23:08:50* + +**implemented lateral keyword** + + +[5bc39](https://github.com/JSQLParser/JSqlParser/commit/5bc39d3aaa74c24) wumpz *2013-02-27 23:05:01* + +**add WithItem to visitor interface** + + +[10e8f](https://github.com/JSQLParser/JSqlParser/commit/10e8f7ffd9a3b07) wumpz *2013-02-20 23:06:07* + +**some clean up** + + +[00799](https://github.com/JSQLParser/JSqlParser/commit/00799709a45f68c) wumpz *2013-02-20 22:47:14* + +**** + + +[35a17](https://github.com/JSQLParser/JSqlParser/commit/35a17b5a0190992) wumpz *2013-02-16 14:01:45* + +**0.8.2-SNAPSHOT** + + +[e8ed7](https://github.com/JSQLParser/JSqlParser/commit/e8ed7c70fac2cd3) wumpz *2013-02-15 22:42:47* + +**Release 0.8.1 to include in my maven repo** + + +[e41b3](https://github.com/JSQLParser/JSqlParser/commit/e41b333a4635c61) wumpz *2013-02-15 22:41:44* + +**- problem with TablesNamesFinder: finds with - alias instead of tablenames** + + +[08236](https://github.com/JSQLParser/JSqlParser/commit/082362b174d3faf) wumpz *2013-02-15 22:41:07* + +**- problem with TablesNamesFinder: finds with - alias instead of tablenames** + + +[43699](https://github.com/JSQLParser/JSqlParser/commit/436992983926da2) wumpz *2013-02-15 22:14:13* + +**Update README.md** + + +[c438f](https://github.com/JSQLParser/JSqlParser/commit/c438fdd520ede8e) Tobias *2013-02-14 07:45:00* + +**Update README.md** + + +[7beeb](https://github.com/JSQLParser/JSqlParser/commit/7beebabfe7eba67) Tobias *2013-02-14 00:11:32* + +**deployment to github maven repository** + + +[d9fe3](https://github.com/JSQLParser/JSqlParser/commit/d9fe37ad578a0e2) wumpz *2013-02-14 00:04:46* + +**Update README.md** + + +[5f306](https://github.com/JSQLParser/JSqlParser/commit/5f306a889b11754) Tobias *2013-01-04 09:39:02* + +**CreateView merged in** + + +[0ba65](https://github.com/JSQLParser/JSqlParser/commit/0ba65276f0a67e0) wumpz *2013-01-04 09:32:08* + +**CreateView merged in** + + +[b2eff](https://github.com/JSQLParser/JSqlParser/commit/b2eff8b0e0e7976) wumpz *2013-01-04 09:31:12* + +**Add CREATE VIEW support** + + +[101ef](https://github.com/JSQLParser/JSqlParser/commit/101ef1d9e10e7d2) Jeffrey Gerard *2012-12-26 17:52:30* + +**some housekeeping: replace string concats** + + +[db49b](https://github.com/JSQLParser/JSqlParser/commit/db49b43c2d7bace) wumpz *2012-11-15 22:38:04* + +**some housekeeping: adding missing braces** + + +[5dabd](https://github.com/JSQLParser/JSqlParser/commit/5dabda1deca055a) wumpz *2012-11-15 22:33:05* + +**some housekeeping: adding override annotations** + + +[5302b](https://github.com/JSQLParser/JSqlParser/commit/5302b4562af8bd0) wumpz *2012-11-15 22:21:05* + +**changed source encoding to utf8 from win-1252** + + +[af7fc](https://github.com/JSQLParser/JSqlParser/commit/af7fc5c63a08f96) wumpz *2012-10-31 23:38:33* + +**additional letters token rule included, to expand range of acceptable identifiers** + + +[86423](https://github.com/JSQLParser/JSqlParser/commit/86423b0ea8e9875) wumpz *2012-10-31 22:40:42* + +**additional letters token rule included, to expand range of acceptable identifiers** + + +[aa8e1](https://github.com/JSQLParser/JSqlParser/commit/aa8e15a1923c0a1) wumpz *2012-10-31 19:16:02* + +**Update README.md** + + +[50a56](https://github.com/JSQLParser/JSqlParser/commit/50a56b02c70dac2) Tobias *2012-10-27 22:42:10* + +**initial import** + + +[be85e](https://github.com/JSQLParser/JSqlParser/commit/be85e2dd312821a) wumpz *2012-10-27 22:23:51* + +**initial import** + + +[3331f](https://github.com/JSQLParser/JSqlParser/commit/3331fc415a20832) wumpz *2012-10-27 22:21:08* + +**initial import** + + +[52ffc](https://github.com/JSQLParser/JSqlParser/commit/52ffcf6d42d673c) wumpz *2012-10-27 22:17:53* + +**- introduced more generics in parser definition** + + +[4a89f](https://github.com/JSQLParser/JSqlParser/commit/4a89f9b93e3d4ff) wumpz *2012-10-26 22:23:16* + +**- introduced more generics in parser definition** + + +[b0e4a](https://github.com/JSQLParser/JSqlParser/commit/b0e4a4712432492) wumpz *2012-10-26 22:16:59* + +**- introduced more generics in parser definition** + + +[07317](https://github.com/JSQLParser/JSqlParser/commit/07317edca9c8f89) wumpz *2012-10-26 22:13:12* + +**- introduced more generics in parser definition** + + +[fde24](https://github.com/JSQLParser/JSqlParser/commit/fde24683e0c9930) wumpz *2012-10-12 20:55:17* + +**- clean up merge conflicts** + + +[e838d](https://github.com/JSQLParser/JSqlParser/commit/e838d9778060478) wumpz *2012-10-12 20:13:43* + +**- clean up merge conflicts** + + +[bf5d1](https://github.com/JSQLParser/JSqlParser/commit/bf5d17f1594c7ca) wumpz *2012-10-12 20:11:30* + +**Added SELECT parsing and JUnit test** + + +[e9766](https://github.com/JSQLParser/JSqlParser/commit/e9766966ccd7809) Christian Bockermann *2012-10-01 09:21:38* + +**- corrected changelog** + + +[1047b](https://github.com/JSQLParser/JSqlParser/commit/1047bb1877cc1ac) wumpz *2012-09-16 21:14:25* + +**- difference problem between deparser and tostring for function without parameters resolved** + + +[aee0f](https://github.com/JSQLParser/JSqlParser/commit/aee0fa79d5eb085) wumpz *2012-09-16 21:13:08* + +**- difference problem between deparser and tostring for function without parameters resolved** + + +[90f48](https://github.com/JSQLParser/JSqlParser/commit/90f48ff7b87767a) wumpz *2012-09-16 21:11:10* + +**- ExtractExpression integrated** + +* - Tests ExtractExpression started +* - Function problem found + +[7ea63](https://github.com/JSQLParser/JSqlParser/commit/7ea63d17c1ef299) wumpz *2012-09-16 21:01:53* + +**- extract syntax integrated into jj file** + + +[7a50b](https://github.com/JSQLParser/JSqlParser/commit/7a50b960e974183) wumpz *2012-09-15 21:26:39* + +**- expansion warnings removed by introducing lookaheads** + + +[db904](https://github.com/JSQLParser/JSqlParser/commit/db90438f3daab6f) wumpz *2012-09-15 21:04:18* + +**** + + +[3da19](https://github.com/JSQLParser/JSqlParser/commit/3da190b0b31a30d) wumpz *2012-09-11 19:33:24* + +**** + + +[ab60c](https://github.com/JSQLParser/JSqlParser/commit/ab60cfe02940fb8) wumpz *2012-09-08 20:58:20* + +**- moved tables names finder to utils package of source package. it is a too useful tool to live only in the test packages** + + +[57025](https://github.com/JSQLParser/JSqlParser/commit/5702587ce4abae9) wumpz *2012-09-08 19:59:35* + +**- moved tables names finder to utils package of source package. it is a too useful tool to live only in the test packages** + + +[4d33d](https://github.com/JSQLParser/JSqlParser/commit/4d33ded5322ca3b) wumpz *2012-09-08 19:57:25* + +**- Tool expression connector included** + + +[bb726](https://github.com/JSQLParser/JSqlParser/commit/bb726681905a11b) wumpz *2012-09-08 19:46:28* + +**- Tool alias adder implemented** + + +[2ee7a](https://github.com/JSQLParser/JSqlParser/commit/2ee7aa9688f8775) wumpz *2012-09-03 23:32:15* + +**imports corrected** + + +[147e8](https://github.com/JSQLParser/JSqlParser/commit/147e8b70ef75e81) wumpz *2012-09-01 22:05:02* + +**Fix some obvious compiler warnings** + + +[ea7a1](https://github.com/JSQLParser/JSqlParser/commit/ea7a174bf86f0bf) Ian Bacher *2012-06-13 20:35:48* + +**** + + +[99b92](https://github.com/JSQLParser/JSqlParser/commit/99b92b3e4e57860) wumpz *2012-06-12 21:49:05* + +**quoted columns in create table statement included** + +* CreateTableDeParser corrected (NPE with no indexes, toString delivers now same) +* CreateTableTest expanded + +[69287](https://github.com/JSQLParser/JSqlParser/commit/69287d7b2e8b278) wumpz *2012-05-26 19:58:14* + +**complex with tests included** + +* exists formatting included from fork + +[7e39e](https://github.com/JSQLParser/JSqlParser/commit/7e39e9ec4f48448) wumpz *2012-05-23 19:57:10* + +**changed version number due to visitor incombatibilities** + + +[87315](https://github.com/JSQLParser/JSqlParser/commit/87315094501ffbc) wumpz *2012-05-23 19:08:39* + +**** + + +[877ea](https://github.com/JSQLParser/JSqlParser/commit/877ea2c6783bf79) wumpz *2012-05-19 23:04:42* + +**- removed deprecated union class (replaced by SetOperationList)** + + +[bce12](https://github.com/JSQLParser/JSqlParser/commit/bce1290bea487cf) wumpz *2012-05-19 22:09:03* + +**set operation handling done** + + +[673eb](https://github.com/JSQLParser/JSqlParser/commit/673eb25f97c04d8) wumpz *2012-05-19 21:42:21* + +**start implementing union intersection etc. set operation handling** + + +[e980b](https://github.com/JSQLParser/JSqlParser/commit/e980bf3ac12a6b3) wumpz *2012-05-18 21:17:50* + +**** + + +[37ecf](https://github.com/JSQLParser/JSqlParser/commit/37ecf0a5a7e26ab) wumpz *2012-05-18 20:11:59* + +**- Added Oracle (+) join Syntax (instead of taba left join tabn on a=b oracle allows taba,tabn where a=b(+) )** + + +[31e94](https://github.com/JSQLParser/JSqlParser/commit/31e9435776bebaa) wumpz *2012-05-18 20:10:14* + +**- Analytic functions added: corrected PARTITION BY** + + +[4f2cb](https://github.com/JSQLParser/JSqlParser/commit/4f2cbb3eff61683) wumpz *2012-05-17 13:44:50* + +**- Analytic functions added: row_number() over (order by a,c)** + + +[b8543](https://github.com/JSQLParser/JSqlParser/commit/b8543ac725fe773) wumpz *2012-05-17 12:46:52* + +**Added support for modulo expression (5 % 4)** + + +[ae513](https://github.com/JSQLParser/JSqlParser/commit/ae51331f7c82d04) wumpz *2012-05-17 12:19:50* + +**Added support for modulo expression (5 % 4)** + + +[4ef84](https://github.com/JSQLParser/JSqlParser/commit/4ef842925b27438) wumpz *2012-05-16 21:30:14* + +**Include bracket quotation of columns and aliases. For example MSAccess supports this.** + + +[e6d5a](https://github.com/JSQLParser/JSqlParser/commit/e6d5accd0db8e1f) wumpz *2012-05-16 20:33:44* + +**** + + +[d6a22](https://github.com/JSQLParser/JSqlParser/commit/d6a22d1076b95f0) wumpz *2012-05-15 21:50:56* + +**- allowed simple expressions in case else** + + +[54d2c](https://github.com/JSQLParser/JSqlParser/commit/54d2c54658d1644) wumpz *2012-05-15 21:36:59* + +**- make "select function" pass assertSqlCanBeParsedAndDeparsed** + + +[21296](https://github.com/JSQLParser/JSqlParser/commit/21296032a0ef7db) wumpz *2012-05-15 21:00:51* + +**- make "select function" pass assertSqlCanBeParsedAndDeparsed** + + +[f769e](https://github.com/JSQLParser/JSqlParser/commit/f769ef2e562f485) wumpz *2012-05-15 20:57:07* + +**- make "select function" pass assertSqlCanBeParsedAndDeparsed** + + +[e5853](https://github.com/JSQLParser/JSqlParser/commit/e5853695b96ac0f) wumpz *2012-05-15 20:55:23* + +**- make "select function" pass assertSqlCanBeParsedAndDeparsed** + + +[7a8bb](https://github.com/JSQLParser/JSqlParser/commit/7a8bbbe8abf9681) toben *2012-05-13 22:21:38* + +**- CAST - statement included** + + +[e22f5](https://github.com/JSQLParser/JSqlParser/commit/e22f5a3b6fe70aa) toben *2012-05-13 22:09:34* + +**removed main and junit 3 only artifacts from source code** + + +[3f854](https://github.com/JSQLParser/JSqlParser/commit/3f854eb7cbe63d9) toben *2012-05-13 12:39:52* + +**junit upgrade to 4.10** + + +[44b0d](https://github.com/JSQLParser/JSqlParser/commit/44b0d01d19571d0) toben *2012-05-13 12:35:33* + +**Refactoring of SelectTest** + + +[e1c80](https://github.com/JSQLParser/JSqlParser/commit/e1c80a0434df739) Florent Bécart *2011-12-02 07:20:18* + +**Removal of tests that are not able to pass** + +* - Functions do not accept conditions as arguments + +[aa5f0](https://github.com/JSQLParser/JSqlParser/commit/aa5f044c5bebc78) Florent Bécart *2011-12-02 07:20:18* + +**Code reformat** + + +[272bf](https://github.com/JSQLParser/JSqlParser/commit/272bf237eddcdc2) Florent Bécart *2011-12-02 07:20:18* + +**Modify DeParsers to output the same result as statement.toString();** + + +[2a35e](https://github.com/JSQLParser/JSqlParser/commit/2a35efd003ca5b5) Alice Rapunzel *2011-11-21 08:53:24* + +**Changed DeParsers to generic list types.** + + +[666ca](https://github.com/JSQLParser/JSqlParser/commit/666cac2edecc8d7) Christian Bockermann *2011-09-17 07:58:43* + +**Changed all lists to their appropriate generics type.** + + +[0dd60](https://github.com/JSQLParser/JSqlParser/commit/0dd60b143eae3f1) Christian Bockermann *2011-09-17 07:53:14* + +**.gitignore update** + + +[dd2a7](https://github.com/JSQLParser/JSqlParser/commit/dd2a75bd7fde3fb) Florent Bécart *2011-09-16 22:41:36* + +**Add the sources generated by javacc-maven-plugin to eclipse classpath** + + +[66556](https://github.com/JSQLParser/JSqlParser/commit/6655673c1531cac) Florent Bécart *2011-09-16 22:41:36* + +**Set the version of javacc-maven-plugin in pom.xml as recommended by maven** + + +[3f9c4](https://github.com/JSQLParser/JSqlParser/commit/3f9c4cc36c1a628) Florent Bécart *2011-09-16 22:41:36* + +**Project cleanup** + + +[0cb63](https://github.com/JSQLParser/JSqlParser/commit/0cb637199c9cd95) Florent Bécart *2011-09-16 22:41:36* + +**README update** + + +[00b8c](https://github.com/JSQLParser/JSqlParser/commit/00b8ca8dbb2ca6b) Florent Bécart *2011-09-16 22:41:36* + +**Added README** + + +[2005d](https://github.com/JSQLParser/JSqlParser/commit/2005d6db8594102) Christian Bockermann *2011-09-16 20:22:29* + +**Removed javcc-5.0 directory (no covered by Maven plugin)** + + +[61fb4](https://github.com/JSQLParser/JSqlParser/commit/61fb4a16876f9e4) Christian Bockermann *2011-09-16 20:13:28* + +**Added support for select without from-list ( SELECT 1 + 2 )** + +* Modified test cases for test resources in src/test/resources + +[0e5d7](https://github.com/JSQLParser/JSqlParser/commit/0e5d732e65bf622) Christian Bockermann *2011-09-16 20:06:07* + +**Moved classes to match Maven directory layout.** + + +[a8d70](https://github.com/JSQLParser/JSqlParser/commit/a8d70350729d085) Christian Bockermann *2011-09-16 19:48:54* + +**Use of StringBuilders instead of StringBuffers** + + +[ef03d](https://github.com/JSQLParser/JSqlParser/commit/ef03d68f8a365fc) Florent Bécart *2011-06-23 00:50:08* + +**Files generated by JavaCC should be ignored by Git** + + +[b5aff](https://github.com/JSQLParser/JSqlParser/commit/b5affcc84aaf6d7) Florent Bécart *2011-06-23 00:49:59* + +**Removal of files generated by JavaCC** + + +[767e3](https://github.com/JSQLParser/JSqlParser/commit/767e3c4e257512e) Florent Bécart *2011-06-23 00:05:33* + +**Bug Fix: the column deparser should use the table alias if any** + + +[bc8dc](https://github.com/JSQLParser/JSqlParser/commit/bc8dcbbe1fdae50) Florent Bécart *2011-06-23 00:01:57* + +**Use of generics** + +* - List of expressions in ItemsList +* - List of columns in Statement +* - List of joins in PlainSelect +* - List of withItems in Select +* - List of plainSelects in Union +* - List of orderByElements in Union +* - List of columns in Update +* - List of expressions in Update + +[8b0b8](https://github.com/JSQLParser/JSqlParser/commit/8b0b865780ee962) Florent Bécart *2011-06-22 20:00:44* + +**Insert statements accept both keywords "value" and "values"** + + +[1db31](https://github.com/JSQLParser/JSqlParser/commit/1db31a4491b01f1) Florent Bécart *2011-06-20 23:14:11* + +**Organize imports** + + +[db5e2](https://github.com/JSQLParser/JSqlParser/commit/db5e2501d8eefd5) Florent Bécart *2011-06-20 22:49:36* + +**Code reformat** + + +[fed74](https://github.com/JSQLParser/JSqlParser/commit/fed74aec2acf3db) Florent Bécart *2011-06-20 22:48:00* + +**Fixes a compilation error by removing an unused import** + + +[b9ce3](https://github.com/JSQLParser/JSqlParser/commit/b9ce35c945ffdab) Florent Bécart *2011-06-20 22:35:16* + +**Eclipse configuration files** + +* Makes development environment installation easier + +[b93af](https://github.com/JSQLParser/JSqlParser/commit/b93af3e4f333cdc) Florent Bécart *2011-06-20 22:33:30* + +**Add .gitignore file** + +* Auto-generated files that won't be pushed to the repo are: +* - classes: compiled main code +* - docs: project javadoc +* - *.jar: distribution jar (sources and documentation) +* - lib: library jar (.class files) +* - testclasses: compiled unit tests + +[55197](https://github.com/JSQLParser/JSqlParser/commit/5519799ce41c45b) Florent Bécart *2011-06-20 22:08:46* + +**Remove auto-generated folders docs and lib** + + +[d2f54](https://github.com/JSQLParser/JSqlParser/commit/d2f5416986e5c9b) Florent Bécart *2011-06-20 22:06:36* + +**Add junit library (required for ant build)** + + +[e0ad5](https://github.com/JSQLParser/JSqlParser/commit/e0ad59290667fc2) Florent Bécart *2011-06-20 21:50:19* + +**Add javacc-5.0 folder (required for ant build)** + + +[36ddc](https://github.com/JSQLParser/JSqlParser/commit/36ddcb236313093) Florent Bécart *2011-06-20 21:48:21* + +**Initial commit (base version: 0.7.0)** + +* Source: http://sourceforge.net/projects/jsqlparser/files/jsqlparser/jsqlparser-0.7.0.jar/download + +[67c91](https://github.com/JSQLParser/JSqlParser/commit/67c9150f5d93ced) Florent Bécart *2011-06-20 21:44:37* + + diff --git a/LICENSE_APACHEV2 b/LICENSE_APACHEV2 new file mode 100644 index 0000000000..8dada3edaf --- /dev/null +++ b/LICENSE_APACHEV2 @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/LICENSE_LGPLV21 b/LICENSE_LGPLV21 new file mode 100644 index 0000000000..19e307187a --- /dev/null +++ b/LICENSE_LGPLV21 @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +(This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.) + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random + Hacker. + + {signature of Ty Coon}, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/README.md b/README.md index a8b25c8472..bb7325a6a6 100644 --- a/README.md +++ b/README.md @@ -1,82 +1,288 @@ -# JSqlParser +
-Look here for more information and examples: https://github.com/JSQLParser/JSqlParser/wiki. +
+ + +
+

JSqlParser

+

Turn any SQL statement into a traversable tree of Java objects -- and back again.

+

An RDBMS-agnostic SQL parser for the JVM:
one grammar, twelve dialects, no native extensions.

+
+ +JSqlParser + +
-## News +[![CI](https://github.com/JSQLParser/JSqlParser/actions/workflows/ci.yml/badge.svg)](https://github.com/JSQLParser/JSqlParser/actions/workflows/ci.yml) +[![Coverage Status](https://coveralls.io/repos/JSQLParser/JSqlParser/badge.svg?branch=master)](https://coveralls.io/r/JSQLParser/JSqlParser?branch=master) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/6f9a2d7eb98f45969749e101322634a1)](https://www.codacy.com/gh/JSQLParser/JSqlParser/dashboard) +[![Manticore Build](https://img.shields.io/maven-central/v/com.manticore-projects.jsqlformatter/jsqlparser.svg?label=manticore%20build&color=ff420e)](https://central.sonatype.com/artifact/com.manticore-projects.jsqlformatter/jsqlparser) +[![Maven Central](https://img.shields.io/maven-central/v/com.github.jsqlparser/jsqlparser.svg?label=upstream%20release)](https://central.sonatype.com/artifact/com.github.jsqlparser/jsqlparser) +[![Javadocs](https://www.javadoc.io/badge/com.github.jsqlparser/jsqlparser.svg)](https://www.javadoc.io/doc/com.github.jsqlparser/jsqlparser) +[![GitHub Stars](https://img.shields.io/github/stars/JSQLParser/JSqlParser?style=flat&label=stars)](https://github.com/JSQLParser/JSqlParser/stargazers) +[![Gitter](https://badges.gitter.im/JSQLParser/JSqlParser.svg)](https://gitter.im/JSQLParser/JSqlParser) -Version **0.9.1** released. +**[Website](https://jsqlparser.github.io/JSqlParser)** · **[Samples](https://jsqlparser.github.io/JSqlParser/usage.html#parse-a-sql-statements)** · **[Syntax](https://jsqlparser.github.io/JSqlParser/syntax.html)** · **[Change Log](https://jsqlparser.github.io/JSqlParser/changelog.html#latest-changes-since-jsqlparser-version)** · **[Contributing](https://jsqlparser.github.io/JSqlParser/contribution.html)** -Version **0.9** released. + -More news can be found here: https://github.com/JSQLParser/JSqlParser/wiki/News. +--- -## JSqlParser +## What it does -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. +Give it SQL. Get an AST you can walk, rewrite, and print back out. -## Contributions -To help JSqlParsers development you are encouraged to provide -* feedback -* bugreports -* pull requests for new features -* improvement requests +```sql +SELECT 1 FROM dual WHERE a = b +``` -Also I would like to know about needed examples or documentation stuff. +```text +SQL Text + └─Statements: statement.select.PlainSelect + ├─selectItems: statement.select.SelectItem + │ └─LongValue: 1 + ├─Table: dual + └─where: expression.operators.relational.EqualsTo + ├─Column: a + └─Column: b +``` -## Extensions in the latest SNAPSHOT version 0.9.2 +```java +String sqlStr = "select 1 from dual where a=b"; -* first support for *FOR UPDATE* +PlainSelect select = (PlainSelect) CCJSqlParserUtil.parse(sqlStr); -```sql -SELECT * FROM user_table FOR UPDATE +SelectItem selectItem = select.getSelectItems().get(0); +Assertions.assertEquals(new LongValue(1), selectItem.getExpression()); + +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()); ``` -```sql -UPDATE mytable SET (col) = (SELECT a FROM mytable2) +The tree is traversable with the Visitor pattern, and the same object model works in reverse: +build statements from Java with a [fluent API](https://jsqlparser.github.io/JSqlParser/usage.html#build-a-sql-statements) +and render them as SQL text. + +## Install + +Use the stable **Manticore builds**. They are released continuously from the current development +line and carry all of the performance and grammar work described below. The upstream +`com.github.jsqlparser` release on Maven Central is considerably older. + +```xml + + com.manticore-projects.jsqlformatter + jsqlparser + [5.3.218,) + ``` -* partially support SQL Server 2012 and Oracle 12c OFFSET ... FETCH ... +```gradle +implementation("com.manticore-projects.jsqlformatter:jsqlparser:+") +``` -## Extensions of JSqlParser releases +
+Upstream release and snapshots -* [Release Notes](https://github.com/JSQLParser/JSqlParser/releases) -* Modifications before GitHubs release tagging are listed in the [Older Releases](https://github.com/JSQLParser/JSqlParser/wiki/Older-Releases) page. +```xml + + com.github.jsqlparser + jsqlparser + 5.3 + +``` +Snapshot coordinates and repository setup are on the +[build dependencies page](https://jsqlparser.github.io/JSqlParser/usage.html#build-dependencies). +
-## BUILDING from the sources +## Performance -As the project is a Maven project, building is rather simple by running: +**11× faster than 5.3**, and the fastest parser on real-world SQL of any of the parsers +tested, in any language — 19× ahead of `sqlglot[c]` on JSqlParser's own `SELECT` test suite. And the community kept sending performance improvements since. Thank you everyone! - mvn package +
+ + SQL parser benchmark score + +
-This will produce the jsqlparser-VERSION.jar file in the target/ directory. +```text +Benchmark (version) Mode Cnt Score Error Units +JSQLParserBenchmark.parseSQLStatements latest avgt 15 21.138 ± 0.557 ms/op <-- Community sponsored improvements! +JSQLParserBenchmark.parseSQLStatements 5.4 avgt 15 32.528 ± 0.666 ms/op +JSQLParserBenchmark.parseSQLStatements 5.3 avgt 15 983.459 ± 8.197 ms/op +JSQLParserBenchmark.parseSQLStatements 5.1 avgt 15 319.601 ± 4.081 ms/op +``` -## Maven Repository +Methodology and the full cross-parser comparison against SQLGlot, `sqlglot[c]` and +polyglot-sql: **[jsqlparser-bench](https://github.com/manticore-projects/jsqlparser-bench)**. -JSQLParser is deployed at sonatypes open source maven repository. -Starting from now I will deploy there. The first snapshot version there will be 0.8.5-SNAPSHOT. -To use it this is the repository configuration: +## What it parses -```xml - - - jsqlparser-snapshots - - true - - https://oss.sonatype.org/content/groups/public/ - - +JSqlParser targets the SQL standard plus all major RDBMS. One grammar covers all of them, +and missing syntax gets added on demand — [open an issue](https://github.com/JSQLParser/JSqlParser/issues). + +
+ +`BigQuery` · `Snowflake` · `DuckDB` · `Redshift` · `Oracle` · `MS SQL Server` · `Sybase` +`PostgreSQL` · `MySQL` · `MariaDB` · `DB2` · `H2` · `HSQLDB` · `Derby` · `SQLite` + +
+ +| | Statements | +|---|---| +| **Queries** | `SELECT` · `WITH …` · Piped SQL | +| **ksqlDB windows** | JOIN `WITHIN`, window `GRACE PERIOD`, and `EMIT CHANGES`/`FINAL` | +| **ClickHouse column selection** | `COLUMNS('regexp')` select items with chained `APPLY`, `EXCEPT`, and `REPLACE` transformers | +| **DML** | `INSERT` · `UPDATE` · `UPSERT` · `MERGE` · `DELETE` · `TRUNCATE TABLE` | +| **Oracle RETURNING** | Named output binds (`INTO :name`), JDBC output parameters (`INTO ?`), and `BULK COLLECT INTO` | +| **DDL** | `CREATE …` · `ALTER …` · `DROP …` | +| **Oracle vector types** | `VECTOR(*, *)` · `VECTOR(*, FLOAT32)` · `VECTOR(3, *)`, including dense and sparse storage formats | +| **PostgreSQL ownership** | `DROP OWNED` · `REASSIGN OWNED` | +| **Two-phase commit** | PostgreSQL `PREPARE TRANSACTION` · `COMMIT PREPARED` · `ROLLBACK PREPARED` · MySQL `XA START`/`END`/`PREPARE`/`COMMIT`/`ROLLBACK`/`RECOVER` | +| **PostgreSQL maintenance** | `VACUUM` · `ANALYZE` · `CLUSTER` · `CHECKPOINT` | +| **PostgreSQL session statements** | `DISCARD` · `LISTEN` · `UNLISTEN` · `SHOW`/`RESET TIME ZONE`/`TRANSACTION ISOLATION LEVEL`/`SESSION AUTHORIZATION` · `COPY` options from before 9.0 | +| **PostgreSQL foreign schema import** | `IMPORT FOREIGN SCHEMA … [LIMIT TO \| EXCEPT (…)] FROM SERVER … INTO … [OPTIONS (…)]` | +| **PostgreSQL table and index options** | Bare `CAST`/`EXTRACT` keys with `Dialect.POSTGRESQL` · either order of HASH partition bound options · identity sequence `LOGGED`/`UNLOGGED` | +| **PostgreSQL cursors** | `DECLARE … CURSOR` · `FETCH` · `MOVE` · `CLOSE` | +| **PostgreSQL RLS** | `CREATE POLICY` · `ALTER TABLE … ENABLE`/`DISABLE`/`FORCE`/`NO FORCE ROW LEVEL SECURITY` | +| **MySQL table maintenance** | `ANALYZE` · `CHECK` · `CHECKSUM` · `OPTIMIZE` · `REPAIR TABLE` | +| **MySQL locks** | `LOCK TABLES` · `UNLOCK TABLES` · `LOCK INSTANCE FOR BACKUP` · `UNLOCK INSTANCE` | +| **MySQL resource groups** | `CREATE`/`ALTER`/`DROP RESOURCE GROUP` · `SET RESOURCE GROUP` | +| **MySQL mixed ADD groups** | `ALTER TABLE … ADD [COLUMN] (columns, indexes, constraints)` | +| **MySQL loadable functions** | `CREATE [AGGREGATE] FUNCTION … RETURNS … SONAME` | +| **MySQL servers, plugins and components** | `CREATE SERVER` · `ALTER SERVER` with `OPTIONS (… PORT 3306)` · `INSTALL`/`UNINSTALL PLUGIN` · `INSTALL`/`UNINSTALL COMPONENT` | +| **MySQL server administration** | `FLUSH` · `KILL` · `RESET PERSIST` · `HANDLER … OPEN`/`READ`/`CLOSE` | +| **MySQL replication** | `CHANGE REPLICATION SOURCE TO` · `CHANGE REPLICATION FILTER` · `START`/`STOP REPLICA` · `RESET REPLICA` · `RESET BINARY LOGS AND GTIDS` · `PURGE BINARY LOGS` | +| **MySQL data loading** | `LOAD DATA` · `LOAD XML` · `SELECT … INTO OUTFILE` with the same `FIELDS` and `LINES` clauses | +| **MySQL account management** | `CREATE`/`ALTER`/`RENAME USER` · `CREATE ROLE` · `SET ROLE` · `SET DEFAULT ROLE` · `SET PASSWORD` | +| **Tablespaces** | MySQL and PostgreSQL `CREATE TABLESPACE` · `ALTER TABLESPACE` | +| **MySQL spatial reference systems and instance** | `CREATE`/`DROP SPATIAL REFERENCE SYSTEM` · `ALTER INSTANCE` | +| **Routine changes** | `ALTER FUNCTION` · `ALTER PROCEDURE` · `ALTER ROUTINE` · PostgreSQL `ALTER TRIGGER` | +| **MySQL metadata statements** | `SHOW [FULL] COLUMNS`/`FIELDS` · `SHOW INDEX`/`INDEXES`/`KEYS` · `SHOW TABLE STATUS` · `SHOW CREATE TABLE`/`VIEW`/`PROCEDURE`/`FUNCTION`/`TRIGGER`/`EVENT`/`DATABASE`/`USER` · `SHOW [GLOBAL | SESSION] VARIABLES`/`STATUS` · `SHOW [FULL] PROCESSLIST` · `SHOW GRANTS [FOR …]` · `SHOW WARNINGS`/`ERRORS` · `SHOW BINARY LOGS`/`BINLOG EVENTS`/`RELAYLOG EVENTS` · `SHOW ENGINE …` · `SHOW PROFILE` · `SHOW DATABASES`/`TRIGGERS`/`EVENTS`/`OPEN TABLES`/`CHARACTER SET`/`COLLATION` · `SHOW PROCEDURE`/`FUNCTION STATUS`/`CODE` · `SHOW REPLICA STATUS`/`REPLICAS` | +| **MySQL utility statements** | `EXPLAIN`/`DESCRIBE [ANALYZE] FORMAT = …` · `EXPLAIN FOR CONNECTION` · `DESCRIBE t col` · `PREPARE … FROM` · `EXECUTE … USING` · `DROP PREPARE` · `DO` | +| **PostgreSQL administration** | `CREATE`/`ALTER EVENT TRIGGER` · `REINDEX` · `SECURITY LABEL` | +| **PostgreSQL types and rules** | `CREATE TYPE` (shell, composite, enum, range and base types) · `ALTER TYPE` · `CREATE RULE` · `ALTER RULE` | +| **PostgreSQL casts, transforms and conversions** | `CREATE CAST` · `DROP CAST` · `CREATE [OR REPLACE] TRANSFORM` · `DROP TRANSFORM` · `CREATE [DEFAULT] CONVERSION` · `ALTER CONVERSION` | +| **PostgreSQL metadata objects** | `CREATE`/`ALTER [PROCEDURAL] LANGUAGE` · `ALTER LARGE OBJECT … OWNER TO` · `CREATE`/`ALTER TEXT SEARCH DICTIONARY` · `CREATE`/`ALTER TEXT SEARCH PARSER` · `CREATE`/`ALTER TEXT SEARCH TEMPLATE` | +| **PostgreSQL operators and aggregates** | `CREATE`/`ALTER OPERATOR` · `CREATE`/`ALTER OPERATOR CLASS` · `CREATE`/`ALTER OPERATOR FAMILY` · `CREATE`/`ALTER AGGREGATE` | +| **Informix constraints** | `ALTER TABLE … ADD CONSTRAINT` with trailing constraint names for primary, unique, foreign and check constraints; enable with `parser.withDialect(Dialect.INFORMIX)` | +| **Salesforce SOQL** | `INCLUDES` · `EXCLUDES` | + +Beyond statement shapes, the grammar handles nested sub-selects, bind parameters (`?`, +`:name`), window and analytic functions, Oracle hints, and the T-SQL square-bracket versus +array-literal ambiguity. The complete reference is on the +[syntax page](https://jsqlparser.github.io/JSqlParser/syntax.html). + +PostgreSQL dollar-quoted strings, including `$tag$…$tag$`, retain their delimiter and +literal body in `StringValue`. Tagged quotes are disabled by default to preserve +identifier parsing. Enable them with `parser.withDialect(Dialect.POSTGRESQL)` or +`parser.withDollarQuotedStringTags(true)`. Untagged `$$…$$` literals remain enabled. + +## Statement classification + +Any parsed statement can say what it actually does — no second parse, no visitor to write: + +```java +StatementFeatures features = CCJSqlParserUtil.parse(sqlStr).getFeatures(); + +// safeguard a read-only client before anything reaches the database +if (connection.isReadOnly() && features.mayModifyData()) { + throw new SQLException("rejected: " + features.getUnresolvedReferences()); +} + +// dispatch correctly +if (features.returnsResultSet()) { statement.executeQuery(sqlStr); } +else { statement.executeUpdate(sqlStr); } ``` -This repositories releases will be synched to maven central. Snapshots remain at sonatype. -And this is the dependency declaration in your pom: -```xml - - com.github.jsqlparser - jsqlparser - 0.9 - +This is not `sqlStr.startsWith("SELECT")` with extra steps. `RETURNING` turns DML into a row +source, a data-modifying CTE hides a `DELETE` inside a `SELECT`, and `INSERT INTO x SELECT ..` +contains a query but returns nothing: + +| SQL | returns rows | modifies data | +|---|---|---| +| `SELECT * FROM t` | yes | no | +| `INSERT INTO x SELECT * FROM t` | no | yes | +| `DELETE FROM t RETURNING *` | yes | yes | +| `WITH c AS (DELETE FROM t RETURNING *) SELECT * FROM c` | yes | yes | +| `SELECT nextval('s')` | yes | *unproven* | + +Features are not mutually exclusive, and each is three-valued: proven, not excludable, or ruled +out. `is()` answers "did the grammar prove it", `may()` answers "could it be ruled out" — so a +guard uses `may()` and a dispatcher uses `is()`. Function volatility is not a syntactic property, +so anything the caller has not declared pure stays unproven and is listed by name. + +Legacy MySQL `GROUP BY ... ASC/DESC` is available with `Dialect.MYSQL` and the explicit +`withLegacyMySqlGroupBy(true)` option; modern/default parsing keeps it disabled. + +## Piped SQL + +Support is progressing for Piped SQL, which writes queries in the order they actually +execute rather than the order SQL historically demanded. + +```sql +FROM Produce +|> WHERE + item != 'bananas' + AND category IN ('fruit', 'nut') +|> AGGREGATE COUNT(*) AS num_items, SUM(sales) AS total_sales + GROUP BY item +|> ORDER BY item DESC; ``` +Background reading: the [Google research paper](https://storage.googleapis.com/gweb-research2023-media/pubtools/1004848.pdf), +[BigQuery pipe syntax](https://cloud.google.com/bigquery/docs/reference/standard-sql/pipe-syntax) +and [DuckDB FROM-first syntax](https://duckdb.org/docs/sql/query_syntax/from.html#from-first-syntax). + +ODBC `{fn TIMESTAMPADD(...)}` and `{fn TIMESTAMPDIFF(...)}` expose standard +`SQL_TSI_*` interval arguments as time-unit expressions, preserving column traversal. + +## Java version + +| JSqlParser | Runtime | Notes | +|------------|---------|-------| +| 4.9 | JDK 8 | last JDK 8 compatible release | +| 5.0 and later | JDK 11 | breaking changes to the AST Visitors, see the Migration Guide | +| 5.1 and later | JDK 11 | building requires a **JDK 17 toolchain** (plugin requirement) | +| 5.4 and later | JDK 11 | parser generated with **JavaCC 8** | + +## Sister projects + +- **[JSQLFormatter](https://manticore-projects.com/JSQLFormatter/index.html)** — pretty-printing and formatting of SQL text +- **[JSQLTranspiler](https://manticore-projects.com/JSQLTranspiler/index.html)** — dialect-specific rewriting, column resolution and lineage, by [Starlake.ai](https://starlake.ai/) + +## Alternatives + +The dual-licensed [JOOQ](https://www.jooq.org/doc/latest/manual/sql-building/sql-parser/) +ships a hand-written parser with broad RDBMS support, cross-dialect translation, SQL +transformation, and a JDBC proxy mode. Worth a look if translation between dialects is your +primary need rather than AST access. + +## Sponsor + +A huge thank you to **[Starlake.ai](https://starlake.ai/)**, who simplify data ingestion, +transformation and orchestration for faster delivery of high-quality data. Starlake has been +instrumental in providing Piped SQL support and a large number of test cases for BigQuery, +Redshift, Databricks and DuckDB. If JSqlParser is useful to you, visit +[Starlake.ai](https://starlake.ai/) and give them a star. + +## Documentation + +1. [Samples](https://jsqlparser.github.io/JSqlParser/usage.html#parse-a-sql-statements) +2. [Build instructions](https://jsqlparser.github.io/JSqlParser/usage.html) and [Maven artifact](https://jsqlparser.github.io/JSqlParser/usage.html#build-dependencies) +3. [Contribution guide](https://jsqlparser.github.io/JSqlParser/contribution.html) +4. [Change log](https://jsqlparser.github.io/JSqlParser/changelog.html#latest-changes-since-jsqlparser-version) +5. [Issues](https://github.com/JSQLParser/JSqlParser/issues) + +## License + +Dual licensed under **LGPL 2.1** or the **Apache License, Version 2.0**. Take your pick. diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000000..d3d57be1d4 --- /dev/null +++ b/build.gradle @@ -0,0 +1,860 @@ +import se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask +import com.nwalsh.gradle.saxon.SaxonXsltTask + +import java.time.Instant + +buildscript { + dependencies { + classpath group: 'net.sf.saxon', name: 'Saxon-HE', version: 'latest.release' + } +} + +plugins { + id 'java' + id "com.vanniktech.maven.publish" version "latest.release" + id 'maven-publish' + id 'signing' + + id "org.javacc.javacc" version "latest.release" + id 'jacoco' + id 'com.github.kt3k.coveralls' version "latest.release" + id "com.github.spotbugs" version "latest.release" + id "com.diffplug.spotless" version "latest.release" + id 'pmd' + id 'checkstyle' + id 'eclipse' + + // download the RR tools which have no Maven Repository + id "de.undercouch.download" version "latest.release" + id 'org.hidetake.ssh' version "latest.release" + + id "se.bjurr.gitchangelog.git-changelog-gradle-plugin" version "latest.release" + id "me.champeau.jmh" version "latest.release" + id "com.nwalsh.gradle.saxon.saxon-gradle" version "latest.release" + id 'biz.aQute.bnd.builder' version "latest.release" +} + +def getVersion = { boolean considerSnapshot -> + Integer major = 0 + Integer minor = 0 + Integer patch = null + Integer build = null + String commit = null + String snapshot = "" + + def versionStr = providers.exec { + commandLine "git", "--no-pager", "-C", project.projectDir, "describe", "--tags", "--always", "--dirty=-SNAPSHOT" + }.standardOutput.asText.get().trim() + + def pattern = /jsqlparser-(?\d*)\.(?\d*)(\.(?\d*))?(-(?\d*)-(?[a-zA-Z\d]*))?/ + def matcher = versionStr =~ pattern + + if (matcher.find()) { + major = matcher.group('major') as Integer ?: 0 + minor = matcher.group('minor') as Integer ?: 0 + patch = matcher.group('patch') as Integer ?: null + build = matcher.group('build') as Integer ?: null + commit = matcher.group('commit') ?: null + } + + if (considerSnapshot && (versionStr.endsWith('SNAPSHOT') || build != null)) { + minor++ + if (patch != null) patch = 0 + snapshot = "-SNAPSHOT" + } + + return "${major}.${minor}" + + (patch != null ? ".${patch}" : "") + + (build != null ? ".${build}" : "") + + snapshot +} + + +// for publishing a release, call Gradle with Environment Variable RELEASE: +// RELEASE=true gradle JSQLParser:publish +version = getVersion( !System.getenv("RELEASE") ) +group = 'com.manticore-projects.jsqlformatter' +description = 'JSQLParser library' + +tasks.register('generateBuildInfo') { + outputs.dir layout.buildDirectory.file("resources/main") + doLast { + def outputDir = new File( layout.buildDirectory.file("generated/sources/buildinfo/java/main").get().asFile, "net/sf/jsqlparser") + outputDir.mkdirs() + + def gitVersionStr = providers.exec { + commandLine "git", "--no-pager", "-C", project.projectDir, "describe", "--tags", "--always", "--dirty=-SNAPSHOT" + }.standardOutput.asText.get().trim() + + def gitCommitStr = providers.exec { + commandLine "git", "--no-pager", "-C", project.projectDir, "rev-parse", "--short", "HEAD" + }.standardOutput.asText.get().trim() + + def buildTime = Instant.now().toString() + + def content = """\ + |package net.sf.jsqlparser; + | + |public final class BuildInfo { + | public static final String NAME = "${project.name}"; + | public static final String VERSION = "${gitVersionStr}"; + | public static final String GIT_COMMIT = "${gitCommitStr ?: 'unknown'}"; + | public static final String BUILD_TIME = "${buildTime}"; + |} + """.stripMargin() + + new File(outputDir, "BuildInfo.java").text = content + } +} + +// Make sure the file is included in the compiled sources +sourceSets { + main { + java { + srcDir layout.buildDirectory.file("generated/sources/buildinfo/java/main").get().asFile + } + } +} + +tasks.withType(JavaCompile).configureEach { + mustRunAfter("generateBuildInfo") +} + +tasks.withType(Pmd).configureEach { + mustRunAfter("generateBuildInfo") +} + +tasks.withType(Checkstyle).configureEach { + exclude '**/module-info.java', '**/package-info.java' + + mustRunAfter("generateBuildInfo") +} + +repositories { + mavenCentral() + maven { url "https://dev.saxonica.com/maven" } +} + +configurations { + xmlDoclet +} + +dependencies { + testImplementation 'commons-io:commons-io:2.+' + testImplementation 'org.apache.commons:commons-text:+' + testImplementation 'org.mockito:mockito-core:+' + testImplementation 'org.assertj:assertj-core:+' + testImplementation 'org.hamcrest:hamcrest-core:+' + testImplementation 'org.apache.commons:commons-lang3:+' + testImplementation 'com.h2database:h2:+' + + // for JaCoCo Reports + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.+' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.+' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.+' + testImplementation 'org.junit.jupiter:junit-jupiter-params:5+' + + // https://mvnrepository.com/artifact/org.mockito/mockito-junit-jupiter + testImplementation 'org.mockito:mockito-junit-jupiter:5.+' + + // Performance Benchmark + testImplementation 'org.openjdk.jmh:jmh-core:+' + testImplementation 'org.openjdk.jmh:jmh-generator-annprocess:+' + + // Java Doc in XML Format + xmlDoclet ('com.manticore-projects.tools:xml-doclet:+'){ changing = true } + + // enforce latest version of JavaCC + testImplementation('com.manticore-projects.jsqlformatter:javacc-core:[8.1.4.1944,)') + testImplementation('com.manticore-projects.jsqlformatter:javacc-java:[8.1.4.1944,)') + + jmh 'org.openjdk.jmh:jmh-core:+' + jmh 'org.openjdk.jmh:jmh-generator-annprocess:+' + javacc('com.manticore-projects.jsqlformatter:javacc-core:[8.1.4.1944,)') + javacc('com.manticore-projects.jsqlformatter:javacc-java:[8.1.4.1944,)') +} + +compileJavacc { + arguments = [ + grammar_encoding: 'UTF-8', + static: 'false', + java_template_type: 'modern', + // Comment this in to build the parser with tracing. + DEBUG_PARSER: 'false', + DEBUG_LOOKAHEAD: 'false', + LEGACY_EXCEPTION_HANDLING: 'false' + ] +} + +java { + withSourcesJar() + // withJavadocJar() + + sourceCompatibility = '11' + targetCompatibility = '11' + + // needed for XML-Doclet to work (since Doclet changed again with Java 13) + toolchain { + languageVersion.set(JavaLanguageVersion.of(17)) + } +} + +javadoc { + include("build/generated/javacc/net/sf/jsqlparser/parser/*.java" ) + if(JavaVersion.current().isJava9Compatible()) { + options.addBooleanOption('html5', true) + } + options.addBooleanOption("Xdoclint:none", true) +} + +jar { + manifest { + attributes ( + "Automatic-Module-Name": "net.sf.jsqlparser" + ) + } + + bundle { + properties.empty() + bnd( + "Created-By": System.properties.get('user.name'), + "Bundle-SymbolicName": "net.sf.jsqlparser", + "Import-Package": "*", + "Export-Package": "net.sf.jsqlparser.*", + "Automatic-Module-Name": "net.sf.jsqlparser" + ) + } + + dependsOn(generateBuildInfo) +} + +tasks.register('xmldoc', Javadoc) { + dependsOn(compileJavacc) + + def outFile = reporting.file( + version.endsWith("-SNAPSHOT") + ? "xmlDoclet/javadoc_snapshot.xml" + : "xmlDoclet/javadoc_stable.xml" + ) + + source = sourceSets.main.allJava + // add any generated Java sources + source += fileTree(layout.buildDirectory.dir("generated/javacc").get().asFile) { + include '**/*.java' + } + source += fileTree(layout.buildDirectory.dir("generated/jjtree").get().asFile) { + include '**/*.java' + } + + classpath = sourceSets.main.runtimeClasspath + + destinationDir = reporting.file("xmlDoclet") + options.docletpath = configurations.xmlDoclet.files as List + options.doclet = "com.manticore.tools.xmldoclet.XmlDoclet" + title = "API $version" + + options.addStringOption("basePackage", "net.sf.jsqlparser") + options.addStringOption("filename", outFile.getName()) + + doLast { + copy { + from outFile + into layout.projectDirectory.dir("src/site/sphinx/").asFile + } + } +} + +test { + environment = [ 'EXPORT_TEST_TO_FILE': 'False' ] + useJUnitPlatform() + + // set heap size for the test JVM(s) + minHeapSize = "1G" + maxHeapSize = "4G" + + // set JVM stack size + jvmArgs = ['-Xss4m', '--add-opens=java.base/java.lang=ALL-UNNAMED'] + + jacoco { + // the generated parser exceeds the constant-pool limit once instrumented (#2866) + excludes = ['net/sf/jsqlparser/parser/CCJSqlParserTokenManager', + 'net/sf/jsqlparser/parser/CCJSqlParser'] + } +} + +coveralls { + jacocoReportPath 'build/reports/jacoco/test/jacocoTestReport.xml' +} + +jacocoTestReport { + dependsOn test // tests are required to run before generating the report + reports { + xml.required = false + csv.required = false + html.outputLocation = layout.buildDirectory.dir('reports/jacoco') + } + // the classes that are not instrumented, see test.jacoco + afterEvaluate { + classDirectories.setFrom(files(classDirectories.files.collect { + fileTree(dir: it, exclude: [ + "**/parser/CCJSqlParserTokenManager.class", + "**/parser/CCJSqlParser.class" + ]) + })) + } +} +jacocoTestCoverageVerification { + // Jacoco can't handle the TokenManager and the generated parser classes + afterEvaluate { + classDirectories.setFrom(files(classDirectories.files.collect { + fileTree(dir: it, exclude: [ + "**/parser/CCJSqlParserTokenManager.class", + "**/parser/CCJSqlParser.class" + ]) + })) + } + violationRules { + rule { + //element = 'CLASS' + limit { + //@todo: temporarily reduced it 80%, we need to bring that back to 84% accepting the Keywords PR + minimum = 0.50 + } + excludes = [ + 'net.sf.jsqlparser.util.validation.*', + 'net.sf.jsqlparser.**.*Adapter', + 'net.sf.jsqlparser.parser.**' + ] + } + rule { + //element = 'CLASS' + limit { + counter = 'LINE' + value = 'MISSEDCOUNT' + + //@todo: temporarily increased to 7000, we need to bring that down to 5500 after accepting the Keywords PR + maximum = 20000 + } + excludes = [ + 'net.sf.jsqlparser.util.validation.*', + 'net.sf.jsqlparser.**.*Adapter', + 'net.sf.jsqlparser.parser.**' + ] + } +// rule { +// element = 'CLASS' +// limit { +// counter = 'LINE' +// value = 'MISSEDRATIO' +// maximum = 0.3 +// } +// excludes = [ +// 'net.sf.jsqlparser.util.validation.*', +// 'net.sf.jsqlparser.**.*Adapter', +// 'net.sf.jsqlparser.parser.**' +// ] +// } + } +} + +spotbugsMain { + reports { + html.required.set(true) + html.outputLocation.set( layout.buildDirectory.file("reports/spotbugs/main/spotbugs.html").get().asFile ) + html.stylesheet="fancy-hist.xsl" + } +} + + +spotbugs { + // fail only on P1 and without the net.sf.jsqlparser.parser.* + excludeFilter = file("config/spotbugs/spotBugsExcludeFilter.xml") +} + +// do not run over the test, although we should do that eventually +tasks.named('spotbugsTest').configure { + enabled = false +} + +pmd { + // later versions throw NPE + toolVersion = '7.17.0' + + consoleOutput = true + sourceSets = [sourceSets.main] + + // clear the ruleset in order to use configured rules only + ruleSets = [] + rulesMinimumPriority = 2 + ruleSetFiles = files("config/pmd/ruleset.xml") +} + +tasks.named('pmdMain').configure { + excludes = [ + "build/generated/*" + , "**/net/sf/jsqlparser/parser/SimpleCharStream.java" + ] +} + +checkstyle { + sourceSets = [sourceSets.main, sourceSets.test] + configFile = rootProject.file('config/checkstyle/checkstyle.xml') +} + +tasks.withType(Checkstyle).configureEach { + reports { + xml.required = false + html.required = true + } + excludes = [ + "**/module-info.java" + , "net/sf/jsqlparser/parser/SimpleCharStream.java" + ] +} + +spotless { + // optional: limit format enforcement to just the files changed by this feature branch + ratchetFrom 'origin/master' + + format 'misc', { + // define the files to apply `misc` to + target '*.rst', '*.md', '.gitignore' + + // define the steps to apply to those files + trimTrailingWhitespace() + leadingTabsToSpaces(4) + endWithNewline() + } + java { + leadingTabsToSpaces(4) + eclipse().configFile('config/formatter/eclipse-java-google-style.xml') + } +} + + +tasks.register('renderRR') { + dependsOn(compileJavacc) + + doLast { + def rrDir = layout.buildDirectory.dir("rr").get().asFile + + // Download convert.war + download.run { + src 'http://manticore-projects.com/download/convert.war' + dest new File(rrDir, "convert.war") + overwrite false + onlyIfModified true + } + + // Download rr.war + download.run { + src 'http://manticore-projects.com/download/rr.war' + dest new File(rrDir, "rr.war") + overwrite false + onlyIfModified true + tempAndMove true + } + + // Convert JJ file to EBNF + def ebnfFile = new File(rrDir, "JSqlParserCC.ebnf") + def jjFile = layout.buildDirectory.dir("generated/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jj").get().asFile.absolutePath + + def convertProc = new ProcessBuilder('java', + '-Djdk.xml.maxElementDepth=0', + '-jar', + new File(rrDir, "convert.war").absolutePath, + jjFile) + .redirectOutput(ebnfFile) + .redirectErrorStream(true) + .start() + if (convertProc.waitFor() != 0) { + throw new GradleException("Failed to convert JJ to EBNF") + } + + // Generate RR diagrams + def rrProc = new ProcessBuilder('java', '-jar', + new File(rrDir, "rr.war").absolutePath, + "-noepsilon", + "-color:#4D88FF", + "-offset:0", + "-width:800", + "-out:${new File(rrDir, "JSqlParserCC.xhtml")}", + new File(rrDir, "JSqlParserCC.ebnf").absolutePath) + .redirectErrorStream(true) + .start() + rrProc.inputStream.eachLine { logger.info(it) } + if (rrProc.waitFor() != 0) { + throw new GradleException("Failed to generate RR diagrams") + } + } +} + + +tasks.register('gitChangelogTask', GitChangelogTask) { + fromRepo.set( file("$projectDir").toString() ) + file.set( new File("${projectDir}/src/site/sphinx/changelog.rst") ) + fromRevision.set( "4.0") + //toRef = "1.1"; + + // switch off the formatter since the indentation matters for Mark-down + // @formatter:off + templateContent.set (""" +************************ +Changelog +************************ + + +{{#tags}} +{{#ifMatches name "^Unreleased.*"}} +Latest Changes since |JSQLPARSER_VERSION| +{{/ifMatches}} +{{#ifMatches name "^(?!Unreleased).*"}} +Version {{name}} +{{/ifMatches}} +============================================================= + + {{#issues}} + + {{#commits}} + {{#ifMatches messageTitle "^(?!Merge).*"}} + * **{{{messageTitle}}}** + + {{authorName}}, {{commitDate}} + {{/ifMatches}} + {{/commits}} + + {{/issues}} +{{/tags}} +""") + // @formatter:on +} + +tasks.register('updateKeywords', JavaExec) { + group = "Execution" + description = "Generate the Reserved Keywords documentation" + classpath = sourceSets.main.runtimeClasspath + args = [ + file('src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt').absolutePath + , file('src/site/sphinx/keywords.rst').absolutePath + ] + mainClass.set("net.sf.jsqlparser.parser.ParserKeywordsUtils") + + dependsOn(compileJava) +} + +tasks.register('xslt', SaxonXsltTask) { + def outFile = version.endsWith("-SNAPSHOT") + ? file("src/site/sphinx/syntax_snapshot.rst") + : file("src/site/sphinx/syntax_stable.rst") + + dependsOn(renderRR) + stylesheet file('src/main/resources/rr/xhtml2rst.xsl') + + parameters( + "withFloatingToc": System.getProperty("FLOATING_TOC", "false"), + "isSnapshot": Boolean.toString(version.endsWith("-SNAPSHOT")) + ) + + // Transform every .xml file in the "input" directory. + input layout.buildDirectory.file("rr/JSqlParserCC.xhtml").get() + output outFile +} + +tasks.register('sphinx', Exec) { + dependsOn(gitChangelogTask, renderRR, xslt, xmldoc) + + String PROLOG = """ +.. |_| unicode:: U+00A0 + :trim: + +.. |JSQLPARSER_EMAIL| replace:: support@manticore-projects.com +.. |JSQLPARSER_VERSION| replace:: ${getVersion(false)} +.. |JSQLPARSER_SNAPSHOT_VERSION| replace:: ${getVersion(true)} +.. |JSQLPARSER_STABLE_VERSION_LINK| raw:: html + + ${project.name}-${getVersion(false)}.jar + +.. |JSQLPARSER_SNAPSHOT_VERSION_LINK| raw:: html + + ${project.name}-${getVersion(true)}.jar + +""" + + args = [ + "-Dproject=JSQLParser" + , "-Dcopyright=Tobias Warneke, 2022" + , "-Dauthor=Tobias Warneke" + , "-Drelease=${getVersion(false)}" + , "-Drst_prolog=$PROLOG" + , "${projectDir}/src/site/sphinx" + , layout.buildDirectory.file("sphinx").get().asFile + ] + + executable "sphinx-build" + + //store the output instead of printing to the console: + standardOutput = new ByteArrayOutputStream() + + //extension method stopTomcat.output() can be used to obtain the output: + ext.output = { + return standardOutput.toString() + } +} + +// `publish` is Gradle's own task; the Central Portal upload runs under `publishToMavenCentral`. +// Both need the same prerequisites, or a CI job invoking the latter silently skips check and docs. +tasks.matching { it.name in ['publish', 'publishToMavenCentral'] }.configureEach { + dependsOn(check, gitChangelogTask, renderRR, xslt, xmldoc) +} + +mavenPublishing { + publishToMavenCentral(true) + signAllPublications() + + coordinates(group, "jsqlparser", version) + + pom { + name.set('JSQLParser library') + description.set('Parse SQL Statements into Abstract Syntax Trees (AST)') + url.set('https://github.com/JSQLParser/JSqlParser') + + licenses { + license { + name.set('GNU Library or Lesser General Public License (LGPL) V2.1') + url.set('http://www.gnu.org/licenses/lgpl-2.1.html') + } + license { + name.set('The Apache Software License, Version 2.0') + url.set('http://www.apache.org/licenses/LICENSE-2.0.txt') + } + } + + developers { + developer { + id.set('twa') + name.set('Tobias Warneke') + email.set('t.warneke@gmx.net') + } + developer { + id.set('are') + name.set('Andreas Reichel') + email.set('andreas@manticore-projects.com') + } + } + + scm { + connection.set('scm:git:https://github.com/JSQLParser/JSqlParser.git') + developerConnection.set('scm:git:ssh://git@github.com:JSQLParser/JSqlParser.git') + url.set('https://github.com/JSQLParser/JSqlParser.git') + } + } +} + +// Signing and its task wiring are handled by mavenPublishing.signAllPublications() above. +// The manual `signing { required { ... hasTask("publish") } }` block that used to live here +// never matched the `publishToMavenCentral` task, so the two disagreed about whether to sign. + +tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' + + // javac's parser is recursive descent: one stack frame per level of nesting. The generated + // CCJSqlParser is nested deeply enough to exhaust the default thread stack, which surfaces as + // "An exception has occurred in the compiler ... java.lang.StackOverflowError" - a compiler + // crash, not a compile error, and not a bug worth reporting to Oracle. + // + // -Xss only takes effect at JVM launch, so the compiler has to run in its own process: + // setting forkOptions without options.fork = true silently does nothing. + options.fork = true + options.forkOptions.jvmArgs = (options.forkOptions.jvmArgs ?: []) + ['-Xss16m'] +} + +// javadoc parses the same sources in a forked process and hits the same wall +tasks.withType(Javadoc).configureEach { + options.setJFlags((options.getJFlags() ?: []) + ['-Xss16m']) +} + +remotes { + webServer { + host = findProperty("${project.name}.host") ?: "defaultHost" // Provide default if not found + user = findProperty("${project.name}.username") ?: "defaultUsername" // Provide default if not found + identity = file("${System.getProperty('user.home')}/.ssh/id_rsa") + } +} + + +tasks.register('upload') { + doFirst { + if (findProperty("${project.name}.host") == null) { + println( + """ + Property \"${project.name}.host\' not found. + Please define \"${project.name}.host\" in the Gradle configuration (e. g. \$HOME/.gradle/gradle.properties. + """ + ) + } + } + doLast { + ssh.run { + session(remotes.webServer) { + def versionStable = getVersion(false) + execute "mkdir -p download/${project.name}-${versionStable}" + for (File file: fileTree(include:['*.jar'], dir: layout.buildDirectory.dir("libs").get()).collect()) { + put from: file, into: "download/${project.name}-${versionStable}" + } + } + } + } + + dependsOn(check, assemble, gitChangelogTask, renderRR, xslt, xmldoc) +} + +check { + dependsOn jacocoTestCoverageVerification +} + +jmh { + jmhVersion = '1.37' + jvmArgs = [ + "--enable-native-access=ALL-UNNAMED" + , "--add-opens=java.base/sun.misc=ALL-UNNAMED" + , "--add-opens=java.base/java.lang=ALL-UNNAMED" + , "-XX:+UnlockDiagnosticVMOptions" + , "-XX:+DebugNonSafepoints" + ] + + // Profiling is opt-in because the native library path depends on the host. + profilers = providers.gradleProperty('jmhProfiler').map { [it] }.getOrElse([]) + + includes = ['.*JSQLParserBenchmark.*'] + warmupIterations = 2 + fork = 3 + iterations = 5 + timeOnIteration = '1s' +} + +// --------------------------------------------------------------------------------------------- +// Grammar ambiguity gate +// +// JavaCC reports choice conflicts as "Warning: ..." on stdout and still exits 0, so an ambiguity +// introduced by a PR is completely invisible to `./gradlew check`. The `org.javacc.javacc` plugin +// forwards that output to the Gradle logger, where it cannot be inspected either. +// +// This task therefore re-runs JavaCC on the JJTree output, into a throwaway directory, captures +// stdout+stderr and fails when any warning survives the allow list. +// --------------------------------------------------------------------------------------------- + +// Regexes for warnings that are known-benign. Add an entry ONLY together with a comment saying +// why. Never add a "Choice conflict" pattern here — that is the thing this gate exists to catch. +def grammarWarningAllowList = [ + // JJTree copies the options block into the .jj; re-passing -OUTPUT_DIRECTORY on the + // command line makes JavaCC complain that it overrides the in-file value. + ~/^Warning: .*Command line setting of .* modifies option value in file\./, + + // -OUTPUT_DIRECTORY points at a scratch directory that is wiped before every run, so + // JavaCC always announces that it is creating it. Housekeeping, not a grammar problem. + ~/^Warning: Output directory .* does not exist\. Creating the directory\./ +] + +def javaccMainClassOverride = project.findProperty('javaccMainClass') + +tasks.register('checkGrammarAmbiguity') { + group = 'verification' + description = 'Fails the build when JavaCC reports choice conflicts (grammar ambiguities).' + + dependsOn(compileJavacc) + + def jjFile = layout.buildDirectory + .file('generated/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jj') + def scratchDir = layout.buildDirectory.dir('grammar-check') + def reportFile = layout.buildDirectory.file('reports/grammar/javacc-warnings.txt') + def javaccClasspath = configurations.javacc + def allowList = grammarWarningAllowList + def mainClassOverride = javaccMainClassOverride + + inputs.file(jjFile) + inputs.files(javaccClasspath) + outputs.file(reportFile) + + doLast { + def jj = jjFile.get().asFile + if (!jj.exists()) { + throw new GradleException("Generated grammar not found: ${jj} — did compileJavacc run?") + } + + def out = scratchDir.get().asFile + out.deleteDir() + out.mkdirs() + + // JavaCC 8 splits into javacc-core / javacc-java; take Main-Class from whichever jar + // declares one, so this keeps working across upgrades of the Manticore JavaCC branch. + def mainClass = mainClassOverride ?: javaccClasspath.files.findResult { f -> + if (!f.name.endsWith('.jar')) { + return null + } + new java.util.jar.JarFile(f).withCloseable { jar -> + jar.manifest?.mainAttributes?.getValue('Main-Class') + } + } ?: 'org.javacc.parser.Main' + + def isWindows = System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('win') + def javaExe = new File(new File(System.getProperty('java.home'), 'bin'), + isWindows ? 'java.exe' : 'java') + + def proc = new ProcessBuilder( + javaExe.absolutePath, + '-cp', javaccClasspath.asPath, + mainClass.toString(), + '-GRAMMAR_ENCODING=UTF-8', + "-OUTPUT_DIRECTORY=${out.absolutePath}".toString(), + jj.absolutePath) + .directory(out) + .redirectErrorStream(true) + .start() + + def output = proc.inputStream.getText('UTF-8') + def exit = proc.waitFor() + + // Warnings are multi-line: a "Warning:" header followed by indented continuation lines. + def warnings = [] + def current = null + output.eachLine { line -> + if (line.startsWith('Warning:')) { + current = new StringBuilder(line) + warnings << current + } else if (current != null && line.startsWith(' ')) { + current.append('\n').append(line) + } else { + current = null + } + } + + def offending = warnings + .collect { it.toString() } + .findAll { w -> allowList.every { !(w =~ it) } } + + def report = reportFile.get().asFile + report.parentFile.mkdirs() + report.setText(offending.isEmpty() ? 'No JavaCC grammar warnings.\n' + : offending.join('\n\n') + '\n', 'UTF-8') + + if (exit != 0) { + logger.error(output) + throw new GradleException("JavaCC exited with ${exit} while analysing the grammar.") + } + + if (!offending.isEmpty()) { + def conflicts = offending.count { it.contains('Choice conflict') } + logger.error("\n${offending.join('\n\n')}\n") + throw new GradleException( + "${offending.size()} JavaCC grammar warning(s), ${conflicts} of them choice " + + "conflicts. Resolve the ambiguity or add an explicit LOOKAHEAD to the earlier " + + "expansion. Report: ${report}") + } + + logger.lifecycle('Grammar is free of JavaCC choice conflicts.') + } +} + +tasks.named('check') { + dependsOn('checkGrammarAmbiguity') +} diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 0000000000..c49a705024 --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/checkstyle/checkstyle_checks.xml b/config/checkstyle/checkstyle_checks.xml new file mode 100644 index 0000000000..708f38789a --- /dev/null +++ b/config/checkstyle/checkstyle_checks.xml @@ -0,0 +1,879 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/checkstyle/google_checks.xml b/config/checkstyle/google_checks.xml new file mode 100644 index 0000000000..153a045d61 --- /dev/null +++ b/config/checkstyle/google_checks.xml @@ -0,0 +1,358 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/checkstyle/sun_checks.xml b/config/checkstyle/sun_checks.xml new file mode 100644 index 0000000000..e5f5367da8 --- /dev/null +++ b/config/checkstyle/sun_checks.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml new file mode 100644 index 0000000000..b5ddce5877 --- /dev/null +++ b/config/checkstyle/suppressions.xml @@ -0,0 +1,659 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/formatter/eclipse-java-google-style.xml b/config/formatter/eclipse-java-google-style.xml new file mode 100644 index 0000000000..5f9965da0d --- /dev/null +++ b/config/formatter/eclipse-java-google-style.xml @@ -0,0 +1,337 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/pmd/ruleset.xml b/config/pmd/ruleset.xml new file mode 100644 index 0000000000..45804d4c0b --- /dev/null +++ b/config/pmd/ruleset.xml @@ -0,0 +1,114 @@ + + + + + + Custom PMD ruleset, compatible with PMD 7.x. + + Based on the old (pre PMD 6.0.0) rulesets java-basic, java-empty, java-imports, + java-unnecessary, java-unusedcode, migrated for PMD 7. + + This ruleset might be used as a starting point for an own customized ruleset [0]. + + [0] https://pmd.github.io/latest/pmd_userdocs_making_rulesets.html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/spotbugs/spotBugsExcludeFilter.xml b/config/spotbugs/spotBugsExcludeFilter.xml new file mode 100644 index 0000000000..14af0c11a0 --- /dev/null +++ b/config/spotbugs/spotBugsExcludeFilter.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000000..4df9d4bd05 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,17 @@ +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx8G -Xss16m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError + +org.gradle.caching=true + +# Modularise your project and enable parallel build +org.gradle.parallel=true + +# Enable configure on demand. +org.gradle.configureondemand=true + +# see https://docs.gradle.org/current/userguide/upgrading_version_8.html#xml_parsing_now_requires_recent_parsers +systemProp.javax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl +systemProp.javax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl +systemProp.javax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000..eddabd2eef Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..69dd0d0404 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,9 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.0-bin.zip +networkTimeout=10000 +retries=0 +retryBackOffMs=500 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000000..379a6582e2 --- /dev/null +++ b/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# gradlew start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh gradlew +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob//platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000000..a51ec4f588 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,82 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem gradlew startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:execute +@rem Setup the command line + + + +@rem Execute gradlew +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel + +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/nb-configuration.xml b/nb-configuration.xml index aef8ab1397..04d5801d39 100644 --- a/nb-configuration.xml +++ b/nb-configuration.xml @@ -14,6 +14,19 @@ Any value defined here will override the pom.xml file value but is only applicable to the current project. --> none - JDK_1.7 + false + true + LF + false + true + false + none + 4 + 4 + 4 + 120 + true + project + Temurin_11.0.32_9 diff --git a/nbactions.xml b/nbactions.xml index 4570638164..6522476ebe 100644 --- a/nbactions.xml +++ b/nbactions.xml @@ -12,4 +12,12 @@ true + + CUSTOM-clean deploy + clean deploy + + clean + deploy + + diff --git a/pom.xml b/pom.xml index 77a83cb173..172bc3eae7 100644 --- a/pom.xml +++ b/pom.xml @@ -1,305 +1,819 @@ + - 4.0.0 - com.github.jsqlparser - jsqlparser - 0.9.2-SNAPSHOT - JSQLParser library - 2004 - - JSQLParser - - jar - https://github.com/JSQLParser/JSqlParser - - - - GNU Library or Lesser General Public License (LGPL) V2.1 - http://www.gnu.org/licenses/lgpl-2.1.html - - - - - - junit - junit - 4.11 + 4.0.0 + + com.github.jsqlparser + jsqlparser + 5.5-SNAPSHOT + bundle + + JSQLParser library + JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes. + The generated hierarchy can be navigated using the Visitor Pattern. + https://github.com/JSQLParser/JSqlParser + 2004 + + + JSQLParser + + + + + GNU Library or Lesser General Public License (LGPL) V2.1 + http://www.gnu.org/licenses/lgpl-2.1.html + repo + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + Tobias Warneke + t.warneke@gmx.net + + + + + scm:git:https://github.com/JSQLParser/JSqlParser.git + scm:git:ssh://git@github.com:JSQLParser/JSqlParser.git + https://github.com/JSQLParser/JSqlParser.git + HEAD + + + + GitHub Issues + https://github.com/JSQLParser/JSqlParser/issues + + + + + + sonatype-nexus-snapshots + https://central.sonatype.com/repository/maven-snapshots/ + + false + + + true + + + + + + + 11 + [17,24) + IfMatch + + UTF-8 + UTF-8 + + + 2026-09-13T21:14:58Z + + + + + 3.3.0 + 3.6.3 + 3.15.0 + 3.5.0 + 3.5.0 + 3.1.4 + 3.1.4 + 3.22.0 + 3.4.0 + 3.12.0 + 3.5.6 + 3.3.1 + 3.2.8 + 3.28.0 + 3.6.0 + 3.6.0 + 3.9.0 + 5.1.8 + 3.6.0 + 3.5.0 + 2.0.0 + 3.8.0 + 0.8.15 + 3.8.0 + 4.9.3.0 + 0.10.0 + + + 7.17.0 + 10.23.1 + + + + [8.1.2.1941,) + 5.14.4 + 5.23.0 + 3.27.7 + 3.0 + 2.18.0 + 3.18.0 + 2.3.232 + 1.37 + + + f22e0543 + + + + + + org.junit + junit-bom + ${junit.version} + pom + import + + + + + + + com.manticore-projects.jsqlformatter + javacc-java + ${javacc.version} + test + + + com.manticore-projects.jsqlformatter + javacc-core + ${javacc.version} + test + + + commons-io + commons-io + ${commons-io.version} + test + + + org.junit.jupiter + junit-jupiter + test + + + org.mockito + mockito-core + ${mockito.version} + test + + + org.mockito + mockito-junit-jupiter + ${mockito.version} + test + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + test + + + com.h2database + h2 + ${h2.version} + test + + + + + org.hamcrest + hamcrest + ${hamcrest.version} + test + + + + + org.openjdk.jmh + jmh-core + ${jmh.version} test - - - commons-io - commons-io - 2.4 - test - - - - - - Tobias Warneke - t.warneke@gmx.net - - - - - - sonatype-nexus-staging - https://oss.sonatype.org/service/local/staging/deploy/maven2 - - - sonatype-nexus-snapshots - https://oss.sonatype.org/content/repositories/snapshots - - - - - scm:git:https://github.com/JSQLParser/JSqlParser.git - scm:git:ssh://git@github.com:JSQLParser/JSqlParser.git - https://github.com/JSQLParser/JSqlParser.git - HEAD - - - - GitHub Issues - https://github.com/JSQLParser/JSqlParser/issues - - - - - - maven-compiler-plugin - 3.1 - - 1.6 - 1.6 - true - ${project.build.sourceEncoding} - - - - org.codehaus.mojo - javacc-maven-plugin - 2.6 - - - javacc - generate-sources - - javacc - - - - - - net.java.dev.javacc - javacc - 6.1.2 - - - - - org.apache.maven.plugins - maven-eclipse-plugin - 2.9 - - - /target/generated-sources/javacc - - - - - org.apache.maven.plugins - maven-resources-plugin - 2.6 - - ${project.build.sourceEncoding} - - - - org.codehaus.mojo - license-maven-plugin - 1.6 - - false - false - false - - - - first - - update-file-header - - process-sources - - lgpl_v2_1 - - src/main/java - - - - - - - org.apache.maven.plugins - maven-release-plugin - 2.4.2 - - true - false - forked-path - - - - org.apache.maven.scm - maven-scm-provider-gitexe - 1.9 - - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - - attach-javadocs - - jar - - - - - - maven-site-plugin - 3.3 - - - attach-descriptor - - attach-descriptor - - - - - en - - - - - - - - - org.apache.maven.plugins - maven-surefire-report-plugin - 2.16 - - ${project.reporting.outputDirectory}/testresults - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - true - - - - html - - javadoc - - - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.7 - - - org.apache.maven.plugins - maven-jxr-plugin - 2.3 - - true - - - - org.codehaus.mojo - cobertura-maven-plugin - 2.6 - - true - %{project.reporting.outputDirectory}/cobertura - - - - org.codehaus.mojo - findbugs-maven-plugin - 2.5.3 - - - org.codehaus.mojo - javacc-maven-plugin - 2.6 - - - - - - - sign-release-artifacts - - - performRelease - true - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.4 - - - sign-artifacts - verify - - sign - - - f22e0543 - - - - - - - - - - - UTF-8 - - - - JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes. - The generated hierarchy can be navigated using the Visitor Pattern. - - + + + + + + + + + org.apache.maven.plugins + maven-clean-plugin + ${maven-clean-plugin.version} + + + org.apache.maven.plugins + maven-resources-plugin + ${maven-resources-plugin.version} + + + org.apache.maven.plugins + maven-install-plugin + ${maven-install-plugin.version} + + + org.apache.maven.plugins + maven-deploy-plugin + ${maven-deploy-plugin.version} + + + org.apache.maven.plugins + maven-site-plugin + ${maven-site-plugin.version} + + + + + + + + org.apache.maven.plugins + maven-toolchains-plugin + ${maven-toolchains-plugin.version} + + + select-jdk-toolchain + + select-jdk-toolchain + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + ${maven-enforcer-plugin.version} + + + enforce + validate + + enforce + + + + + [3.9.0,) + + + + + + + + + + + org.codehaus.mojo + exec-maven-plugin + ${exec-maven-plugin.version} + + net.sf.jsqlparser.parser.ParserKeywordsUtils + + src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt + src/site/sphinx/keywords.rst + + + + + + org.apache.maven.plugins + maven-pmd-plugin + ${maven-pmd-plugin.version} + + 2 + + + ${project.basedir}/config/pmd/ruleset.xml + + + **/*Bean.java + **/generated/*.java + **/net/sf/jsqlparser/parser/SimpleCharStream.java + + + ${project.build.directory}/generated-sources + ${project.build.directory}/generated-test-sources + + true + + + + pmd + process-sources + + check + + + + + + net.sourceforge.pmd + pmd-core + ${pmd.version} + + + net.sourceforge.pmd + pmd-java + ${pmd.version} + + + + + + org.codehaus.mojo + build-helper-maven-plugin + ${build-helper-maven-plugin.version} + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/generated-sources/javacc/ + ${project.build.directory}/generated-sources/jjtree/ + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.release} + ${project.build.sourceEncoding} + true + true + 2000m + + true + + -J-Xss4M + + + + + + default-testCompile + + testCompile + + + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} + + + + + + + + + org.javacc.plugin + javacc-maven-plugin + ${javacc-maven-plugin.version} + + + javacc + generate-sources + + jjtree-javacc + + + + + -CODE_GENERATOR:"Java" + -GRAMMAR_ENCODING:"UTF-8" + + + -GRAMMAR_ENCODING:"UTF-8" + -CODE_GENERATOR:"Java" + + + + + + + com.manticore-projects.jsqlformatter + javacc-java + ${javacc.version} + + + com.manticore-projects.jsqlformatter + javacc-core + ${javacc.version} + + + + + + org.codehaus.mojo + license-maven-plugin + ${license-maven-plugin.version} + + false + false + false + dual_lgpl_ap2 + ${project.baseUri}/src/license + + site/sphinx/** + + + + + update-file-header + process-sources + + update-file-header + + + + + + + org.apache.maven.plugins + maven-release-plugin + ${maven-release-plugin.version} + + true + false + forked-path + sign-release-artifacts + + + + + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin.version} + + + attach-sources + + jar-no-fork + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + attach-javadocs + + jar + + + net.sf.jsqlparser.parser + none + + true + true + 2g + 800m + + -J-Xss4m + + + + + + + + + org.apache.felix + maven-bundle-plugin + ${maven-bundle-plugin.version} + true + + + net.sf.jsqlparser + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + false + + false + + + + @{jacocoArgLine} + --add-opens=java.base/java.lang=ALL-UNNAMED + --add-opens=java.base/java.util=ALL-UNNAMED + -Xmx2G -Xms800m -Xss4m + -Dfile.encoding=UTF-8 + + + + + + org.jacoco + jacoco-maven-plugin + ${jacoco-maven-plugin.version} + + + prepare-agent + + prepare-agent + + + + jacocoArgLine + + + + report + prepare-package + + report + + + + + + + + com.diffplug.spotless + spotless-maven-plugin + ${spotless-maven-plugin.version} + + + origin/master + + + + *.md + .gitignore + + + + + true + 4 + + + + + + src/main/java/**/*.java + src/test/java/**/*.java + + + + + + config/formatter/eclipse-java-google-style.xml + + + + + + + + org.sonatype.central + central-publishing-maven-plugin + ${central-publishing-maven-plugin.version} + true + + sonatype-nexus + + + + + + + + + org.apache.maven.plugins + maven-surefire-report-plugin + ${maven-surefire-plugin.version} + + ${project.reporting.outputDirectory}/testresults + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + true + none + + true + 2g + 800m + + -J-Xss2m + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + ${maven-project-info-reports-plugin.version} + + + org.apache.maven.plugins + maven-jxr-plugin + ${maven-jxr-plugin.version} + + + com.github.spotbugs + spotbugs-maven-plugin + ${spotbugs-maven-plugin.version} + + + + + + + sign-release-artifacts + + + performRelease + true + + + + + + org.apache.maven.plugins + maven-gpg-plugin + ${maven-gpg-plugin.version} + + + sign-artifacts + verify + + sign + + + ${gpg.keyname} + + + --pinentry-mode + loopback + + + + + + + + + + + check.sources + + + !skipCheckSources + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + + verify-style + process-classes + + check + + + + + true + true + + ${project.build.sourceDirectory} + **/module-info.java,**/net/sf/jsqlparser/parser/SimpleCharStream.java + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + + + + + + + + skip.all + + true + true + true + true + true + + + + \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000000..d0322b0de5 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,5 @@ +/* + * This file was generated by the Gradle 'init' task. + */ + +rootProject.name = 'JSQLParser' diff --git a/src/license/dual_lgpl_ap2/header.txt b/src/license/dual_lgpl_ap2/header.txt new file mode 100644 index 0000000000..0dab25924a --- /dev/null +++ b/src/license/dual_lgpl_ap2/header.txt @@ -0,0 +1 @@ +Dual licensed under GNU LGPL 2.1 or Apache License 2.0 \ No newline at end of file diff --git a/src/license/dual_lgpl_ap2/license.txt b/src/license/dual_lgpl_ap2/license.txt new file mode 100644 index 0000000000..8a2d35be0d --- /dev/null +++ b/src/license/dual_lgpl_ap2/license.txt @@ -0,0 +1,710 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +(This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.) + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random + Hacker. + + {signature of Ty Coon}, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + +********************************************************************************************* + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/src/license/licenses.properties b/src/license/licenses.properties new file mode 100644 index 0000000000..dfdce951de --- /dev/null +++ b/src/license/licenses.properties @@ -0,0 +1,10 @@ +### +# #%L +# JSQLParser library +# %% +# Copyright (C) 2004 - 2019 JSQLParser +# %% +# Dual licensed under GNU LGPL 2.1 or Apache License 2.0 +# #L% +### +dual_lgpl_ap2=Dual License GNU LGPL 2.1 or Apache License 2.0 diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 0000000000..14ed418f03 --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,64 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2024 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +module net.sf.jsqlparser { + requires java.sql; + requires java.logging; + requires java.desktop; + + exports net.sf.jsqlparser; + exports net.sf.jsqlparser.expression; + exports net.sf.jsqlparser.expression.operators.arithmetic; + exports net.sf.jsqlparser.expression.operators.conditional; + exports net.sf.jsqlparser.expression.operators.relational; + exports net.sf.jsqlparser.parser; + exports net.sf.jsqlparser.parser.feature; + exports net.sf.jsqlparser.schema; + exports net.sf.jsqlparser.statement; + exports net.sf.jsqlparser.statement.alter; + exports net.sf.jsqlparser.statement.alter.sequence; + exports net.sf.jsqlparser.statement.analyze; + exports net.sf.jsqlparser.statement.comment; + exports net.sf.jsqlparser.statement.create.event; + exports net.sf.jsqlparser.statement.create.function; + exports net.sf.jsqlparser.statement.create.index; + exports net.sf.jsqlparser.statement.create.policy; + exports net.sf.jsqlparser.statement.create.procedure; + exports net.sf.jsqlparser.statement.create.schema; + exports net.sf.jsqlparser.statement.create.sequence; + exports net.sf.jsqlparser.statement.create.synonym; + exports net.sf.jsqlparser.statement.create.table; + exports net.sf.jsqlparser.statement.create.trigger; + exports net.sf.jsqlparser.statement.create.user; + exports net.sf.jsqlparser.statement.create.view; + exports net.sf.jsqlparser.statement.delete; + exports net.sf.jsqlparser.statement.drop; + exports net.sf.jsqlparser.statement.execute; + exports net.sf.jsqlparser.statement.export; + exports net.sf.jsqlparser.statement.grant; + exports net.sf.jsqlparser.statement.imprt; + exports net.sf.jsqlparser.statement.insert; + exports net.sf.jsqlparser.statement.lock; + exports net.sf.jsqlparser.statement.merge; + exports net.sf.jsqlparser.statement.piped; + exports net.sf.jsqlparser.statement.refresh; + exports net.sf.jsqlparser.statement.select; + exports net.sf.jsqlparser.statement.show; + exports net.sf.jsqlparser.statement.truncate; + exports net.sf.jsqlparser.statement.update; + exports net.sf.jsqlparser.statement.upsert; + exports net.sf.jsqlparser.util; + exports net.sf.jsqlparser.util.cnfexpression; + exports net.sf.jsqlparser.util.deparser; + exports net.sf.jsqlparser.util.validation; + exports net.sf.jsqlparser.util.validation.allowedtypes; + exports net.sf.jsqlparser.util.validation.feature; + exports net.sf.jsqlparser.util.validation.metadata; + exports net.sf.jsqlparser.util.validation.validator; +} diff --git a/src/main/java/net/sf/jsqlparser/JSQLParserException.java b/src/main/java/net/sf/jsqlparser/JSQLParserException.java index ee7b455402..d5ac694276 100644 --- a/src/main/java/net/sf/jsqlparser/JSQLParserException.java +++ b/src/main/java/net/sf/jsqlparser/JSQLParserException.java @@ -1,77 +1,32 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser; -/** - * An exception class with stack trace informations - */ public class JSQLParserException extends Exception { - /* The serial class version */ - private static final long serialVersionUID = -1099039459759769980L; - private Throwable cause = null; - - public JSQLParserException() { - super(); - } - - public JSQLParserException(String arg0) { - super(arg0); - } - - public JSQLParserException(Throwable arg0) { - this.cause = arg0; - } + private static final long serialVersionUID = -4200894355696788796L; - public JSQLParserException(String arg0, Throwable arg1) { - super(arg0); - this.cause = arg1; - } + public JSQLParserException() { + super(); + } - @Override - public Throwable getCause() { - return cause; - } + public JSQLParserException(String message, Throwable cause) { + super(message, cause); + } - @Override - public void printStackTrace() { - printStackTrace(System.err); - } + public JSQLParserException(String message) { + super(message); + } - @Override - public void printStackTrace(java.io.PrintWriter pw) { - super.printStackTrace(pw); - if (cause != null) { - pw.println("Caused by:"); - cause.printStackTrace(pw); - } - } + public JSQLParserException(Throwable cause) { + super(cause == null ? null : cause.getMessage(), cause); + } - @Override - public void printStackTrace(java.io.PrintStream ps) { - super.printStackTrace(ps); - if (cause != null) { - ps.println("Caused by:"); - cause.printStackTrace(ps); - } - } } diff --git a/src/main/java/net/sf/jsqlparser/Model.java b/src/main/java/net/sf/jsqlparser/Model.java new file mode 100644 index 0000000000..4ad52f4297 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/Model.java @@ -0,0 +1,24 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2020 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser; + +import java.io.Serializable; + +/** + *

+ * A marker interface for jsqlparser-model-classes. + *

+ *

+ * The datastructure where the sql syntax is represented by a tree consists of {@link Model}'s + *

+ */ +public interface Model extends Serializable { + +} diff --git a/src/main/java/net/sf/jsqlparser/expression/Alias.java b/src/main/java/net/sf/jsqlparser/expression/Alias.java index e9e7b2e8e5..ffc599680c 100644 --- a/src/main/java/net/sf/jsqlparser/expression/Alias.java +++ b/src/main/java/net/sf/jsqlparser/expression/Alias.java @@ -1,62 +1,150 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2014 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +import net.sf.jsqlparser.schema.MultiPartName; +import net.sf.jsqlparser.statement.create.table.ColDataType; + /** + * The type Alias for Tables, Columns or Views. * - * @author toben + * We support three different types: + * 1) Simple String: `SELECT 1 AS "ALIAS"` when NAME is set and aliasColumns has no elements + * 2) UDF Aliases: `SELECT udf(1,2,3) AS "Alias(a,b,c)"` " when NAME!=null and aliasColumns has elements + * 3) Column lists for LATERAL VIEW: `SELECT * from a LATERAL VIEW EXPLODE ... AS a, b, c`, when NAME is NULL and aliasColumns has elements + * @see Spark LATERAL VIEW */ -public class Alias { - - private String name; - private boolean useAs = true; - - public Alias(String name) { - this.name = name; - } - - public Alias(String name, boolean useAs) { - this.name = name; - this.useAs = useAs; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public boolean isUseAs() { - return useAs; - } - - public void setUseAs(boolean useAs) { - this.useAs = useAs; - } - - @Override - public String toString() { - return (useAs ? " AS " : " ") + name; - } +public class Alias implements Serializable { + + private String name; + private boolean useAs = true; + private List aliasColumns; + + public Alias(String name) { + this.name = name; + } + + public Alias(String name, boolean useAs) { + this.name = name; + this.useAs = useAs; + } + + public String getName() { + return name; + } + + public String getUnquotedName() { + return MultiPartName.unquote(name); + } + + public void setName(String name) { + this.name = name; + } + + public boolean isUseAs() { + return useAs; + } + + public void setUseAs(boolean useAs) { + this.useAs = useAs; + } + + public List getAliasColumns() { + return aliasColumns; + } + + public void setAliasColumns(List aliasColumns) { + this.aliasColumns = aliasColumns; + } + + @Override + public String toString() { + String alias = (useAs ? " AS " : " ") + (name != null ? name : ""); + + if (aliasColumns != null && !aliasColumns.isEmpty()) { + StringBuilder ac = new StringBuilder(); + for (AliasColumn col : aliasColumns) { + if (ac.length() > 0) { + ac.append(", "); + } + ac.append(col.name); + if (col.colDataType != null) { + ac.append(" ").append(col.colDataType); + } + } + alias += name != null ? "(" + ac + ")" : ac; + } + + return alias; + } + + public Alias withName(String name) { + this.setName(name); + return this; + } + + public Alias withUseAs(boolean useAs) { + this.setUseAs(useAs); + return this; + } + + public Alias withAliasColumns(List aliasColumns) { + this.setAliasColumns(aliasColumns); + return this; + } + + + public Alias addAliasColumns(String... columnNames) { + List collection = + Optional.ofNullable(getAliasColumns()).orElseGet(ArrayList::new); + for (String columnName : columnNames) { + collection.add(new AliasColumn(columnName)); + } + return this.withAliasColumns(collection); + } + + public Alias addAliasColumns(AliasColumn... aliasColumns) { + List collection = + Optional.ofNullable(getAliasColumns()).orElseGet(ArrayList::new); + Collections.addAll(collection, aliasColumns); + return this.withAliasColumns(collection); + } + + public Alias addAliasColumns(Collection aliasColumns) { + List collection = + Optional.ofNullable(getAliasColumns()).orElseGet(ArrayList::new); + collection.addAll(aliasColumns); + return this.withAliasColumns(collection); + } + + public static class AliasColumn implements Serializable { + + public final String name; + public final ColDataType colDataType; + + public AliasColumn(String name, ColDataType colDataType) { + Objects.requireNonNull(name); + this.name = name; + this.colDataType = colDataType; + } + + public AliasColumn(String name) { + this(name, null); + } + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/AliasedExpression.java b/src/main/java/net/sf/jsqlparser/expression/AliasedExpression.java new file mode 100644 index 0000000000..745cdf4259 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/AliasedExpression.java @@ -0,0 +1,59 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.function.Consumer; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** An expression with an alias, such as an XMLFOREST argument. */ +public class AliasedExpression extends ASTNodeAccessImpl implements Expression { + private Expression expression; + private Alias alias; + + public AliasedExpression(Expression expression, Alias alias) { + this.expression = expression; + this.alias = alias; + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + public Alias getAlias() { + return alias; + } + + public void setAlias(Alias alias) { + this.alias = alias; + } + + @Override + public T accept(ExpressionVisitor visitor, S context) { + return visitor.visit(this, context); + } + + public StringBuilder appendTo(StringBuilder builder, Consumer expressionPrinter) { + expressionPrinter.accept(expression); + if (alias != null) { + builder.append(alias); + } + return builder; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, builder::append).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/AllComparisonExpression.java b/src/main/java/net/sf/jsqlparser/expression/AllComparisonExpression.java deleted file mode 100644 index 109f371ce6..0000000000 --- a/src/main/java/net/sf/jsqlparser/expression/AllComparisonExpression.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * #%L - * JSQLParser library - * %% - * Copyright (C) 2004 - 2013 JSQLParser - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . - * #L% - */ -package net.sf.jsqlparser.expression; - -import net.sf.jsqlparser.statement.select.SubSelect; - -public class AllComparisonExpression implements Expression { - - private SubSelect subSelect; - - public AllComparisonExpression(SubSelect subSelect) { - this.subSelect = subSelect; - } - - public SubSelect getSubSelect() { - return subSelect; - } - - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } -} diff --git a/src/main/java/net/sf/jsqlparser/expression/AllValue.java b/src/main/java/net/sf/jsqlparser/expression/AllValue.java new file mode 100644 index 0000000000..14f924ab86 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/AllValue.java @@ -0,0 +1,25 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class AllValue extends ASTNodeAccessImpl implements Expression { + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + return "ALL"; + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/AnalyticExpression.java b/src/main/java/net/sf/jsqlparser/expression/AnalyticExpression.java index 74494af4d1..0f8f56dd65 100644 --- a/src/main/java/net/sf/jsqlparser/expression/AnalyticExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/AnalyticExpression.java @@ -1,99 +1,158 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; -import net.sf.jsqlparser.schema.Column; +import java.util.function.Consumer; +import java.util.Locale; +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.select.Limit; import net.sf.jsqlparser.statement.select.OrderByElement; import java.util.List; -import net.sf.jsqlparser.expression.operators.relational.ExpressionList; -import net.sf.jsqlparser.statement.select.PlainSelect; + +import static java.util.stream.Collectors.joining; /** - * Analytic function. The name of the function is variable but the parameters - * following the special analytic function path. e.g. row_number() over (order - * by test). Additional there can be an expression for an analytical aggregate - * like sum(col) or the "all collumns" wildcard like count(*). + * Analytic function. The name of the function is variable but the parameters following the special + * analytic function path. e.g. row_number() over (order by test). Additionally, there can be an + * expression for an analytical aggregate like sum(col) or the "all columns" wildcard like count(*). * * @author tw */ -public class AnalyticExpression implements Expression { +public class AnalyticExpression extends ASTNodeAccessImpl implements Expression { - //private List partitionByColumns; - private ExpressionList partitionExpressionList; - private List orderByElements; - private String name; - private Expression expression; + + private String name; + private Expression expression; private Expression offset; private Expression defaultValue; - private boolean allColumns = false; - private WindowElement windowElement; + private boolean allColumns = false; + private KeepExpression keep = null; + private AnalyticType type = AnalyticType.OVER; + private boolean distinct = false; + private boolean unique = false; + private boolean ignoreNullsOutside = false; // IGNORE NULLS outside function parameters + private Expression filterExpression = null; + private boolean filterWhereKeyword = true; + private List funcOrderBy = null; + private String onOverflowTruncate = null; + + private String windowName = null; // refers to an external window definition (paritionBy, + // orderBy, windowElement) + private WindowDefinition windowDef = new WindowDefinition(); + + private Function.HavingClause havingClause; + + private Function.NullHandling nullHandling = null; + + private Limit limit = null; + + private List keywordArguments = null; + + public AnalyticExpression() {} + + public AnalyticExpression(Function function) { + this.name = function.getName(); + this.allColumns = function.isAllColumns(); + this.distinct = function.isDistinct(); + this.unique = function.isUnique(); + + ExpressionList list = function.getParameters(); + if (list != null) { + if (list.size() > 3) { + throw new IllegalArgumentException( + "function object not valid to initialize analytic expression"); + } + + expression = list.get(0); + if (list.size() > 1) { + offset = list.get(1); + } + if (list.size() > 2) { + defaultValue = list.get(2); + } + } + this.havingClause = function.getHavingClause(); + this.ignoreNullsOutside = function.isIgnoreNullsOutside(); + this.nullHandling = function.getNullHandling(); + this.funcOrderBy = function.getOrderByElements(); + this.onOverflowTruncate = function.getOnOverflowTruncate(); + this.limit = function.getLimit(); + this.keep = function.getKeep(); + this.keywordArguments = function.getKeywordArguments(); + } + + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public List getOrderByElements() { + return windowDef.orderBy.getOrderByElements(); + } - public List getOrderByElements() { - return orderByElements; - } + public void setOrderByElements(List orderByElements) { + windowDef.orderBy.setOrderByElements(orderByElements); + } - public void setOrderByElements(List orderByElements) { - this.orderByElements = orderByElements; - } + public String getOnOverflowTruncate() { + return onOverflowTruncate; + } -// public List getPartitionByColumns() { -// return partitionByColumns; -// } -// -// public void setPartitionByColumns(List partitionByColumns) { -// this.partitionByColumns = partitionByColumns; -// } + public AnalyticExpression setOnOverflowTruncate(String onOverflowTruncate) { + this.onOverflowTruncate = onOverflowTruncate; + return this; + } - public ExpressionList getPartitionExpressionList() { - return partitionExpressionList; + public KeepExpression getKeep() { + return keep; } - public void setPartitionExpressionList(ExpressionList partitionExpressionList) { - this.partitionExpressionList = partitionExpressionList; + public void setKeep(KeepExpression keep) { + this.keep = keep; } - - - public String getName() { - return name; - } + public ExpressionList getPartitionExpressionList() { + return windowDef.partitionBy; + } - public void setName(String name) { - this.name = name; - } + public void setPartitionExpressionList(ExpressionList partitionExpressionList) { + setPartitionExpressionList(partitionExpressionList, false); + } - public Expression getExpression() { - return expression; - } + public void setPartitionExpressionList(ExpressionList partitionExpressionList, + boolean brackets) { + windowDef.partitionBy.setExpressions(partitionExpressionList, brackets); + } - public void setExpression(Expression expression) { - this.expression = expression; - } + public boolean isPartitionByBrackets() { + return windowDef.partitionBy.isBrackets(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } public Expression getOffset() { return offset; @@ -112,69 +171,340 @@ public void setDefaultValue(Expression defaultValue) { } public WindowElement getWindowElement() { - return windowElement; + return windowDef.windowElement; } public void setWindowElement(WindowElement windowElement) { - this.windowElement = windowElement; + windowDef.windowElement = windowElement; + } + + public AnalyticType getType() { + return type; + } + + public void setType(AnalyticType type) { + this.type = type; + } + + public boolean isDistinct() { + return distinct; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isUnique() { + return unique; + } + + public void setUnique(boolean unique) { + this.unique = unique; + } + + public boolean isIgnoreNulls() { + return this.nullHandling == Function.NullHandling.IGNORE_NULLS; + } + + public void setIgnoreNulls(boolean ignoreNulls) { + this.nullHandling = ignoreNulls ? Function.NullHandling.IGNORE_NULLS : null; + } + + public boolean isIgnoreNullsOutside() { + return ignoreNullsOutside; + } + + public void setIgnoreNullsOutside(boolean ignoreNullsOutside) { + this.ignoreNullsOutside = ignoreNullsOutside; + } + + public String getWindowName() { + return windowName; + } + + public void setWindowName(String windowName) { + this.windowName = windowName; + } + + public WindowDefinition getWindowDefinition() { + return windowDef; + } + + public void setWindowDefinition(WindowDefinition windowDef) { + this.windowDef = windowDef; + } + + + public Function.HavingClause getHavingClause() { + return havingClause; + } + + public AnalyticExpression setHavingClause(Function.HavingClause havingClause) { + this.havingClause = havingClause; + return this; + } + + public AnalyticExpression setHavingClause(String havingType, Expression expression) { + this.havingClause = new Function.HavingClause( + Function.HavingClause.HavingType + .valueOf(havingType.trim().toUpperCase(Locale.ROOT)), + expression); + return this; + } + + public Function.NullHandling getNullHandling() { + return nullHandling; + } + + public AnalyticExpression setNullHandling(Function.NullHandling nullHandling) { + this.nullHandling = nullHandling; + return this; + } + + public Limit getLimit() { + return limit; + } + + public AnalyticExpression setLimit(Limit limit) { + this.limit = limit; + return this; + } + + public List getKeywordArguments() { + return keywordArguments; + } + + public void setKeywordArguments(List keywordArguments) { + this.keywordArguments = keywordArguments; } @Override - public String toString() { - StringBuilder b = new StringBuilder(); + @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity", + "PMD.MissingBreakInSwitch"}) + public String toString() { + StringBuilder b = new StringBuilder(); - b.append(name).append("("); - if (expression != null) { - b.append(expression.toString()); + b.append(name).append("("); + if (isDistinct()) { + b.append("DISTINCT "); + } + if (expression != null) { + b.append(expression); if (offset != null) { - b.append(", ").append(offset.toString()); + b.append(", ").append(offset); if (defaultValue != null) { - b.append(", ").append(defaultValue.toString()); + b.append(", ").append(defaultValue); } } - } else if (isAllColumns()) { - b.append("*"); - } - b.append(") OVER ("); - - toStringPartitionBy(b); - toStringOrderByElements(b); - - b.append(")"); - - return b.toString(); - } - - public boolean isAllColumns() { - return allColumns; - } - - public void setAllColumns(boolean allColumns) { - this.allColumns = allColumns; - } - - private void toStringPartitionBy(StringBuilder b) { - if (partitionExpressionList != null && !partitionExpressionList.getExpressions().isEmpty()) { - b.append("PARTITION BY "); - b.append(PlainSelect.getStringList(partitionExpressionList.getExpressions(), true, false)); - b.append(" "); - } - } - - private void toStringOrderByElements(StringBuilder b) { - if (orderByElements != null && !orderByElements.isEmpty()) { - b.append("ORDER BY "); - for (int i = 0; i < orderByElements.size(); i++) { - if (i > 0) { - b.append(", "); - } - b.append(orderByElements.get(i).toString()); - } - - if(windowElement != null){ - b.append(' '); - b.append(windowElement); + } else if (isAllColumns()) { + b.append("*"); + } + + if (havingClause != null) { + havingClause.appendTo(b); + } + + if (nullHandling != null && !ignoreNullsOutside) { + switch (nullHandling) { + case IGNORE_NULLS: + b.append(" IGNORE NULLS"); + break; + case RESPECT_NULLS: + b.append(" RESPECT NULLS"); + break; + } + } + + if (funcOrderBy != null) { + b.append(" ORDER BY "); + b.append(funcOrderBy.stream().map(OrderByElement::toString).collect(joining(", "))); + } + + if (onOverflowTruncate != null) { + b.append(" ON OVERFLOW ").append(onOverflowTruncate); + } + + if (limit != null) { + b.append(limit); + } + + // Generic keyword arguments (e.g. SEPARATOR ',') + if (keywordArguments != null) { + for (Function.KeywordArgument ka : keywordArguments) { + ka.appendTo(b); + } + } + + b.append(") "); + if (keep != null) { + b.append(keep).append(" "); + } + + if (filterExpression != null && type != AnalyticType.WITHIN_GROUP) { + appendFilterTo(b, b::append); + if (type != AnalyticType.FILTER_ONLY) { + b.append(" "); + } + } + + if (nullHandling != null && ignoreNullsOutside) { + switch (nullHandling) { + case IGNORE_NULLS: + b.append(" IGNORE NULLS "); + break; + case RESPECT_NULLS: + b.append(" RESPECT NULLS "); + break; } - } - } + } + + switch (type) { + case FILTER_ONLY: + return b.toString(); + case WITHIN_GROUP: + b.append("WITHIN GROUP"); + break; + case WITHIN_GROUP_OVER: + b.append("WITHIN GROUP ("); + windowDef.orderBy.toStringOrderByElements(b); + b.append(") OVER ("); + windowDef.partitionBy.toStringPartitionBy(b); + b.append(")"); + break; + default: + b.append("OVER"); + } + + if (windowName != null) { + b.append(" ").append(windowName); + } else if (type != AnalyticType.WITHIN_GROUP_OVER) { + b.append(" "); + b.append(windowDef.toString()); + } + + if (filterExpression != null && type == AnalyticType.WITHIN_GROUP) { + b.append(' '); + appendFilterTo(b, b::append); + } + return b.toString(); + } + + /** Renders the filter using the caller's expression writer. */ + public void appendFilterTo(StringBuilder builder, Consumer expressionPrinter) { + if (filterExpression != null) { + builder.append(filterWhereKeyword ? "FILTER (WHERE " : "FILTER ("); + expressionPrinter.accept(filterExpression); + builder.append(')'); + } + } + + /** Whether the FILTER clause has WHERE, which DuckDB allows to leave out. */ + public boolean isFilterWhereKeyword() { + return filterWhereKeyword; + } + + public AnalyticExpression setFilterWhereKeyword(boolean filterWhereKeyword) { + this.filterWhereKeyword = filterWhereKeyword; + return this; + } + + public boolean isAllColumns() { + return allColumns; + } + + public void setAllColumns(boolean allColumns) { + this.allColumns = allColumns; + } + + public Expression getFilterExpression() { + return filterExpression; + } + + public void setFilterExpression(Expression filterExpression) { + this.filterExpression = filterExpression; + } + + public AnalyticExpression withName(String name) { + this.setName(name); + return this; + } + + public AnalyticExpression withExpression(Expression expression) { + this.setExpression(expression); + return this; + } + + public AnalyticExpression withOffset(Expression offset) { + this.setOffset(offset); + return this; + } + + public AnalyticExpression withDefaultValue(Expression defaultValue) { + this.setDefaultValue(defaultValue); + return this; + } + + public AnalyticExpression withAllColumns(boolean allColumns) { + this.setAllColumns(allColumns); + return this; + } + + public AnalyticExpression withKeep(KeepExpression keep) { + this.setKeep(keep); + return this; + } + + public AnalyticExpression withType(AnalyticType type) { + this.setType(type); + return this; + } + + public AnalyticExpression withDistinct(boolean distinct) { + this.setDistinct(distinct); + return this; + } + + public AnalyticExpression withUnique(boolean unique) { + this.setUnique(unique); + return this; + } + + public AnalyticExpression withIgnoreNulls(boolean ignoreNulls) { + this.setIgnoreNulls(ignoreNulls); + return this; + } + + public AnalyticExpression withFilterExpression(Expression filterExpression) { + this.setFilterExpression(filterExpression); + return this; + } + + public AnalyticExpression withWindowElement(WindowElement windowElement) { + this.setWindowElement(windowElement); + return this; + } + + public E getExpression(Class type) { + return type.cast(getExpression()); + } + + public E getOffset(Class type) { + return type.cast(getOffset()); + } + + public E getDefaultValue(Class type) { + return type.cast(getDefaultValue()); + } + + public E getFilterExpression(Class type) { + return type.cast(getFilterExpression()); + } + + public List getFuncOrderBy() { + return funcOrderBy; + } + + public void setFuncOrderBy(List funcOrderBy) { + this.funcOrderBy = funcOrderBy; + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/AnalyticType.java b/src/main/java/net/sf/jsqlparser/expression/AnalyticType.java new file mode 100644 index 0000000000..ea083c902f --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/AnalyticType.java @@ -0,0 +1,20 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.Locale; + +public enum AnalyticType { + OVER, WITHIN_GROUP, WITHIN_GROUP_OVER, FILTER_ONLY; + + public static AnalyticType from(String type) { + return Enum.valueOf(AnalyticType.class, type.toUpperCase(Locale.ROOT)); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/AnyComparisonExpression.java b/src/main/java/net/sf/jsqlparser/expression/AnyComparisonExpression.java index a19afa2cdc..cf3ba46d5e 100644 --- a/src/main/java/net/sf/jsqlparser/expression/AnyComparisonExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/AnyComparisonExpression.java @@ -1,42 +1,48 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; -import net.sf.jsqlparser.statement.select.SubSelect; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.select.Select; -public class AnyComparisonExpression implements Expression { +/** + * Combines ANY and SOME expressions. + * + * @author toben + */ +public class AnyComparisonExpression extends ASTNodeAccessImpl implements Expression { + private final Select select; + private final AnyType anyType; + + public AnyComparisonExpression(AnyType anyType, Select select) { + this.anyType = anyType; + this.select = select; + } + + public Select getSelect() { + return select; + } - private SubSelect subSelect; - public AnyComparisonExpression(SubSelect subSelect) { - this.subSelect = subSelect; - } + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } - public SubSelect getSubSelect() { - return subSelect; - } + public AnyType getAnyType() { + return anyType; + } - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + @Override + public String toString() { + String s = anyType.name() + select; + return s; + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/AnyType.java b/src/main/java/net/sf/jsqlparser/expression/AnyType.java new file mode 100644 index 0000000000..da5495d077 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/AnyType.java @@ -0,0 +1,20 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.Locale; + +public enum AnyType { + ANY, SOME, ALL; + + public static AnyType from(String type) { + return Enum.valueOf(AnyType.class, type.toUpperCase(Locale.ROOT)); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/ArrayConstructor.java b/src/main/java/net/sf/jsqlparser/expression/ArrayConstructor.java new file mode 100644 index 0000000000..5e1c8d0e66 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/ArrayConstructor.java @@ -0,0 +1,75 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2021 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.create.table.ColDataType; + +public class ArrayConstructor extends ASTNodeAccessImpl implements Expression { + private ExpressionList expressions; + private boolean arrayKeyword; + private ColDataType dataType; + + public ArrayConstructor(ExpressionList expressions, boolean arrayKeyword) { + this.expressions = expressions; + this.arrayKeyword = arrayKeyword; + } + + public ArrayConstructor(Expression... expressions) { + this(new ExpressionList(expressions), false); + } + + public ExpressionList getExpressions() { + return expressions; + } + + public void setExpressions(ExpressionList expressions) { + this.expressions = expressions; + } + + public boolean isArrayKeyword() { + return arrayKeyword; + } + + public void setArrayKeyword(boolean arrayKeyword) { + this.arrayKeyword = arrayKeyword; + } + + public ColDataType getDataType() { + return dataType; + } + + public ArrayConstructor setDataType(ColDataType dataType) { + this.dataType = dataType; + return this; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + if (arrayKeyword) { + sb.append("ARRAY"); + + if (dataType != null) { + sb.append("<").append(dataType).append(">"); + } + } + sb.append("["); + sb.append(expressions.toString()); + sb.append("]"); + return sb.toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/ArrayExpression.java b/src/main/java/net/sf/jsqlparser/expression/ArrayExpression.java new file mode 100644 index 0000000000..74072efe34 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/ArrayExpression.java @@ -0,0 +1,128 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class ArrayExpression extends ASTNodeAccessImpl implements Expression { + + private Expression objExpression; + private Expression indexExpression; + private Expression startIndexExpression; + private Expression stopIndexExpression; + private Expression stepExpression; + + + public ArrayExpression() { + // empty constructor + } + + public ArrayExpression(Expression objExpression, Expression indexExpression, + Expression startIndexExpression, Expression stopIndexExpression) { + this.objExpression = objExpression; + this.indexExpression = indexExpression; + this.startIndexExpression = startIndexExpression; + this.stopIndexExpression = stopIndexExpression; + } + + public ArrayExpression(Expression objExpression, Expression indexExpression) { + this(objExpression, indexExpression, null, null); + } + + public ArrayExpression(Expression objExpression, Expression startIndexExpression, + Expression stopIndexExpression) { + this(objExpression, null, startIndexExpression, stopIndexExpression); + } + + public Expression getObjExpression() { + return objExpression; + } + + public void setObjExpression(Expression objExpression) { + this.objExpression = objExpression; + } + + public Expression getIndexExpression() { + return indexExpression; + } + + public void setIndexExpression(Expression indexExpression) { + this.indexExpression = indexExpression; + } + + public Expression getStartIndexExpression() { + return startIndexExpression; + } + + public void setStartIndexExpression(Expression startIndexExpression) { + this.startIndexExpression = startIndexExpression; + } + + public Expression getStopIndexExpression() { + return stopIndexExpression; + } + + public void setStopIndexExpression(Expression stopIndexExpression) { + this.stopIndexExpression = stopIndexExpression; + } + + public Expression getStepExpression() { + return stepExpression; + } + + public void setStepExpression(Expression stepExpression) { + this.stepExpression = stepExpression; + } + + public ArrayExpression withStepExpression(Expression stepExpression) { + this.setStepExpression(stepExpression); + return this; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + if (indexExpression != null) { + return objExpression.toString() + "[" + indexExpression.toString() + "]"; + } else { + return objExpression.toString() + "[" + RangeExpression.toString(startIndexExpression, + stopIndexExpression, stepExpression) + "]"; + } + } + + public ArrayExpression withObjExpression(Expression objExpression) { + this.setObjExpression(objExpression); + return this; + } + + public ArrayExpression withIndexExpression(Expression indexExpression) { + this.setIndexExpression(indexExpression); + return this; + } + + public ArrayExpression withRangeExpression(Expression startIndexExpression, + Expression stopIndexExpression) { + this.setStartIndexExpression(startIndexExpression); + this.setStopIndexExpression(stopIndexExpression); + return this; + } + + public E getObjExpression(Class type) { + return type.cast(getObjExpression()); + } + + public E getIndexExpression(Class type) { + return type.cast(getIndexExpression()); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/BinaryExpression.java b/src/main/java/net/sf/jsqlparser/expression/BinaryExpression.java index 53dddc12e6..ffd9c2d846 100644 --- a/src/main/java/net/sf/jsqlparser/expression/BinaryExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/BinaryExpression.java @@ -1,67 +1,266 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import net.sf.jsqlparser.expression.operators.arithmetic.Addition; +import net.sf.jsqlparser.expression.operators.arithmetic.BitwiseAnd; +import net.sf.jsqlparser.expression.operators.arithmetic.BitwiseLeftShift; +import net.sf.jsqlparser.expression.operators.arithmetic.BitwiseOr; +import net.sf.jsqlparser.expression.operators.arithmetic.BitwiseRightShift; +import net.sf.jsqlparser.expression.operators.arithmetic.BitwiseXor; +import net.sf.jsqlparser.expression.operators.arithmetic.Concat; +import net.sf.jsqlparser.expression.operators.arithmetic.Division; +import net.sf.jsqlparser.expression.operators.arithmetic.IntegerDivision; +import net.sf.jsqlparser.expression.operators.arithmetic.Modulo; +import net.sf.jsqlparser.expression.operators.arithmetic.Multiplication; +import net.sf.jsqlparser.expression.operators.arithmetic.Subtraction; +import net.sf.jsqlparser.expression.operators.conditional.AndExpression; +import net.sf.jsqlparser.expression.operators.conditional.OrExpression; +import net.sf.jsqlparser.expression.operators.conditional.XorExpression; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; +import java.util.Iterator; + /** - * A basic class for binary expressions, that is expressions having a left - * member and a right member which are in turn expressions. + * A basic class for binary expressions, that is expressions having a left member and a right member + * which are in turn expressions. */ -public abstract class BinaryExpression implements Expression { +public abstract class BinaryExpression extends ASTNodeAccessImpl implements Expression { + + private Expression leftExpression; + private Expression rightExpression; + + public BinaryExpression() {} + + public BinaryExpression(Expression leftExpression, Expression rightExpression) { + this.leftExpression = leftExpression; + this.rightExpression = rightExpression; + } + + public static Expression build(Class clz, Expression... expressions) + throws NoSuchMethodException, InvocationTargetException, InstantiationException, + IllegalAccessException { + switch (expressions.length) { + case 0: + return new NullValue(); + case 1: + return expressions[0]; + default: + Iterator it = Arrays.stream(expressions).iterator(); + + Expression leftExpression = it.next(); + Expression rightExpression = it.next(); + BinaryExpression binaryExpression = + clz.getConstructor(Expression.class, Expression.class) + .newInstance(leftExpression, rightExpression); + + while (it.hasNext()) { + rightExpression = it.next(); + binaryExpression = clz.getConstructor(Expression.class, Expression.class) + .newInstance(binaryExpression, rightExpression); + } + return binaryExpression; + } + } + + public static Expression add(Expression... expressions) { + try { + return build(Addition.class, expressions); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + // this should never happen, at least I don't see how + throw new RuntimeException(e); + } + } + + public static Expression bitAnd(Expression... expressions) { + try { + return build(BitwiseAnd.class, expressions); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + // this should never happen, at least I don't see how + throw new RuntimeException(e); + } + } + + public static Expression bitShiftLeft(Expression... expressions) { + try { + return build(BitwiseLeftShift.class, expressions); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + // this should never happen, at least I don't see how + throw new RuntimeException(e); + } + } + + public static Expression multiply(Expression... expressions) { + try { + return build(Multiplication.class, expressions); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + // this should never happen, at least I don't see how + throw new RuntimeException(e); + } + } + + public static Expression bitOr(Expression... expressions) { + try { + return build(BitwiseOr.class, expressions); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + // this should never happen, at least I don't see how + throw new RuntimeException(e); + } + } + + public static Expression bitShiftRight(Expression... expressions) { + try { + return build(BitwiseRightShift.class, expressions); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + // this should never happen, at least I don't see how + throw new RuntimeException(e); + } + } + + public static Expression bitXor(Expression... expressions) { + try { + return build(BitwiseXor.class, expressions); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + // this should never happen, at least I don't see how + throw new RuntimeException(e); + } + } + + public static Expression concat(Expression... expressions) { + try { + return build(Concat.class, expressions); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + // this should never happen, at least I don't see how + throw new RuntimeException(e); + } + } + + public static Expression divide(Expression... expressions) { + try { + return build(Division.class, expressions); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + // this should never happen, at least I don't see how + throw new RuntimeException(e); + } + } + + public static Expression divideInt(Expression... expressions) { + try { + return build(IntegerDivision.class, expressions); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + // this should never happen, at least I don't see how + throw new RuntimeException(e); + } + } + + public static Expression modulo(Expression... expressions) { + try { + return build(Modulo.class, expressions); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + // this should never happen, at least I don't see how + throw new RuntimeException(e); + } + } + + public static Expression subtract(Expression... expressions) { + try { + return build(Subtraction.class, expressions); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + // this should never happen, at least I don't see how + throw new RuntimeException(e); + } + } + + public static Expression or(Expression... expressions) { + try { + return build(OrExpression.class, expressions); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + // this should never happen, at least I don't see how + throw new RuntimeException(e); + } + } + + public static Expression xor(Expression... expressions) { + try { + return build(XorExpression.class, expressions); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + // this should never happen, at least I don't see how + throw new RuntimeException(e); + } + } + + public static Expression and(Expression... expressions) { + try { + return build(AndExpression.class, expressions); + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException + | IllegalAccessException e) { + // this should never happen, at least I don't see how + throw new RuntimeException(e); + } + } - private Expression leftExpression; - private Expression rightExpression; - private boolean not = false; + public Expression getLeftExpression() { + return leftExpression; + } - public BinaryExpression() { - } + public void setLeftExpression(Expression expression) { + leftExpression = expression; + } - public Expression getLeftExpression() { - return leftExpression; - } + public Expression getRightExpression() { + return rightExpression; + } - public Expression getRightExpression() { - return rightExpression; - } + public void setRightExpression(Expression expression) { + rightExpression = expression; + } - public void setLeftExpression(Expression expression) { - leftExpression = expression; - } + public BinaryExpression withLeftExpression(Expression expression) { + setLeftExpression(expression); + return this; + } - public void setRightExpression(Expression expression) { - rightExpression = expression; - } + public BinaryExpression withRightExpression(Expression expression) { + setRightExpression(expression); + return this; + } - public void setNot() { - not = true; - } + @Override + public String toString() { + return // (not ? "NOT " : "") + + getLeftExpression() + " " + getStringExpression() + " " + getRightExpression(); + } - public boolean isNot() { - return not; - } + public abstract String getStringExpression(); - @Override - public String toString() { - return (not ? "NOT " : "") + getLeftExpression() + " " + getStringExpression() + " " + getRightExpression(); - } + public E getLeftExpression(Class type) { + return type.cast(getLeftExpression()); + } - public abstract String getStringExpression(); + public E getRightExpression(Class type) { + return type.cast(getRightExpression()); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/BooleanValue.java b/src/main/java/net/sf/jsqlparser/expression/BooleanValue.java new file mode 100644 index 0000000000..258a89e165 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/BooleanValue.java @@ -0,0 +1,74 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2024 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +import java.util.Objects; + +/** + * A boolean value true/false + */ +public final class BooleanValue extends ASTNodeAccessImpl implements Expression { + + private boolean value = false; + + public BooleanValue() { + // empty constructor + } + + public BooleanValue(String value) { + this(Boolean.parseBoolean(value)); + } + + public BooleanValue(boolean bool) { + value = bool; + } + + public boolean getValue() { + return value; + } + + public void setValue(boolean bool) { + value = bool; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + return Boolean.toString(value); + } + + public BooleanValue withValue(boolean bool) { + this.setValue(bool); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BooleanValue that = (BooleanValue) o; + return Objects.equals(value, that.value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/CaseExpression.java b/src/main/java/net/sf/jsqlparser/expression/CaseExpression.java index e095cc062c..10fd7d56d7 100644 --- a/src/main/java/net/sf/jsqlparser/expression/CaseExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/CaseExpression.java @@ -1,124 +1,182 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; import java.util.List; +import java.util.Optional; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; import net.sf.jsqlparser.statement.select.PlainSelect; /** * CASE/WHEN expression. - * + *

* Syntax: - *

+ *
+ * 
+ * 
  * CASE
  * WHEN condition THEN expression
  * [WHEN condition THEN expression]...
  * [ELSE expression]
  * END
- * 
+ *
+ *
* - *
- * or
- *
+ *
+ * or
+ *
* - *
+ * 
+ * 
  * CASE expression
  * WHEN condition THEN expression
  * [WHEN condition THEN expression]...
  * [ELSE expression]
  * END
- * 
- * - * See also: https://aurora.vcu.edu/db2help/db2s0/frame3.htm#casexp - * http://sybooks.sybase.com/onlinebooks/group-as/asg1251e /commands/ - * - * @ebt-link;pt=5954?target=%25N%15_52628_START_RESTART_N%25 - * - * - * @author Havard Rast Blok + *
+ *
*/ -public class CaseExpression implements Expression { - - private Expression switchExpression; - private List whenClauses; - private Expression elseExpression; - - /* - * (non-Javadoc) - * - * @see net.sf.jsqlparser.expression.Expression#accept(net.sf.jsqlparser.expression.ExpressionVisitor) - */ - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } - - /** - * @return Returns the switchExpression. - */ - public Expression getSwitchExpression() { - return switchExpression; - } - - /** - * @param switchExpression The switchExpression to set. - */ - public void setSwitchExpression(Expression switchExpression) { - this.switchExpression = switchExpression; - } - - /** - * @return Returns the elseExpression. - */ - public Expression getElseExpression() { - return elseExpression; - } - - /** - * @param elseExpression The elseExpression to set. - */ - public void setElseExpression(Expression elseExpression) { - this.elseExpression = elseExpression; - } - - /** - * @return Returns the whenClauses. - */ - public List getWhenClauses() { - return whenClauses; - } - - /** - * @param whenClauses The whenClauses to set. - */ - public void setWhenClauses(List whenClauses) { - this.whenClauses = whenClauses; - } - - @Override - public String toString() { - return "CASE " + ((switchExpression != null) ? switchExpression + " " : "") - + PlainSelect.getStringList(whenClauses, false, false) + " " - + ((elseExpression != null) ? "ELSE " + elseExpression + " " : "") + "END"; - } +public class CaseExpression extends ASTNodeAccessImpl implements Expression { + + private boolean usingBrackets = false; + private Expression switchExpression; + private List whenClauses; + private Expression elseExpression; + + public CaseExpression() {} + + public CaseExpression(WhenClause... whenClauses) { + this.whenClauses = Arrays.asList(whenClauses); + } + + public CaseExpression(Expression elseExpression, WhenClause... whenClauses) { + this.elseExpression = elseExpression; + this.whenClauses = Arrays.asList(whenClauses); + } + + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public Expression getSwitchExpression() { + return switchExpression; + } + + public void setSwitchExpression(Expression switchExpression) { + this.switchExpression = switchExpression; + } + + /** + * @return Returns the elseExpression. + */ + public Expression getElseExpression() { + return elseExpression; + } + + /** + * @param elseExpression The elseExpression to set. + */ + public void setElseExpression(Expression elseExpression) { + this.elseExpression = elseExpression; + } + + /** + * @return Returns the whenClauses. + */ + public List getWhenClauses() { + return whenClauses; + } + + /** + * @param whenClauses The whenClauses to set. + */ + public void setWhenClauses(List whenClauses) { + this.whenClauses = whenClauses; + } + + @Override + public String toString() { + return (usingBrackets ? "(" : "") + "CASE " + + ((switchExpression != null) ? switchExpression + " " : "") + + PlainSelect.getStringList(whenClauses, false, false) + " " + + ((elseExpression != null) ? "ELSE " + elseExpression + " " : "") + "END" + + (usingBrackets ? ")" : ""); + } + + public CaseExpression withSwitchExpression(Expression switchExpression) { + this.setSwitchExpression(switchExpression); + return this; + } + + public CaseExpression withWhenClauses(WhenClause... whenClauses) { + return this.withWhenClauses(Arrays.asList(whenClauses)); + } + + public CaseExpression withWhenClauses(List whenClauses) { + this.setWhenClauses(whenClauses); + return this; + } + + public CaseExpression withElseExpression(Expression elseExpression) { + this.setElseExpression(elseExpression); + return this; + } + + public CaseExpression addWhenClauses(WhenClause... whenClauses) { + List collection = + Optional.ofNullable(getWhenClauses()).orElseGet(ArrayList::new); + Collections.addAll(collection, whenClauses); + return this.withWhenClauses(collection); + } + + public CaseExpression addWhenClauses(Collection whenClauses) { + List collection = + Optional.ofNullable(getWhenClauses()).orElseGet(ArrayList::new); + collection.addAll(whenClauses); + return this.withWhenClauses(collection); + } + + public E getSwitchExpression(Class type) { + return type.cast(getSwitchExpression()); + } + + public E getElseExpression(Class type) { + return type.cast(getElseExpression()); + } + + /** + * @return the usingBrackets + */ + public boolean isUsingBrackets() { + return usingBrackets; + } + + /** + * @param usingBrackets the usingBrackets to set + */ + public void setUsingBrackets(boolean usingBrackets) { + this.usingBrackets = usingBrackets; + } + + /** + * @param usingBrackets the usingBrackets to set + */ + public CaseExpression withUsingBrackets(boolean usingBrackets) { + this.usingBrackets = usingBrackets; + return this; + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/CastExpression.java b/src/main/java/net/sf/jsqlparser/expression/CastExpression.java index 897a118a0b..9c77ef825f 100644 --- a/src/main/java/net/sf/jsqlparser/expression/CastExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/CastExpression.java @@ -1,73 +1,296 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import java.util.ArrayList; +import java.util.Locale; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; import net.sf.jsqlparser.statement.create.table.ColDataType; +import net.sf.jsqlparser.statement.create.table.ColumnDefinition; +import net.sf.jsqlparser.statement.select.Select; -/** - * - * @author tw - */ -public class CastExpression implements Expression { - - private Expression leftExpression; - private ColDataType type; - private boolean useCastKeyword = true; - - public ColDataType getType() { - return type; - } - - public void setType(ColDataType type) { - this.type = type; - } - - public Expression getLeftExpression() { - return leftExpression; - } - - public void setLeftExpression(Expression expression) { - leftExpression = expression; - } - - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } - - public boolean isUseCastKeyword() { - return useCastKeyword; - } - - public void setUseCastKeyword(boolean useCastKeyword) { - this.useCastKeyword = useCastKeyword; - } - - @Override - public String toString() { - if (useCastKeyword) { - return "CAST(" + leftExpression + " AS " + type.toString() + ")"; - } else { - return leftExpression + "::" + type.toString(); - } - } +public class CastExpression extends ASTNodeAccessImpl implements Expression { + private final static Pattern PATTERN = + Pattern.compile("(^[a-z0-9_]*){1}", Pattern.CASE_INSENSITIVE); + public String keyword; + + private Expression leftExpression; + private ColDataType colDataType = null; + private ArrayList columnDefinitions = new ArrayList<>(); + + private boolean isImplicitCast = false; + + // BigQuery specific FORMAT clause: + // https://cloud.google.com/bigquery/docs/reference/standard-sql/conversion_functions#cast_as_date + private String format = null; + + public CastExpression(String keyword, Expression leftExpression, String dataType) { + this.keyword = keyword; + this.leftExpression = leftExpression; + this.colDataType = new ColDataType(dataType); + } + + // Implicit Cast + public CastExpression(String dataType, String value) { + this.keyword = null; + this.isImplicitCast = true; + this.colDataType = new ColDataType(dataType); + this.leftExpression = new StringValue(value); + } + + public CastExpression(ColDataType colDataType, String value) { + this.keyword = null; + this.isImplicitCast = true; + this.colDataType = colDataType; + this.leftExpression = new StringValue(value); + } + + public CastExpression(ColDataType colDataType, Long value) { + this.keyword = null; + this.isImplicitCast = true; + this.colDataType = colDataType; + this.leftExpression = new LongValue(value); + } + + public CastExpression(ColDataType colDataType, Double value) { + this.keyword = null; + this.isImplicitCast = true; + this.colDataType = colDataType; + this.leftExpression = new DoubleValue(value); + } + + public CastExpression(Expression leftExpression, String dataType) { + this.keyword = null; + this.leftExpression = leftExpression; + this.colDataType = new ColDataType(dataType); + } + + + public CastExpression(String keyword) { + this.keyword = keyword; + } + + public CastExpression() { + this("CAST"); + } + + public static boolean isOf(ColDataType colDataType, DataType... types) { + return Set.of(types).contains(DataType.from(colDataType.getDataType())); + } + + public static boolean isTime(ColDataType colDataType) { + return isOf(colDataType, DataType.TIME, DataType.TIME_WITH_TIME_ZONE, + DataType.TIME_WITHOUT_TIME_ZONE); + } + + public static boolean isTimeStamp(ColDataType colDataType) { + return isOf(colDataType, DataType.TIMESTAMP_NS, DataType.TIMESTAMP, + DataType.TIMESTAMP_WITHOUT_TIME_ZONE, + DataType.DATETIME, DataType.TIMESTAMP_MS, DataType.TIMESTAMP_S, + DataType.TIMESTAMPTZ, DataType.TIMESTAMP_WITH_TIME_ZONE); + } + + public static boolean isDate(ColDataType colDataType) { + return isOf(colDataType, DataType.DATE); + } + + public static boolean isBLOB(ColDataType colDataType) { + return isOf(colDataType, DataType.BLOB, DataType.BYTEA, DataType.BINARY, DataType.VARBINARY, + DataType.BYTES, DataType.VARBYTE); + } + + public static boolean isFloat(ColDataType colDataType) { + return isOf(colDataType, DataType.REAL, DataType.FLOAT4, DataType.FLOAT, DataType.DOUBLE, + DataType.DOUBLE_PRECISION, DataType.FLOAT8); + } + + public static boolean isInteger(ColDataType colDataType) { + return isOf(colDataType, DataType.TINYINT, DataType.INT1, DataType.SMALLINT, DataType.INT2, + DataType.SHORT, DataType.INTEGER, DataType.INT4, DataType.INT, DataType.SIGNED, + DataType.BIGINT, DataType.INT8, DataType.LONG, DataType.HUGEINT, DataType.UTINYINT, + DataType.USMALLINT, DataType.UINTEGER, DataType.UBIGINT, DataType.UHUGEINT); + } + + public static boolean isDecimal(ColDataType colDataType) { + return isOf(colDataType, DataType.DECIMAL, DataType.NUMBER, DataType.NUMERIC); + } + + public static boolean isText(ColDataType colDataType) { + return isOf(colDataType, DataType.VARCHAR, DataType.NVARCHAR, DataType.CHAR, DataType.NCHAR, + DataType.BPCHAR, DataType.STRING, DataType.TEXT, DataType.CLOB); + } + + public ColDataType getColDataType() { + return colDataType; + } + + public void setColDataType(ColDataType colDataType) { + this.colDataType = colDataType; + } + + public ArrayList getColumnDefinitions() { + return columnDefinitions; + } + + public void addColumnDefinition(ColumnDefinition columnDefinition) { + this.columnDefinitions.add(columnDefinition); + } + + public Expression getLeftExpression() { + return leftExpression; + } + + public void setLeftExpression(Expression expression) { + leftExpression = expression; + } + + public boolean isImplicitCast() { + return isImplicitCast; + } + + public CastExpression setImplicitCast(boolean implicitCast) { + isImplicitCast = implicitCast; + return this; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Deprecated + public boolean isUseCastKeyword() { + return keyword != null && !keyword.isEmpty(); + } + + @Deprecated + public void setUseCastKeyword(boolean useCastKeyword) { + if (useCastKeyword) { + if (keyword == null || keyword.isEmpty()) { + keyword = "CAST"; + } + } else { + keyword = null; + } + } + + public String getFormat() { + return format; + } + + public CastExpression setFormat(String format) { + this.format = format; + return this; + } + + @Override + public String toString() { + String formatStr = format != null && !format.isEmpty() + ? " FORMAT " + format + : ""; + if (isImplicitCast) { + return colDataType + " " + leftExpression; + } else if (keyword != null && !keyword.isEmpty()) { + return !columnDefinitions.isEmpty() + ? keyword + "(" + leftExpression + " AS ROW(" + + Select.getStringList(columnDefinitions) + ")" + formatStr + ")" + : keyword + "(" + leftExpression + " AS " + colDataType.toString() + formatStr + + ")"; + } else { + return leftExpression + "::" + colDataType.toString(); + } + } + + public CastExpression withType(ColDataType type) { + this.setColDataType(type); + return this; + } + + public CastExpression withUseCastKeyword(boolean useCastKeyword) { + this.setUseCastKeyword(useCastKeyword); + return this; + } + + public CastExpression withLeftExpression(Expression leftExpression) { + this.setLeftExpression(leftExpression); + return this; + } + + public E getLeftExpression(Class type) { + return type.cast(getLeftExpression()); + } + + public boolean isOf(CastExpression anotherCast) { + return this.colDataType.equals(anotherCast.colDataType); + } + + public boolean isOf(DataType... types) { + return Set.of(types).contains(DataType.from(colDataType.getDataType())); + } + + public boolean isTime() { + return isTime(this.colDataType); + } + + public boolean isTimeStamp() { + return isTimeStamp(this.colDataType); + } + + public boolean isDate() { + return isDate(this.colDataType); + } + + public boolean isBLOB() { + return isBLOB(this.colDataType); + } + + public boolean isFloat() { + return isFloat(this.colDataType); + } + + public boolean isInteger() { + return isInteger(this.colDataType); + } + + public boolean isDecimal() { + return isDecimal(this.colDataType); + } + + public boolean isText() { + return isText(this.colDataType); + } + + public enum DataType { + ARRAY, BIT, BITSTRING, BLOB, BYTEA, BINARY, VARBINARY, BYTES, BOOLEAN, BOOL, ENUM, INTERVAL, LIST, MAP, STRUCT, TINYINT, INT1, SMALLINT, INT2, SHORT, INTEGER, INT4, INT, SIGNED, BIGINT, INT8, LONG, HUGEINT, UTINYINT, USMALLINT, UINTEGER, UBIGINT, UHUGEINT, DECIMAL, NUMBER, NUMERIC, REAL, FLOAT4, FLOAT, DOUBLE, DOUBLE_PRECISION, FLOAT8, FLOAT64, UUID, VARCHAR, NVARCHAR, CHAR, NCHAR, BPCHAR, STRING, TEXT, CLOB, DATE, TIME, TIME_WITHOUT_TIME_ZONE, TIMETZ, TIME_WITH_TIME_ZONE, TIMESTAMP_NS, TIMESTAMP, TIMESTAMP_WITHOUT_TIME_ZONE, DATETIME, TIMESTAMP_MS, TIMESTAMP_S, TIMESTAMPTZ, TIMESTAMP_WITH_TIME_ZONE, UNKNOWN, VARBYTE, JSON; + + public static DataType from(String typeStr) { + Matcher matcher = PATTERN.matcher( + typeStr.trim().replaceAll("\\s+", "_").toUpperCase(Locale.ROOT)); + if (matcher.find()) { + try { + return Enum.valueOf(DataType.class, matcher.group(0)); + } catch (Exception ex) { + Logger.getLogger(CastExpression.class.getName()).log(Level.FINE, + "Type " + typeStr + " unknown", ex); + return DataType.UNKNOWN; + } + } else { + Logger.getLogger(CastExpression.class.getName()).log(Level.FINE, + "Type " + typeStr + " unknown"); + return DataType.UNKNOWN; + } + } + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/CollateExpression.java b/src/main/java/net/sf/jsqlparser/expression/CollateExpression.java new file mode 100644 index 0000000000..8a419b2419 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/CollateExpression.java @@ -0,0 +1,67 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class CollateExpression extends ASTNodeAccessImpl implements Expression { + + private Expression leftExpression; + private String collate; + + public CollateExpression() { + // empty constructor + } + + public CollateExpression(Expression leftExpression, String collate) { + this.leftExpression = leftExpression; + this.collate = collate; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public Expression getLeftExpression() { + return leftExpression; + } + + public void setLeftExpression(Expression leftExpression) { + this.leftExpression = leftExpression; + } + + public String getCollate() { + return collate; + } + + public void setCollate(String collate) { + this.collate = collate; + } + + @Override + public String toString() { + return leftExpression.toString() + " COLLATE " + collate; + } + + public CollateExpression withLeftExpression(Expression leftExpression) { + this.setLeftExpression(leftExpression); + return this; + } + + public CollateExpression withCollate(String collate) { + this.setCollate(collate); + return this; + } + + public E getLeftExpression(Class type) { + return type.cast(getLeftExpression()); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/ColumnsExpression.java b/src/main/java/net/sf/jsqlparser/expression/ColumnsExpression.java new file mode 100644 index 0000000000..aa19d555f3 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/ColumnsExpression.java @@ -0,0 +1,84 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.ArrayList; +import java.util.List; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** + * A ClickHouse {@code COLUMNS('regexp')} matcher with one or more transformers, for example + * {@code COLUMNS('^metric_') APPLY(x -> round(x, 2))}. + * + * Without a transformer, {@code COLUMNS('regexp')} keeps parsing as a regular + * {@link net.sf.jsqlparser.expression.Function}. + */ +public class ColumnsExpression extends ASTNodeAccessImpl implements Expression { + + private Expression columns; + private List transformers; + + public ColumnsExpression(Expression columns) { + this.columns = columns; + this.transformers = new ArrayList<>(); + } + + public ColumnsExpression(Expression columns, List transformers) { + this.columns = columns; + this.transformers = transformers; + } + + public Expression getColumns() { + return columns; + } + + public ColumnsExpression setColumns(Expression columns) { + this.columns = columns; + return this; + } + + public List getTransformers() { + return transformers; + } + + public ColumnsExpression setTransformers(List transformers) { + this.transformers = transformers; + return this; + } + + public List getAllExpressions() { + List expressions = new ArrayList<>(); + if (columns != null) { + expressions.add(columns); + } + for (ColumnsTransformer transformer : transformers) { + transformer.collectExpressions(expressions); + } + return expressions; + } + + public StringBuilder appendTo(StringBuilder builder) { + builder.append(columns); + for (ColumnsTransformer transformer : transformers) { + builder.append(" ").append(transformer); + } + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/ColumnsTransformer.java b/src/main/java/net/sf/jsqlparser/expression/ColumnsTransformer.java new file mode 100644 index 0000000000..9f471fe16e --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/ColumnsTransformer.java @@ -0,0 +1,213 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.List; +import net.sf.jsqlparser.expression.operators.relational.ParenthesedExpressionList; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.schema.Column; +import net.sf.jsqlparser.statement.select.Select; +import net.sf.jsqlparser.statement.select.SelectItem; + +/** + * A ClickHouse transformer following a {@code COLUMNS(...)} matcher or a {@code *}, for example the + * {@code APPLY(x -> round(x, 2))} in {@code SELECT COLUMNS('^m') APPLY(x -> round(x, 2))}. + * + * ClickHouse parses its transformers in a loop, so they may repeat and combine in any order. + */ +public class ColumnsTransformer extends ASTNodeAccessImpl { + + public enum ColumnsTransformerType { + APPLY, EXCEPT, EXCLUDE, REPLACE, RENAME + } + + private ColumnsTransformerType type; + private Expression applyExpression; + private ParenthesedExpressionList exceptColumns; + private StringValue exceptPattern; + private List> replaceItems; + private List> renameItems; + private boolean parenthesized = true; + private boolean strict; + + public ColumnsTransformer(ColumnsTransformerType type) { + this.type = type; + } + + public ColumnsTransformerType getType() { + return type; + } + + public ColumnsTransformer setType(ColumnsTransformerType type) { + this.type = type; + return this; + } + + public Expression getApplyExpression() { + return applyExpression; + } + + public ColumnsTransformer setApplyExpression(Expression applyExpression) { + this.applyExpression = applyExpression; + return this; + } + + public ParenthesedExpressionList getExceptColumns() { + return exceptColumns; + } + + public ColumnsTransformer setExceptColumns(ParenthesedExpressionList exceptColumns) { + this.exceptColumns = exceptColumns; + if (exceptColumns != null) { + this.exceptPattern = null; + } + return this; + } + + /** + * The re2 pattern of the ClickHouse {@code EXCEPT 'pattern'} form, mutually exclusive with + * {@link #getExceptColumns()}. + */ + public StringValue getExceptPattern() { + return exceptPattern; + } + + public ColumnsTransformer setExceptPattern(StringValue exceptPattern) { + this.exceptPattern = exceptPattern; + if (exceptPattern != null) { + this.exceptColumns = null; + } + return this; + } + + /** + * The {@code STRICT} modifier of ClickHouse {@code EXCEPT}/{@code REPLACE} transformers: named + * columns must exist, otherwise the database rejects the query. Meaningless for {@code APPLY} + * and {@code EXCLUDE}. + */ + public boolean isStrict() { + return strict; + } + + public ColumnsTransformer setStrict(boolean strict) { + this.strict = strict; + return this; + } + + public List> getReplaceItems() { + return replaceItems; + } + + public ColumnsTransformer setReplaceItems(List> replaceItems) { + this.replaceItems = replaceItems; + return this; + } + + /** DuckDB's {@code RENAME (column AS name, ...)}: each item is a column with its new name. */ + public List> getRenameItems() { + return renameItems; + } + + public ColumnsTransformer setRenameItems(List> renameItems) { + this.renameItems = renameItems; + return this; + } + + /** + * Whether the columns or items of an {@code EXCLUDE}, {@code REPLACE} or {@code RENAME} are + * parenthesized; DuckDB also accepts a single one without parentheses, e.g. + * {@code * EXCLUDE i}. + */ + public boolean isParenthesized() { + return parenthesized; + } + + public ColumnsTransformer setParenthesized(boolean parenthesized) { + this.parenthesized = parenthesized; + return this; + } + + void collectExpressions(List expressions) { + switch (type) { + case APPLY: + if (applyExpression != null) { + expressions.add(applyExpression); + } + break; + case EXCEPT: + if (exceptPattern != null) { + expressions.add(exceptPattern); + } + if (exceptColumns != null) { + expressions.addAll(exceptColumns); + } + break; + case EXCLUDE: + if (exceptColumns != null) { + expressions.addAll(exceptColumns); + } + break; + case REPLACE: + if (replaceItems != null) { + for (SelectItem item : replaceItems) { + expressions.add(item.getExpression()); + } + } + break; + case RENAME: + if (renameItems != null) { + for (SelectItem item : renameItems) { + expressions.add(item.getExpression()); + } + } + break; + default: + throw new IllegalStateException("Unhandled ColumnsTransformerType: " + type); + } + } + + public StringBuilder appendTo(StringBuilder builder) { + switch (type) { + case APPLY: + builder.append("APPLY(").append(applyExpression).append(")"); + break; + case EXCEPT: + builder.append("EXCEPT").append(strict ? " STRICT" : "").append(" ") + .append(exceptPattern != null ? exceptPattern : exceptColumns); + break; + case EXCLUDE: + builder.append("EXCLUDE ").append(parenthesized || exceptColumns.size() != 1 + ? exceptColumns + : exceptColumns.get(0)); + break; + case REPLACE: + boolean replaceParenthesized = parenthesized || replaceItems.size() != 1; + builder.append("REPLACE").append(strict ? " STRICT" : "") + .append(replaceParenthesized ? "(" : " ") + .append(Select.getStringList(replaceItems)) + .append(replaceParenthesized ? ")" : ""); + break; + case RENAME: + boolean renameParenthesized = parenthesized || renameItems.size() != 1; + builder.append("RENAME ").append(renameParenthesized ? "(" : "") + .append(Select.getStringList(renameItems)) + .append(renameParenthesized ? ")" : ""); + break; + default: + throw new IllegalStateException("Unhandled ColumnsTransformerType: " + type); + } + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/ConnectByPriorOperator.java b/src/main/java/net/sf/jsqlparser/expression/ConnectByPriorOperator.java new file mode 100644 index 0000000000..45c2fde6a3 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/ConnectByPriorOperator.java @@ -0,0 +1,74 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2021 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +/* + * Copyright (C) 2021 JSQLParser. + * + * This library is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version + * 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; + * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.schema.Column; + +import java.util.Objects; + +/** + * + * @author are + */ +public class ConnectByPriorOperator extends ASTNodeAccessImpl implements Expression { + private final Expression expression; + + @Deprecated + public ConnectByPriorOperator(Column column) { + this.expression = Objects.requireNonNull(column, + "The COLUMN of the ConnectByPrior Operator must not be null"); + } + + public ConnectByPriorOperator(Expression column) { + this.expression = Objects.requireNonNull(column, + "The COLUMN of the ConnectByPrior Operator must not be null"); + } + + @Deprecated + public Expression getColumn() { + return getExpression(); + } + + public Expression getExpression() { + return expression; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public StringBuilder appendTo(StringBuilder builder) { + builder.append("PRIOR ").append(expression); + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/ConnectByRootOperator.java b/src/main/java/net/sf/jsqlparser/expression/ConnectByRootOperator.java new file mode 100644 index 0000000000..776dc031ed --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/ConnectByRootOperator.java @@ -0,0 +1,74 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2021 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +/* + * Copyright (C) 2021 JSQLParser. + * + * This library is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version + * 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; + * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +package net.sf.jsqlparser.expression; + +import java.util.Objects; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.schema.Column; + +/** + * @author are + */ +public class ConnectByRootOperator extends ASTNodeAccessImpl implements Expression { + private final Expression expression; + + @Deprecated + public ConnectByRootOperator(Column column) { + this.expression = Objects.requireNonNull(column, + "The COLUMN of the ConnectByRoot Operator must not be null"); + } + + public ConnectByRootOperator(Expression column) { + this.expression = Objects.requireNonNull(column, + "The EXPRESSION of the ConnectByRoot Operator must not be null"); + } + + @Deprecated + public Expression getColumn() { + return expression; + } + + public Expression getExpression() { + return expression; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public StringBuilder appendTo(StringBuilder builder) { + builder.append("CONNECT_BY_ROOT ").append(expression); + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } + +} diff --git a/src/main/java/net/sf/jsqlparser/expression/DateTimeLiteralExpression.java b/src/main/java/net/sf/jsqlparser/expression/DateTimeLiteralExpression.java new file mode 100644 index 0000000000..c2873bfb08 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/DateTimeLiteralExpression.java @@ -0,0 +1,63 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.Locale; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class DateTimeLiteralExpression extends ASTNodeAccessImpl implements Expression { + + private String value; + private DateTime type; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public DateTime getType() { + return type; + } + + public void setType(DateTime type) { + this.type = type; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + return type != null ? type.name() + " " + value : value; + } + + public DateTimeLiteralExpression withValue(String value) { + this.setValue(value); + return this; + } + + public DateTimeLiteralExpression withType(DateTime type) { + this.setType(type); + return this; + } + + public enum DateTime { + DATE, DATETIME, TIME, TIMESTAMP, TIMESTAMPTZ; + + public static DateTime from(String dateTimeStr) { + return Enum.valueOf(DateTime.class, dateTimeStr.toUpperCase(Locale.ROOT)); + } + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/DateUnitExpression.java b/src/main/java/net/sf/jsqlparser/expression/DateUnitExpression.java new file mode 100644 index 0000000000..f3c4adfd4b --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/DateUnitExpression.java @@ -0,0 +1,67 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.Locale; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +import java.util.Objects; + +public class DateUnitExpression extends ASTNodeAccessImpl implements Expression { + + private final DateUnit type; + + private final String text; + + public DateUnitExpression(DateUnit type) { + this.type = Objects.requireNonNull(type); + this.text = type.toString(); + } + + public DateUnitExpression(String DateUnitStr) { + this.type = Objects.requireNonNull(DateUnit.from(DateUnitStr)); + this.text = DateUnitStr; + } + + public DateUnit getType() { + return type; + } + + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + return text; + } + + public enum DateUnit { + CENTURY, DECADE, YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND, MICROSECOND, NANOSECOND, SQL_TSI_FRAC_SECOND, SQL_TSI_SECOND, SQL_TSI_MINUTE, SQL_TSI_HOUR, SQL_TSI_DAY, SQL_TSI_WEEK, SQL_TSI_MONTH, SQL_TSI_QUARTER, SQL_TSI_YEAR; + + /** Returns an ODBC interval keyword, or null when the text is not one. */ + public static DateUnit fromOdbcInterval(String text) { + if (text == null || !text.toUpperCase(Locale.ROOT).startsWith("SQL_TSI_")) { + return null; + } + try { + return from(text); + } catch (IllegalArgumentException exception) { + return null; + } + } + + public static DateUnit from(String UnitStr) { + return Enum.valueOf(DateUnit.class, UnitStr.toUpperCase(Locale.ROOT)); + } + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/DateValue.java b/src/main/java/net/sf/jsqlparser/expression/DateValue.java index 1ea097ea8b..d03a73c66d 100644 --- a/src/main/java/net/sf/jsqlparser/expression/DateValue.java +++ b/src/main/java/net/sf/jsqlparser/expression/DateValue.java @@ -1,49 +1,62 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + import java.sql.Date; /** * A Date in the form {d 'yyyy-mm-dd'} */ -public class DateValue implements Expression { +public class DateValue extends ASTNodeAccessImpl implements Expression { + + private Date value; + + public DateValue() { + // empty constructor + } + + public DateValue(Date value) { + this.value = value; + } + + /** + * A Date in the form {d 'yyyy-mm-dd'} + * + * @param value The text presentation of the Date to be parsed. + */ + public DateValue(String value) { + this(Date.valueOf(value.substring(1, value.length() - 1))); + } - private Date value; + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } - public DateValue(String value) { - this.value = Date.valueOf(value.substring(1, value.length() - 1)); - } + public Date getValue() { + return value; + } - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public void setValue(Date d) { + value = d; + } - public Date getValue() { - return value; - } + @Override + public String toString() { + return "{d '" + value.toString() + "'}"; + } - public void setValue(Date d) { - value = d; - } + public DateValue withValue(Date value) { + this.setValue(value); + return this; + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/DoubleValue.java b/src/main/java/net/sf/jsqlparser/expression/DoubleValue.java index e56dbef7c8..8d25aa61a8 100644 --- a/src/main/java/net/sf/jsqlparser/expression/DoubleValue.java +++ b/src/main/java/net/sf/jsqlparser/expression/DoubleValue.java @@ -1,58 +1,66 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + /** * Every number with a point or a exponential format is a DoubleValue */ -public class DoubleValue implements Expression { - - private double value; - private String stringValue; - - public DoubleValue(final String value) { - String val = value; - if (val.charAt(0) == '+') { - val = val.substring(1); - } - this.value = Double.parseDouble(val); - this.stringValue = val; - } - - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } - - public double getValue() { - return value; - } - - public void setValue(double d) { - value = d; - } - - @Override - public String toString() { - return stringValue; - } +public class DoubleValue extends ASTNodeAccessImpl implements Expression { + + private Double value; + private String stringValue; + + public DoubleValue() { + // empty constructor + } + + public DoubleValue(final String value) { + if (value == null || value.length() == 0) { + throw new IllegalArgumentException("value can neither be null nor empty."); + } + String val = value; + if (val.charAt(0) == '+') { + val = val.substring(1); + } + this.value = Double.parseDouble(val); + this.stringValue = val; + } + + public DoubleValue(final double value) { + this.value = value; + this.stringValue = String.valueOf(value); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public double getValue() { + return value; + } + + public void setValue(Double d) { + value = d; + stringValue = String.valueOf(value); + } + + @Override + public String toString() { + return stringValue; + } + + public DoubleValue withValue(Double value) { + this.setValue(value); + return this; + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/Expression.java b/src/main/java/net/sf/jsqlparser/expression/Expression.java index 409dbb21f1..1f733d5643 100644 --- a/src/main/java/net/sf/jsqlparser/expression/Expression.java +++ b/src/main/java/net/sf/jsqlparser/expression/Expression.java @@ -1,27 +1,23 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; -public interface Expression { +import net.sf.jsqlparser.Model; +import net.sf.jsqlparser.parser.ASTNodeAccess; + +public interface Expression extends ASTNodeAccess, Model { + + T accept(ExpressionVisitor expressionVisitor, S context); + + default void accept(ExpressionVisitor expressionVisitor) { + this.accept(expressionVisitor, null); + } - void accept(ExpressionVisitor expressionVisitor); } diff --git a/src/main/java/net/sf/jsqlparser/expression/ExpressionVisitor.java b/src/main/java/net/sf/jsqlparser/expression/ExpressionVisitor.java index 16a5622019..4a6b4ef27e 100644 --- a/src/main/java/net/sf/jsqlparser/expression/ExpressionVisitor.java +++ b/src/main/java/net/sf/jsqlparser/expression/ExpressionVisitor.java @@ -1,151 +1,914 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import java.util.List; +import net.sf.jsqlparser.statement.execute.ExecuteArgument; import net.sf.jsqlparser.expression.operators.arithmetic.Addition; import net.sf.jsqlparser.expression.operators.arithmetic.BitwiseAnd; +import net.sf.jsqlparser.expression.operators.arithmetic.BitwiseLeftShift; import net.sf.jsqlparser.expression.operators.arithmetic.BitwiseOr; +import net.sf.jsqlparser.expression.operators.arithmetic.BitwiseRightShift; import net.sf.jsqlparser.expression.operators.arithmetic.BitwiseXor; import net.sf.jsqlparser.expression.operators.arithmetic.Concat; import net.sf.jsqlparser.expression.operators.arithmetic.Division; +import net.sf.jsqlparser.expression.operators.arithmetic.Exponentiation; +import net.sf.jsqlparser.expression.operators.arithmetic.IntegerDivision; import net.sf.jsqlparser.expression.operators.arithmetic.Modulo; import net.sf.jsqlparser.expression.operators.arithmetic.Multiplication; import net.sf.jsqlparser.expression.operators.arithmetic.Subtraction; import net.sf.jsqlparser.expression.operators.conditional.AndExpression; import net.sf.jsqlparser.expression.operators.conditional.OrExpression; +import net.sf.jsqlparser.expression.operators.conditional.XorExpression; import net.sf.jsqlparser.expression.operators.relational.Between; +import net.sf.jsqlparser.expression.operators.relational.ContainedBy; +import net.sf.jsqlparser.expression.operators.relational.Contains; +import net.sf.jsqlparser.expression.operators.relational.CosineSimilarity; +import net.sf.jsqlparser.expression.operators.relational.DoubleAnd; import net.sf.jsqlparser.expression.operators.relational.EqualsTo; +import net.sf.jsqlparser.expression.operators.relational.ExcludesExpression; import net.sf.jsqlparser.expression.operators.relational.ExistsExpression; +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.expression.operators.relational.FullTextSearch; +import net.sf.jsqlparser.expression.operators.relational.GeometryDistance; import net.sf.jsqlparser.expression.operators.relational.GreaterThan; import net.sf.jsqlparser.expression.operators.relational.GreaterThanEquals; import net.sf.jsqlparser.expression.operators.relational.InExpression; +import net.sf.jsqlparser.expression.operators.relational.IncludesExpression; +import net.sf.jsqlparser.expression.operators.relational.Intersects; +import net.sf.jsqlparser.expression.operators.relational.IsBooleanExpression; +import net.sf.jsqlparser.expression.operators.relational.IsDistinctExpression; +import net.sf.jsqlparser.expression.operators.relational.IsNormalizedExpression; import net.sf.jsqlparser.expression.operators.relational.IsNullExpression; +import net.sf.jsqlparser.expression.operators.relational.IsUnknownExpression; +import net.sf.jsqlparser.expression.operators.relational.IsJsonExpression; +import net.sf.jsqlparser.expression.operators.relational.JsonOperator; import net.sf.jsqlparser.expression.operators.relational.LikeExpression; import net.sf.jsqlparser.expression.operators.relational.Matches; +import net.sf.jsqlparser.expression.operators.relational.MemberOfExpression; import net.sf.jsqlparser.expression.operators.relational.MinorThan; import net.sf.jsqlparser.expression.operators.relational.MinorThanEquals; import net.sf.jsqlparser.expression.operators.relational.NotEqualsTo; +import net.sf.jsqlparser.expression.operators.relational.Plus; +import net.sf.jsqlparser.expression.operators.relational.PriorTo; import net.sf.jsqlparser.expression.operators.relational.RegExpMatchOperator; -import net.sf.jsqlparser.expression.operators.relational.RegExpMySQLOperator; +import net.sf.jsqlparser.expression.operators.relational.SimilarToExpression; +import net.sf.jsqlparser.expression.operators.relational.TSQLLeftJoin; +import net.sf.jsqlparser.expression.operators.relational.TSQLRightJoin; import net.sf.jsqlparser.schema.Column; -import net.sf.jsqlparser.statement.select.SubSelect; +import net.sf.jsqlparser.statement.piped.FromQuery; +import net.sf.jsqlparser.statement.select.AllColumns; +import net.sf.jsqlparser.statement.select.AllTableColumns; +import net.sf.jsqlparser.statement.select.FunctionAllColumns; +import net.sf.jsqlparser.statement.select.GroupByElement; +import net.sf.jsqlparser.statement.select.Limit; +import net.sf.jsqlparser.statement.select.OrderByElement; +import net.sf.jsqlparser.statement.select.ParenthesedSelect; +import net.sf.jsqlparser.statement.select.Select; +import net.sf.jsqlparser.statement.update.UpdateSet; + +public interface ExpressionVisitor { + /** Visits the value of an aliased expression by default, preserving existing visitors. */ + default T visit(AliasedExpression expression, S context) { + return expression.getExpression().accept(this, context); + } + + default void visit(AliasedExpression expression) { + visit(expression, null); + } + + + default T visit(ExecuteArgument argument, S context) { + return argument.getExpression().accept(this, context); + } + + default T visitExpressions(ExpressionList expressions, S context) { + if (expressions != null) { + expressions.forEach(expression -> expression.accept(this, context)); + } + return null; + }; + + default T visitExpression(Expression expression, S context) { + if (expression != null) { + expression.accept(this, context); + } + return null; + } + + default T visitOrderBy(List orderByElements, S context) { + if (orderByElements != null) { + for (OrderByElement orderByElement : orderByElements) { + orderByElement.getExpression().accept(this, context); + } + } + return null; + } + + default T visitLimit(Limit limit, S context) { + if (limit != null && !limit.isLimitNull() && !limit.isLimitAll()) { + if (limit.getOffset() != null) { + limit.getOffset().accept(this, context); + } + if (limit.getRowCount() != null) { + limit.getRowCount().accept(this, context); + } + if (limit.getByExpressions() != null) { + limit.getByExpressions().accept(this, context); + } + } + return null; + } + + default T visitPreferringClause(PreferringClause preferringClause, S context) { + if (preferringClause != null) { + if (preferringClause.getPreferring() != null) { + preferringClause.getPreferring().accept(this, context); + } + if (preferringClause.getPartitionBy() != null) { + for (Expression expression : preferringClause.getPartitionBy()) { + expression.accept(this, context); + } + } + } + return null; + } + + default T visitUpdateSets(List updateSets, S context) { + if (updateSets != null) { + for (UpdateSet updateSet : updateSets) { + for (Column column : updateSet.getColumns()) { + column.accept(this, context); + } + for (Expression value : updateSet.getValues()) { + value.accept(this, context); + } + } + } + return null; + } + + default T visit(GroupByElement groupBy, S context) { + if (groupBy != null) { + for (Expression expression : groupBy.getGroupByExpressionList()) { + expression.accept(this, context); + } + if (!groupBy.getGroupingSets().isEmpty()) { + for (ExpressionList expressionList : groupBy.getGroupingSets()) { + expressionList.accept(this, context); + } + } + } + return null; + } + + T visit(BitwiseRightShift bitwiseRightShift, S context); + + default void visit(BitwiseRightShift bitwiseRightShift) { + this.visit(bitwiseRightShift, null); + } + + T visit(BitwiseLeftShift bitwiseLeftShift, S context); + + default void visit(BitwiseLeftShift bitwiseLeftShift) { + this.visit(bitwiseLeftShift, null); + } + + T visit(NullValue nullValue, S context); + + default void visit(NullValue nullValue) { + this.visit(nullValue, null); + } + + T visit(Function function, S context); + + default void visit(Function function) { + this.visit(function, null); + } + + T visit(SignedExpression signedExpression, S context); + + default void visit(SignedExpression signedExpression) { + this.visit(signedExpression, null); + } + + T visit(JdbcParameter jdbcParameter, S context); + + default void visit(JdbcParameter jdbcParameter) { + this.visit(jdbcParameter, null); + } + + T visit(JdbcNamedParameter jdbcNamedParameter, S context); -public interface ExpressionVisitor { + default void visit(JdbcNamedParameter jdbcNamedParameter) { + this.visit(jdbcNamedParameter, null); + } - void visit(NullValue nullValue); + T visit(DoubleValue doubleValue, S context); - void visit(Function function); + default void visit(DoubleValue doubleValue) { + this.visit(doubleValue, null); + } - void visit(SignedExpression signedExpression); + T visit(LongValue longValue, S context); - void visit(JdbcParameter jdbcParameter); + default void visit(LongValue longValue) { + this.visit(longValue, null); + } - void visit(JdbcNamedParameter jdbcNamedParameter); + T visit(HexValue hexValue, S context); - void visit(DoubleValue doubleValue); + default void visit(HexValue hexValue) { + this.visit(hexValue, null); + } - void visit(LongValue longValue); + T visit(DateValue dateValue, S context); - void visit(DateValue dateValue); + default void visit(DateValue dateValue) { + this.visit(dateValue, null); + } - void visit(TimeValue timeValue); + T visit(TimeValue timeValue, S context); - void visit(TimestampValue timestampValue); + default void visit(TimeValue timeValue) { + this.visit(timeValue, null); + } - void visit(Parenthesis parenthesis); + T visit(TimestampValue timestampValue, S context); - void visit(StringValue stringValue); + default void visit(TimestampValue timestampValue) { + this.visit(timestampValue, null); + } - void visit(Addition addition); + T visit(StringValue stringValue, S context); - void visit(Division division); + default void visit(StringValue stringValue) { + this.visit(stringValue, null); + } - void visit(Multiplication multiplication); + T visit(BooleanValue booleanValue, S context); - void visit(Subtraction subtraction); + default void visit(BooleanValue booleanValue) { + this.visit(booleanValue, null); + } - void visit(AndExpression andExpression); + T visit(Addition addition, S context); - void visit(OrExpression orExpression); + default void visit(Addition addition) { + this.visit(addition, null); + } - void visit(Between between); + T visit(Division division, S context); - void visit(EqualsTo equalsTo); + default void visit(Division division) { + this.visit(division, null); + } - void visit(GreaterThan greaterThan); + T visit(IntegerDivision integerDivision, S context); - void visit(GreaterThanEquals greaterThanEquals); + default T visit(Exponentiation exponentiation, S context) { + visitExpression(exponentiation.getLeftExpression(), context); + return visitExpression(exponentiation.getRightExpression(), context); + } - void visit(InExpression inExpression); + default void visit(Exponentiation exponentiation) { + this.visit(exponentiation, null); + } - void visit(IsNullExpression isNullExpression); + default void visit(IntegerDivision integerDivision) { + this.visit(integerDivision, null); + } - void visit(LikeExpression likeExpression); + T visit(Multiplication multiplication, S context); - void visit(MinorThan minorThan); + default void visit(Multiplication multiplication) { + this.visit(multiplication, null); + } - void visit(MinorThanEquals minorThanEquals); + T visit(Subtraction subtraction, S context); - void visit(NotEqualsTo notEqualsTo); + default void visit(Subtraction subtraction) { + this.visit(subtraction, null); + } - void visit(Column tableColumn); + T visit(AndExpression andExpression, S context); - void visit(SubSelect subSelect); + default void visit(AndExpression andExpression) { + this.visit(andExpression, null); + } - void visit(CaseExpression caseExpression); + T visit(OrExpression orExpression, S context); - void visit(WhenClause whenClause); + default void visit(OrExpression orExpression) { + this.visit(orExpression, null); + } - void visit(ExistsExpression existsExpression); + T visit(XorExpression xorExpression, S context); - void visit(AllComparisonExpression allComparisonExpression); + default void visit(XorExpression xorExpression) { + this.visit(xorExpression, null); + } - void visit(AnyComparisonExpression anyComparisonExpression); + T visit(Between between, S context); - void visit(Concat concat); + default void visit(Between between) { + this.visit(between, null); + } - void visit(Matches matches); + T visit(OverlapsCondition overlapsCondition, S context); - void visit(BitwiseAnd bitwiseAnd); + default void visit(OverlapsCondition overlapsCondition) { + this.visit(overlapsCondition, null); + } - void visit(BitwiseOr bitwiseOr); + T visit(EqualsTo equalsTo, S context); - void visit(BitwiseXor bitwiseXor); + default void visit(EqualsTo equalsTo) { + this.visit(equalsTo, null); + } - void visit(CastExpression cast); + T visit(GreaterThan greaterThan, S context); - void visit(Modulo modulo); + default void visit(GreaterThan greaterThan) { + this.visit(greaterThan, null); + } - void visit(AnalyticExpression aexpr); + T visit(GreaterThanEquals greaterThanEquals, S context); - void visit(ExtractExpression eexpr); + default void visit(GreaterThanEquals greaterThanEquals) { + this.visit(greaterThanEquals, null); + } - void visit(IntervalExpression iexpr); + T visit(InExpression inExpression, S context); - void visit(OracleHierarchicalExpression oexpr); + default void visit(InExpression inExpression) { + this.visit(inExpression, null); + } - void visit(RegExpMatchOperator rexpr); - - void visit(JsonExpression jsonExpr); + T visit(IncludesExpression includesExpression, S context); - void visit(RegExpMySQLOperator regExpMySQLOperator); + default void visit(IncludesExpression includesExpression) { + this.visit(includesExpression, null); + } + + T visit(ExcludesExpression excludesExpression, S context); + + default void visit(ExcludesExpression excludesExpression) { + this.visit(excludesExpression, null); + } + + T visit(FullTextSearch fullTextSearch, S context); + + default void visit(FullTextSearch fullTextSearch) { + this.visit(fullTextSearch, null); + } + + T visit(IsNullExpression isNullExpression, S context); + + default void visit(IsNullExpression isNullExpression) { + this.visit(isNullExpression, null); + } + + T visit(IsBooleanExpression isBooleanExpression, S context); + + default void visit(IsBooleanExpression isBooleanExpression) { + this.visit(isBooleanExpression, null); + } + + default T visit(IsJsonExpression expression, S context) { + return expression.getLeftExpression().accept(this, context); + } + + default void visit(IsJsonExpression expression) { + visit(expression, null); + } + + T visit(IsUnknownExpression isUnknownExpression, S context); + + default void visit(IsUnknownExpression isUnknownExpression) { + this.visit(isUnknownExpression, null); + } + + default T visit(IsNormalizedExpression isNormalizedExpression, S context) { + return isNormalizedExpression.getLeftExpression().accept(this, context); + } + + default void visit(IsNormalizedExpression isNormalizedExpression) { + this.visit(isNormalizedExpression, null); + } + + T visit(LikeExpression likeExpression, S context); + + default void visit(LikeExpression likeExpression) { + this.visit(likeExpression, null); + } + + T visit(MinorThan minorThan, S context); + + default void visit(MinorThan minorThan) { + this.visit(minorThan, null); + } + + T visit(MinorThanEquals minorThanEquals, S context); + + default void visit(MinorThanEquals minorThanEquals) { + this.visit(minorThanEquals, null); + } + + T visit(NotEqualsTo notEqualsTo, S context); + + default void visit(NotEqualsTo notEqualsTo) { + this.visit(notEqualsTo, null); + } + + T visit(DoubleAnd doubleAnd, S context); + + default void visit(DoubleAnd doubleAnd) { + this.visit(doubleAnd, null); + } + + T visit(Contains contains, S context); + + default void visit(Contains contains) { + this.visit(contains, null); + } + + T visit(ContainedBy containedBy, S context); + + default void visit(ContainedBy containedBy) { + this.visit(containedBy, null); + } + + T visit(ParenthesedSelect select, S context); + + T visit(Column column, S context); + + default void visit(Column column) { + this.visit(column, null); + } + + T visit(CaseExpression caseExpression, S context); + + default void visit(CaseExpression caseExpression) { + this.visit(caseExpression, null); + } + + T visit(WhenClause whenClause, S context); + + default void visit(WhenClause whenClause) { + this.visit(whenClause, null); + } + + T visit(ExistsExpression existsExpression, S context); + + default void visit(ExistsExpression existsExpression) { + this.visit(existsExpression, null); + } + + T visit(MemberOfExpression memberOfExpression, S context); + + default void visit(MemberOfExpression memberOfExpression) { + this.visit(memberOfExpression, null); + } + + T visit(AnyComparisonExpression anyComparisonExpression, S context); + + default void visit(AnyComparisonExpression anyComparisonExpression) { + this.visit(anyComparisonExpression, null); + } + + T visit(Concat concat, S context); + + default void visit(Concat concat) { + this.visit(concat, null); + } + + T visit(Matches matches, S context); + + default void visit(Matches matches) { + this.visit(matches, null); + } + + T visit(BitwiseAnd bitwiseAnd, S context); + + default void visit(BitwiseAnd bitwiseAnd) { + this.visit(bitwiseAnd, null); + } + + T visit(BitwiseOr bitwiseOr, S context); + + default void visit(BitwiseOr bitwiseOr) { + this.visit(bitwiseOr, null); + } + + T visit(BitwiseXor bitwiseXor, S context); + + default void visit(BitwiseXor bitwiseXor) { + this.visit(bitwiseXor, null); + } + + T visit(CastExpression castExpression, S context); + + default void visit(CastExpression castExpression) { + this.visit(castExpression, null); + } + + T visit(Modulo modulo, S context); + + default void visit(Modulo modulo) { + this.visit(modulo, null); + } + + T visit(AnalyticExpression analyticExpression, S context); + + default void visit(AnalyticExpression analyticExpression) { + this.visit(analyticExpression, null); + } + + T visit(ExtractExpression extractExpression, S context); + + default void visit(ExtractExpression extractExpression) { + this.visit(extractExpression, null); + } + + default T visit(RowPatternFunction function, S context) { + return function.getFunction().accept(this, context); + } + + default void visit(RowPatternFunction function) { + visit(function, null); + } + + T visit(IntervalExpression intervalExpression, S context); + + default void visit(IntervalExpression intervalExpression) { + this.visit(intervalExpression, null); + } + + T visit(OracleHierarchicalExpression hierarchicalExpression, S context); + + default void visit(OracleHierarchicalExpression hierarchicalExpression) { + this.visit(hierarchicalExpression, null); + } + + T visit(RegExpMatchOperator regExpMatchOperator, S context); + + default void visit(RegExpMatchOperator regExpMatchOperator) { + this.visit(regExpMatchOperator, null); + } + + T visit(JsonExpression jsonExpression, S context); + + default void visit(JsonExpression jsonExpression) { + this.visit(jsonExpression, null); + } + + T visit(JsonOperator jsonOperator, S context); + + default void visit(JsonOperator jsonOperator) { + this.visit(jsonOperator, null); + } + + T visit(UserVariable userVariable, S context); + + default void visit(UserVariable userVariable) { + this.visit(userVariable, null); + } + + T visit(NumericBind numericBind, S context); + + default void visit(NumericBind numericBind) { + this.visit(numericBind, null); + } + + T visit(KeepExpression keepExpression, S context); + + default void visit(KeepExpression keepExpression) { + this.visit(keepExpression, null); + } + + T visit(MySQLGroupConcat groupConcat, S context); + + default void visit(MySQLGroupConcat groupConcat) { + this.visit(groupConcat, null); + } + + T visit(ExpressionList expressionList, S context); + + default void visit(ExpressionList expressionList) { + this.visit(expressionList, null); + } + + T visit(RowConstructor rowConstructor, S context); + + default void visit(RowConstructor rowConstructor) { + this.visit(rowConstructor, null); + } + + T visit(RowGetExpression rowGetExpression, S context); + + default T visit(MethodCallExpression methodCall, S context) { + methodCall.getExpression().accept(this, context); + return methodCall.getMethod().accept(this, context); + } + + default void visit(MethodCallExpression methodCall) { + this.visit(methodCall, null); + } + + default void visit(RowGetExpression rowGetExpression) { + this.visit(rowGetExpression, null); + } + + T visit(OracleHint hint, S context); + + default void visit(OracleHint hint) { + this.visit(hint, null); + } + + T visit(TimeKeyExpression timeKeyExpression, S context); + + default void visit(TimeKeyExpression timeKeyExpression) { + this.visit(timeKeyExpression, null); + } + + T visit(DateTimeLiteralExpression dateTimeLiteralExpression, S context); + + default void visit(DateTimeLiteralExpression dateTimeLiteralExpression) { + this.visit(dateTimeLiteralExpression, null); + } + + T visit(NotExpression notExpression, S context); + + default void visit(NotExpression notExpression) { + this.visit(notExpression, null); + } + + T visit(NextValExpression nextValExpression, S context); + + default void visit(NextValExpression nextValExpression) { + this.visit(nextValExpression, null); + } + + T visit(CollateExpression collateExpression, S context); + + default void visit(CollateExpression collateExpression) { + this.visit(collateExpression, null); + } + + T visit(SimilarToExpression similarToExpression, S context); + + default void visit(SimilarToExpression similarToExpression) { + this.visit(similarToExpression, null); + } + + T visit(ArrayExpression arrayExpression, S context); + + default void visit(ArrayExpression arrayExpression) { + this.visit(arrayExpression, null); + } + + T visit(ArrayConstructor arrayConstructor, S context); + + default void visit(ArrayConstructor arrayConstructor) { + this.visit(arrayConstructor, null); + } + + default T visit(MapExpression mapExpression, S context) { + return null; + } + + default void visit(MapExpression mapExpression) { + this.visit(mapExpression, null); + } + + T visit(VariableAssignment variableAssignment, S context); + + default void visit(VariableAssignment variableAssignment) { + this.visit(variableAssignment, null); + } + + T visit(XMLSerializeExpr xmlSerializeExpr, S context); + + default void visit(XMLSerializeExpr xmlSerializeExpr) { + this.visit(xmlSerializeExpr, null); + } + + T visit(TimezoneExpression timezoneExpression, S context); + + default void visit(TimezoneExpression timezoneExpression) { + this.visit(timezoneExpression, null); + } + + T visit(JsonAggregateFunction jsonAggregateFunction, S context); + + default void visit(JsonAggregateFunction jsonAggregateFunction) { + this.visit(jsonAggregateFunction, null); + } + + T visit(JsonFunction jsonFunction, S context); + + default void visit(JsonFunction jsonFunction) { + this.visit(jsonFunction, null); + } + + default T visit(JsonTableFunction jsonTableFunction, S context) { + return visit((Function) jsonTableFunction, context); + } + + default void visit(JsonTableFunction jsonTableFunction) { + this.visit(jsonTableFunction, null); + } + + default T visit(XmlTableFunction xmlTableFunction, S context) { + return visit((Function) xmlTableFunction, context); + } + + default void visit(XmlTableFunction xmlTableFunction) { + this.visit(xmlTableFunction, null); + } + + T visit(ConnectByRootOperator connectByRootOperator, S context); + + default void visit(ConnectByRootOperator connectByRootOperator) { + this.visit(connectByRootOperator, null); + } + + T visit(ConnectByPriorOperator connectByPriorOperator, S context); + + default void visit(ConnectByPriorOperator connectByPriorOperator) { + this.visit(connectByPriorOperator, null); + } + + T visit(OracleNamedFunctionParameter oracleNamedFunctionParameter, S context); + + default void visit(OracleNamedFunctionParameter oracleNamedFunctionParameter) { + this.visit(oracleNamedFunctionParameter, null); + } + + T visit(AllColumns allColumns, S context); + + T visit(FunctionAllColumns functionColumns, S context); + + default void visit(AllColumns allColumns) { + this.visit(allColumns, null); + } + + T visit(AllTableColumns allTableColumns, S context); + + default void visit(AllTableColumns allTableColumns) { + this.visit(allTableColumns, null); + } + + T visit(AllValue allValue, S context); + + default void visit(AllValue allValue) { + this.visit(allValue, null); + } + + T visit(IsDistinctExpression isDistinctExpression, S context); + + default void visit(IsDistinctExpression isDistinctExpression) { + this.visit(isDistinctExpression, null); + } + + T visit(GeometryDistance geometryDistance, S context); + + default void visit(GeometryDistance geometryDistance) { + this.visit(geometryDistance, null); + } + + T visit(Intersects intersects, S context); + + default void visit(Intersects intersects) { + this.visit(intersects, null); + } + + T visit(Select select, S context); + + T visit(TranscodingFunction transcodingFunction, S context); + + default void visit(TranscodingFunction transcodingFunction) { + this.visit(transcodingFunction, null); + } + + T visit(TrimFunction trimFunction, S context); + + default void visit(TrimFunction trimFunction) { + this.visit(trimFunction, null); + } + + T visit(RangeExpression rangeExpression, S context); + + default void visit(RangeExpression rangeExpression) { + this.visit(rangeExpression, null); + } + + T visit(TernaryExpression ternaryExpression, S context); + + default void visit(TernaryExpression ternaryExpression) { + this.visit(ternaryExpression, null); + } + + T visit(TSQLLeftJoin tsqlLeftJoin, S context); + + default void visit(TSQLLeftJoin tsqlLeftJoin) { + this.visit(tsqlLeftJoin, null); + } + + T visit(TSQLRightJoin tsqlRightJoin, S context); + + default void visit(TSQLRightJoin tsqlRightJoin) { + this.visit(tsqlRightJoin, null); + } + + T visit(StructType structType, S context); + + default void visit(StructType structType) { + this.visit(structType, null); + } + + T visit(LambdaExpression lambdaExpression, S context); + + default void visit(LambdaExpression lambdaExpression) { + this.visit(lambdaExpression, null); + } + + default T visit(ListComprehension listComprehension, S context) { + visitExpression(listComprehension.getExpression(), context); + visitExpression(listComprehension.getList(), context); + return visitExpression(listComprehension.getCondition(), context); + } + + default void visit(ListComprehension listComprehension) { + this.visit(listComprehension, null); + } + + default T visit(ColumnsExpression columnsExpression, S context) { + for (Expression expression : columnsExpression.getAllExpressions()) { + if (expression != null) { + expression.accept(this, context); + } + } + return null; + } + + default void visit(ColumnsExpression columnsExpression) { + this.visit(columnsExpression, null); + } + + T visit(HighExpression highExpression, S context); + + default void visit(HighExpression highExpression) { + this.visit(highExpression, null); + } + + T visit(LowExpression lowExpression, S context); + + default void visit(LowExpression lowExpression) { + this.visit(lowExpression, null); + } + + T visit(Plus plus, S context); + + default void visit(Plus plus) { + this.visit(plus, null); + } + + T visit(PriorTo priorTo, S context); + + default void visit(PriorTo priorTo) { + this.visit(priorTo, null); + } + + T visit(Inverse inverse, S context); + + default void visit(Inverse inverse) { + this.visit(inverse, null); + } + + T visit(CosineSimilarity cosineSimilarity, S context); + + T visit(FromQuery fromQuery, S context); + + T visit(DateUnitExpression dateUnitExpression, S context); + + T visit(KeyExpression keyExpression, S context); + + default void visit(KeyExpression keyExpression) { + this.visit(keyExpression, null); + } + + T visit(PostgresNamedFunctionParameter postgresNamedFunctionParameter, S context); + + default void visit(PostgresNamedFunctionParameter postgresNamedFunctionParameter) { + this.visit(postgresNamedFunctionParameter, null); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/ExpressionVisitorAdapter.java b/src/main/java/net/sf/jsqlparser/expression/ExpressionVisitorAdapter.java index 21c94652d1..11b052239f 100644 --- a/src/main/java/net/sf/jsqlparser/expression/ExpressionVisitorAdapter.java +++ b/src/main/java/net/sf/jsqlparser/expression/ExpressionVisitorAdapter.java @@ -1,315 +1,980 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; -import net.sf.jsqlparser.expression.operators.arithmetic.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import net.sf.jsqlparser.expression.operators.arithmetic.Addition; +import net.sf.jsqlparser.expression.operators.arithmetic.BitwiseAnd; +import net.sf.jsqlparser.expression.operators.arithmetic.BitwiseLeftShift; +import net.sf.jsqlparser.expression.operators.arithmetic.BitwiseOr; +import net.sf.jsqlparser.expression.operators.arithmetic.BitwiseRightShift; +import net.sf.jsqlparser.expression.operators.arithmetic.BitwiseXor; +import net.sf.jsqlparser.expression.operators.arithmetic.Concat; +import net.sf.jsqlparser.expression.operators.arithmetic.Division; +import net.sf.jsqlparser.expression.operators.arithmetic.Exponentiation; +import net.sf.jsqlparser.expression.operators.arithmetic.IntegerDivision; +import net.sf.jsqlparser.expression.operators.arithmetic.Modulo; +import net.sf.jsqlparser.expression.operators.arithmetic.Multiplication; +import net.sf.jsqlparser.expression.operators.arithmetic.Subtraction; import net.sf.jsqlparser.expression.operators.conditional.AndExpression; import net.sf.jsqlparser.expression.operators.conditional.OrExpression; -import net.sf.jsqlparser.expression.operators.relational.*; +import net.sf.jsqlparser.expression.operators.conditional.XorExpression; +import net.sf.jsqlparser.expression.operators.relational.Between; +import net.sf.jsqlparser.expression.operators.relational.ContainedBy; +import net.sf.jsqlparser.expression.operators.relational.Contains; +import net.sf.jsqlparser.expression.operators.relational.CosineSimilarity; +import net.sf.jsqlparser.expression.operators.relational.DoubleAnd; +import net.sf.jsqlparser.expression.operators.relational.EqualsTo; +import net.sf.jsqlparser.expression.operators.relational.ExcludesExpression; +import net.sf.jsqlparser.expression.operators.relational.ExistsExpression; +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.expression.operators.relational.FullTextSearch; +import net.sf.jsqlparser.expression.operators.relational.GeometryDistance; +import net.sf.jsqlparser.expression.operators.relational.GreaterThan; +import net.sf.jsqlparser.expression.operators.relational.GreaterThanEquals; +import net.sf.jsqlparser.expression.operators.relational.InExpression; +import net.sf.jsqlparser.expression.operators.relational.IncludesExpression; +import net.sf.jsqlparser.expression.operators.relational.Intersects; +import net.sf.jsqlparser.expression.operators.relational.IsBooleanExpression; +import net.sf.jsqlparser.expression.operators.relational.IsDistinctExpression; +import net.sf.jsqlparser.expression.operators.relational.IsNormalizedExpression; +import net.sf.jsqlparser.expression.operators.relational.IsNullExpression; +import net.sf.jsqlparser.expression.operators.relational.IsUnknownExpression; +import net.sf.jsqlparser.expression.operators.relational.JsonOperator; +import net.sf.jsqlparser.expression.operators.relational.LikeExpression; +import net.sf.jsqlparser.expression.operators.relational.Matches; +import net.sf.jsqlparser.expression.operators.relational.MemberOfExpression; +import net.sf.jsqlparser.expression.operators.relational.MinorThan; +import net.sf.jsqlparser.expression.operators.relational.MinorThanEquals; +import net.sf.jsqlparser.expression.operators.relational.NotEqualsTo; +import net.sf.jsqlparser.expression.operators.relational.Plus; +import net.sf.jsqlparser.expression.operators.relational.PriorTo; +import net.sf.jsqlparser.expression.operators.relational.RegExpMatchOperator; +import net.sf.jsqlparser.expression.operators.relational.SimilarToExpression; +import net.sf.jsqlparser.expression.operators.relational.TSQLLeftJoin; +import net.sf.jsqlparser.expression.operators.relational.TSQLRightJoin; import net.sf.jsqlparser.schema.Column; +import net.sf.jsqlparser.statement.piped.FromQuery; +import net.sf.jsqlparser.statement.select.AllColumns; +import net.sf.jsqlparser.statement.select.AllTableColumns; +import net.sf.jsqlparser.statement.select.FunctionAllColumns; import net.sf.jsqlparser.statement.select.OrderByElement; -import net.sf.jsqlparser.statement.select.SubSelect; +import net.sf.jsqlparser.statement.select.ParenthesedSelect; +import net.sf.jsqlparser.statement.select.Pivot; +import net.sf.jsqlparser.statement.select.PivotVisitor; +import net.sf.jsqlparser.statement.select.PivotXml; +import net.sf.jsqlparser.statement.select.Select; +import net.sf.jsqlparser.statement.select.SelectItem; +import net.sf.jsqlparser.statement.select.SelectItemVisitor; +import net.sf.jsqlparser.statement.select.SelectVisitor; +import net.sf.jsqlparser.statement.select.UnPivot; +import net.sf.jsqlparser.statement.select.WithItem; + +@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.UncommentedEmptyMethodBody"}) +public class ExpressionVisitorAdapter + implements ExpressionVisitor, PivotVisitor, SelectItemVisitor { + + private SelectVisitor selectVisitor; + + public ExpressionVisitorAdapter(SelectVisitor selectVisitor) { + this.selectVisitor = selectVisitor; + } + + public ExpressionVisitorAdapter() { + this.selectVisitor = null; + } + + public SelectVisitor getSelectVisitor() { + return selectVisitor; + } + + public ExpressionVisitorAdapter setSelectVisitor(SelectVisitor selectVisitor) { + this.selectVisitor = selectVisitor; + return this; + } + + @Override + public T visit(NullValue nullValue, S context) { + return applyExpression(nullValue, context); + } + + @Override + public T visit(Function function, S context) { + ArrayList subExpressions = new ArrayList<>(); + if (function.getParameters() != null) { + subExpressions.addAll(function.getParameters()); + } + if (function.getNamedParameters() != null) { + subExpressions.addAll(function.getNamedParameters()); + } + if (function.getChainedParameters() != null) { + subExpressions.addAll(function.getChainedParameters()); + } + // an attribute name is not a column reference, only an attribute expression is visited + if (function.getAttribute() instanceof Expression + && function.getAttribute() != function.getAttributeColumn()) { + subExpressions.add((Expression) function.getAttribute()); + } + if (function.getKeep() != null) { + subExpressions.add(function.getKeep()); + } + addOrderByExpressions(subExpressions, function.getOrderByElements()); + addFunctionModifiers(subExpressions, function.getHavingClause(), + function.getKeywordArguments(), function.getLimit()); + return visitExpressions(function, context, subExpressions); + } + + @Override + public T visit(SignedExpression signedExpression, S context) { + return signedExpression.getExpression().accept(this, context); + } + + @Override + public T visit(JdbcParameter jdbcParameter, S context) { + return applyExpression(jdbcParameter, context); + } + + @Override + public T visit(JdbcNamedParameter jdbcNamedParameter, S context) { + return applyExpression(jdbcNamedParameter, context); + } + + @Override + public T visit(DoubleValue doubleValue, S context) { + return applyExpression(doubleValue, context); + } + + @Override + public T visit(LongValue longValue, S context) { + return applyExpression(longValue, context); + } + + @Override + public T visit(DateValue dateValue, S context) { + return applyExpression(dateValue, context); + } + + @Override + public T visit(TimeValue timeValue, S context) { + return applyExpression(timeValue, context); + } + + @Override + public T visit(TimestampValue timestampValue, S context) { + return applyExpression(timestampValue, context); + } + + @Override + public T visit(StringValue stringValue, S context) { + return applyExpression(stringValue, context); + } + + @Override + public T visit(BooleanValue booleanValue, S context) { + return applyExpression(booleanValue, context); + } + + @Override + public T visit(Addition addition, S context) { + return visitBinaryExpression(addition, context); + } + + @Override + public T visit(Division division, S context) { + return visitBinaryExpression(division, context); + } + + @Override + public T visit(IntegerDivision integerDivision, S context) { + return visitBinaryExpression(integerDivision, context); + } + + @Override + public T visit(Exponentiation exponentiation, S context) { + return visitBinaryExpression(exponentiation, context); + } + + @Override + public T visit(Multiplication multiplication, S context) { + return visitBinaryExpression(multiplication, context); + } + + @Override + public T visit(Subtraction subtraction, S context) { + return visitBinaryExpression(subtraction, context); + } -public class ExpressionVisitorAdapter implements ExpressionVisitor, ItemsListVisitor { @Override - public void visit(NullValue value) { + public T visit(AndExpression andExpression, S context) { + return visitBinaryExpression(andExpression, context); + } + @Override + public T visit(OrExpression orExpression, S context) { + return visitBinaryExpression(orExpression, context); } @Override - public void visit(Function function) { + public T visit(XorExpression xorExpression, S context) { + return visitBinaryExpression(xorExpression, context); + } + @Override + public T visit(Between between, S context) { + return visitExpressions(between, context, between.getLeftExpression(), + between.getBetweenExpressionStart(), between.getBetweenExpressionEnd()); + } + + public T visit(OverlapsCondition overlapsCondition, S context) { + return visitExpressions(overlapsCondition, context, overlapsCondition.getLeft(), + overlapsCondition.getRight()); } + @Override - public void visit(SignedExpression expr) { - expr.getExpression().accept(this); + public T visit(EqualsTo equalsTo, S context) { + return visitBinaryExpression(equalsTo, context); } @Override - public void visit(JdbcParameter parameter) { + public T visit(GreaterThan greaterThan, S context) { + return visitBinaryExpression(greaterThan, context); + } + + @Override + public T visit(GreaterThanEquals greaterThanEquals, S context) { + return visitBinaryExpression(greaterThanEquals, context); + } + @Override + public T visit(InExpression inExpression, S context) { + return visitExpressions(inExpression, context, inExpression.getLeftExpression(), + inExpression.getRightExpression()); } @Override - public void visit(JdbcNamedParameter parameter) { + public T visit(IncludesExpression includesExpression, S context) { + return visitExpressions(includesExpression, context, includesExpression.getLeftExpression(), + includesExpression.getRightExpression()); + } + @Override + public T visit(ExcludesExpression excludesExpression, S context) { + return visitExpressions(excludesExpression, context, excludesExpression.getLeftExpression(), + excludesExpression.getRightExpression()); } @Override - public void visit(DoubleValue value) { + public T visit(IsNullExpression isNullExpression, S context) { + return isNullExpression.getLeftExpression().accept(this, context); + } + @Override + public T visit(FullTextSearch fullTextSearch, S context) { + ArrayList subExpressions = new ArrayList<>(fullTextSearch.getMatchColumns()); + subExpressions.add(fullTextSearch.getAgainstValue()); + return visitExpressions(fullTextSearch, context, subExpressions); } @Override - public void visit(LongValue value) { + public T visit(IsBooleanExpression isBooleanExpression, S context) { + return isBooleanExpression.getLeftExpression().accept(this, context); + } + @Override + public T visit(IsUnknownExpression isUnknownExpression, S context) { + return isUnknownExpression.getLeftExpression().accept(this, context); } @Override - public void visit(DateValue value) { + public T visit(IsNormalizedExpression isNormalizedExpression, S context) { + return isNormalizedExpression.getLeftExpression().accept(this, context); + } + @Override + public T visit(LikeExpression likeExpression, S context) { + return visitExpressions(likeExpression, context, likeExpression.getLeftExpression(), + likeExpression.getRightExpression(), likeExpression.getEscape()); } @Override - public void visit(TimeValue value) { + public T visit(MinorThan minorThan, S context) { + return visitBinaryExpression(minorThan, context); + } + @Override + public T visit(MinorThanEquals minorThanEquals, S context) { + return visitBinaryExpression(minorThanEquals, context); } @Override - public void visit(TimestampValue value) { + public T visit(NotEqualsTo notEqualsTo, S context) { + return visitBinaryExpression(notEqualsTo, context); + } + @Override + public T visit(DoubleAnd doubleAnd, S context) { + return visitBinaryExpression(doubleAnd, context); } @Override - public void visit(Parenthesis parenthesis) { - parenthesis.getExpression().accept(this); + public T visit(Contains contains, S context) { + return visitBinaryExpression(contains, context); } @Override - public void visit(StringValue value) { + public T visit(ContainedBy containedBy, S context) { + return visitBinaryExpression(containedBy, context); + } + @Override + public T visit(Column column, S context) { + T result = applyExpression(column, context); + if (column.getArrayConstructor() != null) { + column.getArrayConstructor().accept(this, context); + } + return result; } @Override - public void visit(Addition expr) { - visitBinaryExpression(expr); + public T visit(ParenthesedSelect select, S context) { + visit((Select) select, context); + if (select.getPivot() != null) { + select.getPivot().accept(this, context); + } + return null; } @Override - public void visit(Division expr) { - visitBinaryExpression(expr); + public T visit(CaseExpression caseExpression, S context) { + ArrayList subExpressions = new ArrayList<>(); + + if (caseExpression.getSwitchExpression() != null) { + subExpressions.add(caseExpression.getSwitchExpression()); + } + subExpressions.addAll(caseExpression.getWhenClauses()); + if (caseExpression.getElseExpression() != null) { + subExpressions.add(caseExpression.getElseExpression()); + } + return visitExpressions(caseExpression, context, subExpressions); } @Override - public void visit(Multiplication expr) { - visitBinaryExpression(expr); + public T visit(WhenClause whenClause, S context) { + return visitExpressions(whenClause, context, whenClause.getWhenExpression(), + whenClause.getThenExpression()); + } + + @Override + public T visit(ExistsExpression existsExpression, S context) { + return existsExpression.getRightExpression().accept(this, context); + } + + @Override + public T visit(MemberOfExpression memberOfExpression, S context) { + return visitExpressions(memberOfExpression, context, + memberOfExpression.getLeftExpression(), memberOfExpression.getRightExpression()); + } + + @Override + public T visit(AnyComparisonExpression anyComparisonExpression, S context) { + return visitExpressions(anyComparisonExpression, context, + anyComparisonExpression.getSelect()); + } + + @Override + public T visit(Concat concat, S context) { + return visitBinaryExpression(concat, context); + } + + @Override + public T visit(Matches matches, S context) { + return visitBinaryExpression(matches, context); + } + + @Override + public T visit(BitwiseAnd bitwiseAnd, S context) { + return visitBinaryExpression(bitwiseAnd, context); + } + + @Override + public T visit(BitwiseOr bitwiseOr, S context) { + return visitBinaryExpression(bitwiseOr, context); + } + + @Override + public T visit(BitwiseXor bitwiseXor, S context) { + return visitBinaryExpression(bitwiseXor, context); + } + + @Override + public T visit(CastExpression castExpression, S context) { + return castExpression.getLeftExpression().accept(this, context); + } + + @Override + public T visit(Modulo modulo, S context) { + return visitBinaryExpression(modulo, context); + } + + @Override + public T visit(AnalyticExpression analyticExpression, S context) { + ArrayList subExpressions = new ArrayList<>(); + + if (analyticExpression.getExpression() != null) { + subExpressions.add(analyticExpression.getExpression()); + } + if (analyticExpression.getDefaultValue() != null) { + subExpressions.add(analyticExpression.getDefaultValue()); + } + if (analyticExpression.getOffset() != null) { + subExpressions.add(analyticExpression.getOffset()); + } + if (analyticExpression.getKeep() != null) { + subExpressions.add(analyticExpression.getKeep()); + } + subExpressions.add(analyticExpression.getFilterExpression()); + addOrderByExpressions(subExpressions, analyticExpression.getFuncOrderBy()); + addFunctionModifiers(subExpressions, analyticExpression.getHavingClause(), + analyticExpression.getKeywordArguments(), analyticExpression.getLimit()); + if (analyticExpression.getWindowDefinition() != null) { + subExpressions.addAll(analyticExpression.getWindowDefinition().getAllExpressions()); + } + return visitExpressions(analyticExpression, context, subExpressions); + } + + private static void addOrderByExpressions(List expressions, + List orderBy) { + if (orderBy != null) { + for (OrderByElement element : orderBy) { + expressions.add(element.getExpression()); + } + } + } + + private static void addFunctionModifiers(List expressions, + Function.HavingClause having, List arguments, + net.sf.jsqlparser.statement.select.Limit limit) { + expressions.add(having); + if (arguments != null) { + for (Function.KeywordArgument argument : arguments) { + expressions.add(argument.getExpression()); + } + } + if (limit != null) { + expressions.add(limit.getOffset()); + expressions.add(limit.getRowCount()); + if (limit.getByExpressions() != null) { + expressions.addAll(limit.getByExpressions()); + } + } } @Override - public void visit(Subtraction expr) { - visitBinaryExpression(expr); + public T visit(ExtractExpression extractExpression, S context) { + return extractExpression.getExpression().accept(this, context); } @Override - public void visit(AndExpression expr) { - visitBinaryExpression(expr); + public T visit(IntervalExpression intervalExpression, S context) { + if (intervalExpression.getExpression() != null) { + intervalExpression.getExpression().accept(this, context); + } + return null; } @Override - public void visit(OrExpression expr) { - visitBinaryExpression(expr); + public T visit(OracleHierarchicalExpression hierarchicalExpression, S context) { + return visitExpressions(hierarchicalExpression, context, + hierarchicalExpression.getConnectExpression(), + hierarchicalExpression.getStartExpression()); } @Override - public void visit(Between expr) { - expr.getLeftExpression().accept(this); - expr.getBetweenExpressionStart().accept(this); - expr.getBetweenExpressionEnd().accept(this); + public T visit(RegExpMatchOperator regExpMatchOperator, S context) { + return visitBinaryExpression(regExpMatchOperator, context); } @Override - public void visit(EqualsTo expr) { - visitBinaryExpression(expr); + public T visit(ExpressionList expressionList, S context) { + return visitExpressions(expressionList, context, (Collection) expressionList); } @Override - public void visit(GreaterThan expr) { - visitBinaryExpression(expr); + public T visit(RowConstructor rowConstructor, S context) { + return visitExpressions(rowConstructor, context, (Collection) rowConstructor); } @Override - public void visit(GreaterThanEquals expr) { - visitBinaryExpression(expr); + public T visit(NotExpression notExpr, S context) { + return notExpr.getExpression().accept(this, context); } @Override - public void visit(InExpression expr) { - expr.getLeftExpression().accept(this); - expr.getLeftItemsList().accept(this); - expr.getRightItemsList().accept(this); + public T visit(BitwiseRightShift bitwiseRightShift, S context) { + return visitBinaryExpression(bitwiseRightShift, context); } @Override - public void visit(IsNullExpression expr) { - expr.getLeftExpression().accept(this); + public T visit(BitwiseLeftShift bitwiseLeftShift, S context) { + return visitBinaryExpression(bitwiseLeftShift, context); + } + + protected T applyExpression(Expression expression, S context) { + return null; + } + + protected T visitExpressions(Expression expression, S context, + ExpressionList subExpressions) { + return visitExpressions(expression, context, (Collection) subExpressions); + } + + protected T visitExpressions(Expression expression, S context, + Collection subExpressions) { + for (Expression e : subExpressions) { + if (e != null) { + e.accept(this, context); + } + } + return null; + } + + protected T visitExpressions(Expression expression, S context, + Expression... subExpressions) { + return visitExpressions(expression, context, Arrays.asList(subExpressions)); + } + + protected T visitBinaryExpression(BinaryExpression binaryExpression, S context) { + return visitExpressions(binaryExpression, context, binaryExpression.getLeftExpression(), + binaryExpression.getRightExpression()); } @Override - public void visit(LikeExpression expr) { - visitBinaryExpression(expr); + public T visit(JsonExpression jsonExpr, S context) { + ArrayList subExpressions = new ArrayList<>(); + subExpressions.add(jsonExpr.getExpression()); + subExpressions.addAll(jsonExpr.getIdents()); + return visitExpressions(jsonExpr, context, subExpressions); } @Override - public void visit(MinorThan expr) { - visitBinaryExpression(expr); + public T visit(JsonOperator jsonOperator, S context) { + return visitBinaryExpression(jsonOperator, context); } @Override - public void visit(MinorThanEquals expr) { - visitBinaryExpression(expr); + public T visit(UserVariable userVariable, S context) { + return applyExpression(userVariable, context); } @Override - public void visit(NotEqualsTo expr) { - visitBinaryExpression(expr); + public T visit(NumericBind numericBind, S context) { + return applyExpression(numericBind, context); } @Override - public void visit(Column column) { + public T visit(KeepExpression keepExpression, S context) { + ArrayList subExpressions = new ArrayList<>(); + for (OrderByElement element : keepExpression.getOrderByElements()) { + subExpressions.add(element.getExpression()); + } + return visitExpressions(keepExpression, context, subExpressions); + } + @Override + public T visit(MySQLGroupConcat groupConcat, S context) { + ArrayList subExpressions = new ArrayList<>(groupConcat.getExpressionList()); + if (groupConcat.getOrderByElements() != null) { + for (OrderByElement element : groupConcat.getOrderByElements()) { + subExpressions.add(element.getExpression()); + } + } + return visitExpressions(groupConcat, context, subExpressions); } @Override - public void visit(SubSelect subSelect) { - + public T visit(Pivot pivot, S context) { + for (SelectItem item : pivot.getFunctionItems()) { + item.accept(this, context); + } + for (Column col : pivot.getForColumns()) { + col.accept(this, context); + } + if (pivot.getSingleInItems() != null) { + for (SelectItem item : pivot.getSingleInItems()) { + item.accept(this, context); + } + } + if (pivot.getMultiInItems() != null) { + for (SelectItem> item : pivot.getMultiInItems()) { + item.accept(this, context); + } + } + return null; } @Override - public void visit(CaseExpression expr) { - expr.getSwitchExpression().accept(this); - for (Expression x : expr.getWhenClauses()) { - x.accept(this); + public T visit(PivotXml pivotXml, S context) { + for (SelectItem item : pivotXml.getFunctionItems()) { + item.accept(this, context); + } + for (Column col : pivotXml.getForColumns()) { + col.accept(this, context); + } + if (pivotXml.getInSelect() != null && selectVisitor != null) { + pivotXml.getInSelect().accept(selectVisitor, context); } - expr.getElseExpression().accept(this); + return null; } @Override - public void visit(WhenClause expr) { - expr.getWhenExpression().accept(this); - expr.getThenExpression().accept(this); + public T visit(UnPivot unpivot, S context) { + return unpivot.accept(this, context); } @Override - public void visit(ExistsExpression expr) { - expr.getRightExpression().accept(this); + public T visit(AllColumns allColumns, S context) { + return applyExpression(allColumns, context); } @Override - public void visit(AllComparisonExpression expr) { + public T visit(AllTableColumns allTableColumns, S context) { + return applyExpression(allTableColumns, context); + } + @Override + public T visit(FunctionAllColumns functionAllColumns, S context) { + return applyExpression(functionAllColumns, context); } @Override - public void visit(AnyComparisonExpression expr) { + public T visit(AllValue allValue, S context) { + return applyExpression(allValue, context); + } + @Override + public T visit(IsDistinctExpression isDistinctExpression, S context) { + return visitBinaryExpression(isDistinctExpression, context); } @Override - public void visit(Concat expr) { - visitBinaryExpression(expr); + public T visit(SelectItem selectItem, S context) { + return selectItem.getExpression().accept(this, context); } @Override - public void visit(Matches expr) { - visitBinaryExpression(expr); + public T visit(RowGetExpression rowGetExpression, S context) { + return rowGetExpression.getExpression().accept(this, context); + } + + @Override + public T visit(HexValue hexValue, S context) { + return applyExpression(hexValue, context); + } + + @Override + public T visit(OracleHint hint, S context) { + return applyExpression(hint, context); + } + + @Override + public T visit(TimeKeyExpression timeKeyExpression, S context) { + return applyExpression(timeKeyExpression, context); + } + + @Override + public T visit(DateTimeLiteralExpression dateTimeLiteralExpression, S context) { + return applyExpression(dateTimeLiteralExpression, context); + } + + @Override + public T visit(NextValExpression nextValExpression, S context) { + return applyExpression(nextValExpression, context); + } + + @Override + public T visit(CollateExpression collateExpression, S context) { + return collateExpression.getLeftExpression().accept(this, context); + } + + @Override + public T visit(SimilarToExpression similarToExpression, S context) { + return visitBinaryExpression(similarToExpression, context); + } + + @Override + public T visit(ArrayExpression arrayExpression, S context) { + ArrayList subExpressions = new ArrayList<>(); + + subExpressions.add(arrayExpression.getObjExpression()); + if (arrayExpression.getIndexExpression() != null) { + subExpressions.add(arrayExpression.getIndexExpression()); + } + if (arrayExpression.getStartIndexExpression() != null) { + subExpressions.add(arrayExpression.getStartIndexExpression()); + } + if (arrayExpression.getStopIndexExpression() != null) { + subExpressions.add(arrayExpression.getStopIndexExpression()); + } + if (arrayExpression.getStepExpression() != null) { + subExpressions.add(arrayExpression.getStepExpression()); + } + return visitExpressions(arrayExpression, context, subExpressions); } @Override - public void visit(BitwiseAnd expr) { - visitBinaryExpression(expr); + public T visit(ArrayConstructor arrayConstructor, S context) { + return visitExpressions(arrayConstructor, context, arrayConstructor.getExpressions()); } @Override - public void visit(BitwiseOr expr) { - visitBinaryExpression(expr); + public T visit(MapExpression mapExpression, S context) { + ArrayList subExpressions = new ArrayList<>(); + for (Map.Entry entry : mapExpression.getEntries()) { + subExpressions.add(entry.getKey()); + subExpressions.add(entry.getValue()); + } + return visitExpressions(mapExpression, context, subExpressions); } @Override - public void visit(BitwiseXor expr) { - visitBinaryExpression(expr); + public T visit(VariableAssignment variableAssignment, S context) { + return visitExpressions(variableAssignment, context, variableAssignment.getVariable(), + variableAssignment.getExpression()); } @Override - public void visit(CastExpression expr) { - expr.getLeftExpression().accept(this); + public T visit(XMLSerializeExpr xmlSerializeExpr, S context) { + return visitExpressions(xmlSerializeExpr, context, xmlSerializeExpr.getExpressions()); } @Override - public void visit(Modulo expr) { - visitBinaryExpression(expr); + public T visit(TimezoneExpression timezoneExpression, S context) { + ArrayList subExpressions = new ArrayList<>(); + subExpressions.add(timezoneExpression.getLeftExpression()); + subExpressions.addAll(timezoneExpression.getTimezoneExpressions()); + return visitExpressions(timezoneExpression, context, subExpressions); } @Override - public void visit(AnalyticExpression expr) { - expr.getExpression().accept(this); - expr.getDefaultValue().accept(this); - expr.getOffset().accept(this); - for (OrderByElement element : expr.getOrderByElements()) { - element.getExpression().accept(this); + public T visit(JsonAggregateFunction jsonAggregateFunction, S context) { + ArrayList subExpressions = new ArrayList<>(); + subExpressions.add(jsonAggregateFunction.getExpression()); + if (jsonAggregateFunction.getKey() instanceof Expression) { + subExpressions.add((Expression) jsonAggregateFunction.getKey()); + } + if (jsonAggregateFunction.getValue() instanceof Expression) { + subExpressions.add((Expression) jsonAggregateFunction.getValue()); + } + addOrderByExpressions(subExpressions, + jsonAggregateFunction.getExpressionOrderByElements()); + subExpressions.add(jsonAggregateFunction.getFilterExpression()); + subExpressions.addAll(jsonAggregateFunction.getPartitionExpressionList()); + addOrderByExpressions(subExpressions, jsonAggregateFunction.getOrderByElements()); + return visitExpressions(jsonAggregateFunction, context, subExpressions); + } + + @Override + public T visit(JsonFunction jsonFunction, S context) { + ArrayList subExpressions = new ArrayList<>(); + for (JsonKeyValuePair keyValuePair : jsonFunction.getKeyValuePairs()) { + if (keyValuePair.getKey() instanceof Expression) { + subExpressions.add((Expression) keyValuePair.getKey()); + } + if (keyValuePair.getValue() instanceof Expression) { + subExpressions.add((Expression) keyValuePair.getValue()); + } + } + for (JsonFunctionExpression expr : jsonFunction.getExpressions()) { + subExpressions.add(expr.getExpression()); + } + if (jsonFunction.getInputExpression() != null) { + subExpressions.add(jsonFunction.getInputExpression().getExpression()); } + if (jsonFunction.getJsonPathExpression() != null) { + subExpressions.add(jsonFunction.getJsonPathExpression()); + } + subExpressions.addAll(jsonFunction.getPassingExpressions()); + if (jsonFunction.getOnEmptyBehavior() != null + && jsonFunction.getOnEmptyBehavior().getExpression() != null) { + subExpressions.add(jsonFunction.getOnEmptyBehavior().getExpression()); + } + if (jsonFunction.getOnErrorBehavior() != null + && jsonFunction.getOnErrorBehavior().getExpression() != null) { + subExpressions.add(jsonFunction.getOnErrorBehavior().getExpression()); + } + return visitExpressions(jsonFunction, context, subExpressions); + } + + @Override + public T visit(JsonTableFunction jsonTableFunction, S context) { + return visitExpressions(jsonTableFunction, context, jsonTableFunction.getAllExpressions()); + } + + @Override + public T visit(XmlTableFunction xmlTableFunction, S context) { + return visitExpressions(xmlTableFunction, context, xmlTableFunction.getAllExpressions()); + } + + @Override + public T visit(ConnectByRootOperator connectByRootOperator, S context) { + return connectByRootOperator.getColumn().accept(this, context); + } - expr.getWindowElement().getRange().getStart().getExpression().accept(this); - expr.getWindowElement().getRange().getEnd().getExpression().accept(this); - expr.getWindowElement().getOffset().getExpression().accept(this); + @Override + public T visit(ConnectByPriorOperator connectByPriorOperator, S context) { + return connectByPriorOperator.getColumn().accept(this, context); } @Override - public void visit(ExtractExpression expr) { - expr.getExpression().accept(this); + public T visit(KeyExpression keyExpression, S context) { + return keyExpression.getExpression().accept(this, context); } @Override - public void visit(IntervalExpression expr) { + public T visit(OracleNamedFunctionParameter oracleNamedFunctionParameter, S context) { + return oracleNamedFunctionParameter.getExpression().accept(this, context); + } + @Override + public T visit(PostgresNamedFunctionParameter postgresNamedFunctionParameter, S context) { + return postgresNamedFunctionParameter.getExpression().accept(this, context); } @Override - public void visit(OracleHierarchicalExpression expr) { - expr.getConnectExpression().accept(this); - expr.getStartExpression().accept(this); + public T visit(GeometryDistance geometryDistance, S context) { + return visitBinaryExpression(geometryDistance, context); } @Override - public void visit(RegExpMatchOperator expr) { - visitBinaryExpression(expr); + public T visit(Intersects intersects, S context) { + return visitBinaryExpression(intersects, context); } @Override - public void visit(ExpressionList expressionList) { - for (Expression expr : expressionList.getExpressions()) { - expr.accept(this); + public T visit(Select select, S context) { + if (selectVisitor != null) { + if (select.getWithItemsList() != null) { + for (WithItem item : select.getWithItemsList()) { + item.accept(selectVisitor, context); + } + } + select.accept(selectVisitor, context); } + return null; } @Override - public void visit(MultiExpressionList multiExprList) { - for (ExpressionList list : multiExprList.getExprList()) { - visit(list); + public T visit(TranscodingFunction transcodingFunction, S context) { + return transcodingFunction.getExpression().accept(this, context); + } + + @Override + public T visit(TrimFunction trimFunction, S context) { + return visitExpressions(trimFunction, context, trimFunction.getExpression(), + trimFunction.getFromExpression()); + } + + @Override + public T visit(RangeExpression rangeExpression, S context) { + return visitExpressions(rangeExpression, context, rangeExpression.getStartExpression(), + rangeExpression.getEndExpression(), rangeExpression.getStepExpression()); + } + + @Override + public T visit(TernaryExpression ternaryExpression, S context) { + return visitExpressions(ternaryExpression, context, ternaryExpression.getCondition(), + ternaryExpression.getThenExpression(), ternaryExpression.getElseExpression()); + } + + @Override + public T visit(TSQLLeftJoin tsqlLeftJoin, S context) { + return visitBinaryExpression(tsqlLeftJoin, context); + } + + @Override + public T visit(TSQLRightJoin tsqlRightJoin, S context) { + return visitBinaryExpression(tsqlRightJoin, context); + } + + @Override + public T visit(StructType structType, S context) { + // @todo: visit the ColType also + if (structType.getArguments() != null) { + for (SelectItem selectItem : structType.getArguments()) { + selectItem.accept(this, context); + } } + return null; + } + + @Override + public T visit(LambdaExpression lambdaExpression, S context) { + return lambdaExpression.getExpression().accept(this, context); + } + + @Override + public T visit(ListComprehension listComprehension, S context) { + return visitExpressions(listComprehension, context, listComprehension.getExpression(), + listComprehension.getList(), listComprehension.getCondition()); + } + + @Override + public T visit(ColumnsExpression columnsExpression, S context) { + return visitExpressions(columnsExpression, context, columnsExpression.getAllExpressions()); + } + + @Override + public T visit(HighExpression highExpression, S context) { + return highExpression.getExpression().accept(this, context); } - protected void visitBinaryExpression(BinaryExpression expr) { - expr.getLeftExpression().accept(this); - expr.getRightExpression().accept(this); + @Override + public T visit(LowExpression lowExpression, S context) { + return lowExpression.getExpression().accept(this, context); + } + + @Override + public T visit(Plus plus, S context) { + return visitBinaryExpression(plus, context); + } + + @Override + public T visit(PriorTo priorTo, S context) { + return visitBinaryExpression(priorTo, context); + } + + @Override + public T visit(Inverse inverse, S context) { + return inverse.getExpression().accept(this, context); + } + + @Override + public T visit(CosineSimilarity cosineSimilarity, S context) { + cosineSimilarity.getLeftExpression().accept(this, context); + cosineSimilarity.getRightExpression().accept(this, context); + return null; + } + + @Override + public T visit(FromQuery fromQuery, S context) { + return null; } @Override - public void visit(JsonExpression jsonExpr) { - visit(jsonExpr.getColumn()); + public T visit(DateUnitExpression dateUnitExpression, S context) { + return null; } - @Override - public void visit(RegExpMySQLOperator expr) { - visitBinaryExpression(expr); - } } diff --git a/src/main/java/net/sf/jsqlparser/expression/ExtractExpression.java b/src/main/java/net/sf/jsqlparser/expression/ExtractExpression.java index b98eb097d3..dcbddfef86 100644 --- a/src/main/java/net/sf/jsqlparser/expression/ExtractExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/ExtractExpression.java @@ -1,60 +1,64 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + /** - * Extract value from date/time expression. The name stores the part - name to - * get from the following date/time expression. + * Extract value from date/time expression. The name stores the part - name to get from the + * following date/time expression. * * @author tw */ -public class ExtractExpression implements Expression { +public class ExtractExpression extends ASTNodeAccessImpl implements Expression { + + private String name; + private Expression expression; + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public String getName() { + return name; + } - private String name; - private Expression expression; + public void setName(String name) { + this.name = name; + } - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public Expression getExpression() { + return expression; + } - public String getName() { - return name; - } + public void setExpression(Expression expression) { + this.expression = expression; + } - public void setName(String name) { - this.name = name; - } + @Override + public String toString() { + return "EXTRACT(" + name + " FROM " + expression + ')'; + } - public Expression getExpression() { - return expression; - } + public ExtractExpression withName(String name) { + this.setName(name); + return this; + } - public void setExpression(Expression expression) { - this.expression = expression; - } + public ExtractExpression withExpression(Expression expression) { + this.setExpression(expression); + return this; + } - @Override - public String toString() { - return "EXTRACT(" + name + " FROM " + expression + ')'; - } + public E getExpression(Class type) { + return type.cast(getExpression()); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/FilterOverImpl.java b/src/main/java/net/sf/jsqlparser/expression/FilterOverImpl.java new file mode 100644 index 0000000000..a64d8eb279 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/FilterOverImpl.java @@ -0,0 +1,142 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.List; + +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.select.OrderByElement; + +/** + * @author tw + */ +public class FilterOverImpl extends ASTNodeAccessImpl { + private final OrderByClause orderBy = new OrderByClause(); + private final PartitionByClause partitionBy = new PartitionByClause(); + private AnalyticType analyticType = AnalyticType.FILTER_ONLY; + private Expression filterExpression = null; + private WindowElement windowElement = null; + + public AnalyticType getAnalyticType() { + return analyticType; + } + + public void setAnalyticType(AnalyticType analyticType) { + this.analyticType = analyticType; + } + + public FilterOverImpl withAnalyticType(AnalyticType analyticType) { + this.setAnalyticType(analyticType); + return this; + } + + public List getOrderByElements() { + return orderBy.getOrderByElements(); + } + + public void setOrderByElements(List orderByElements) { + orderBy.setOrderByElements(orderByElements); + } + + public FilterOverImpl withOrderByElements(List orderByElements) { + this.setOrderByElements(orderByElements); + return this; + } + + public ExpressionList getPartitionExpressionList() { + return partitionBy; + } + + public void setPartitionExpressionList(ExpressionList partitionExpressionList) { + setPartitionExpressionList(partitionExpressionList, false); + } + + public void setPartitionExpressionList(ExpressionList partitionExpressionList, + boolean brackets) { + partitionBy.setExpressions(partitionExpressionList, brackets); + } + + public boolean isPartitionByBrackets() { + return partitionBy.isBrackets(); + } + + public Expression getFilterExpression() { + return filterExpression; + } + + public void setFilterExpression(Expression filterExpression) { + this.filterExpression = filterExpression; + } + + + public FilterOverImpl withFilterExpression(Expression filterExpression) { + this.setFilterExpression(filterExpression); + return this; + } + + public WindowElement getWindowElement() { + return windowElement; + } + + public void setWindowElement(WindowElement windowElement) { + this.windowElement = windowElement; + } + + public FilterOverImpl withWindowElement(WindowElement windowElement) { + this.setWindowElement(windowElement); + return this; + } + + @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity", + "PMD.MissingBreakInSwitch"}) + public StringBuilder append(StringBuilder builder) { + if (filterExpression != null) { + builder.append("FILTER (WHERE "); + builder.append(filterExpression.toString()); + builder.append(")"); + if (analyticType != AnalyticType.FILTER_ONLY) { + builder.append(" "); + } + } + + switch (analyticType) { + case FILTER_ONLY: + return builder; + case WITHIN_GROUP: + builder.append("WITHIN GROUP"); + break; + default: + builder.append("OVER"); + } + builder.append(" ("); + + partitionBy.toStringPartitionBy(builder); + orderBy.toStringOrderByElements(builder); + + if (windowElement != null) { + if (orderBy.getOrderByElements() != null) { + builder.append(' '); + } + builder.append(windowElement); + } + + builder.append(")"); + + return builder; + } + + @Override + @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"}) + public String toString() { + StringBuilder builder = new StringBuilder(); + return append(builder).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/Function.java b/src/main/java/net/sf/jsqlparser/expression/Function.java index 663d04740e..0a0ddd86fb 100644 --- a/src/main/java/net/sf/jsqlparser/expression/Function.java +++ b/src/main/java/net/sf/jsqlparser/expression/Function.java @@ -1,133 +1,701 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import java.util.Locale; import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.expression.operators.relational.NamedExpressionList; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.schema.Column; +import net.sf.jsqlparser.statement.select.Limit; +import net.sf.jsqlparser.statement.select.OrderByElement; + +import net.sf.jsqlparser.statement.create.table.ColDataType; +import net.sf.jsqlparser.statement.create.table.ColumnDefinition; +import net.sf.jsqlparser.statement.select.PlainSelect; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Objects; /** * A function as MAX,COUNT... */ -public class Function implements Expression { - - private String name; - private ExpressionList parameters; - private boolean allColumns = false; - private boolean distinct = false; - private boolean isEscaped = false; - - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } - - /** - * The name of he function, i.e. "MAX" - * - * @return the name of he function - */ - public String getName() { - return name; - } - - public void setName(String string) { - name = string; - } - - /** - * true if the parameter to the function is "*" - * - * @return true if the parameter to the function is "*" - */ - public boolean isAllColumns() { - return allColumns; - } - - public void setAllColumns(boolean b) { - allColumns = b; - } - - /** - * true if the function is "distinct" - * - * @return true if the function is "distinct" - */ - public boolean isDistinct() { - return distinct; - } - - public void setDistinct(boolean b) { - distinct = b; - } - - /** - * The list of parameters of the function (if any, else null) If the - * parameter is "*", allColumns is set to true - * - * @return the list of parameters of the function (if any, else null) - */ - public ExpressionList getParameters() { - return parameters; - } - - public void setParameters(ExpressionList list) { - parameters = list; - } - - /** - * Return true if it's in the form "{fn function_body() }" - * - * @return true if it's java-escaped - */ - public boolean isEscaped() { - return isEscaped; - } - - public void setEscaped(boolean isEscaped) { - this.isEscaped = isEscaped; - } - - @Override - public String toString() { - String params; - - if (parameters != null) { - params = parameters.toString(); - if (isDistinct()) { - params = params.replaceFirst("\\(", "(DISTINCT "); - } else if (isAllColumns()) { - params = params.replaceFirst("\\(", "(ALL "); +public class Function extends ASTNodeAccessImpl implements Expression { + private List nameparts; + private ExpressionList parameters; + private ExpressionList chainedParameters; + private NamedExpressionList namedParameters; + private boolean allColumns = false; + private boolean distinct = false; + private boolean unique = false; + private boolean isEscaped = false; + private Expression attributeExpression; + private HavingClause havingClause; + private Column attributeColumn = null; + private List orderByElements; + private NullHandling nullHandling = null; + private boolean ignoreNullsOutside = false; // IGNORE NULLS outside function parameters + private Limit limit = null; + private KeepExpression keep = null; + private String onOverflowTruncate = null; + private String extraKeyword = null; + private List resultColumnDefinitions; + + /** + * Generic keyword arguments captured inside function parentheses, e.g. + * {@code GROUP_CONCAT(col ORDER BY col SEPARATOR ',')} where {@code SEPARATOR ','} is a keyword + * argument. This acts as a catch-all for dialect-specific {@code KEYWORD expr} pairs that don't + * have dedicated grammar branches. + */ + private List keywordArguments = null; + + /** + * The {@code AS type} cast of the argument, as in MySQL's {@code WEIGHT_STRING(str AS CHAR(3))} + * or {@code WEIGHT_STRING(str AS BINARY(4))}. + */ + private ColDataType castType; + + /** Column definitions supplied for a record-returning function inside ROWS FROM. */ + public List getResultColumnDefinitions() { + return resultColumnDefinitions; + } + + public void setResultColumnDefinitions(List resultColumnDefinitions) { + this.resultColumnDefinitions = resultColumnDefinitions; + } + + public StringBuilder appendResultColumnDefinitionsTo(StringBuilder builder) { + if (resultColumnDefinitions != null) { + builder.append(" AS ") + .append(PlainSelect.getStringList(resultColumnDefinitions, true, true)); + } + return builder; + } + + public Function() {} + + public Function(String name, Expression... parameters) { + this.nameparts = Collections.singletonList(name); + this.parameters = new ExpressionList<>(parameters); + } + + /** + * Returns the {@code AS type} cast written after the argument, as in MySQL's + * {@code WEIGHT_STRING(str AS CHAR(3))}, or {@code null}. + */ + public ColDataType getCastType() { + return castType; + } + + public void setCastType(ColDataType castType) { + this.castType = castType; + } + + public Function withCastType(ColDataType castType) { + setCastType(castType); + return this; + } + + /** Appends {@code " AS type"} when the argument has a {@link #getCastType() cast type}. */ + public StringBuilder appendCastTypeTo(StringBuilder builder) { + if (castType != null) { + builder.append(" AS ").append(castType); + } + return builder; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public String getName() { + return nameparts == null ? null + : String.join(nameparts.get(0).equalsIgnoreCase("APPROXIMATE") ? " " : ".", + nameparts); + } + + public void setName(String string) { + nameparts = Arrays.asList(string); + } + + public void setName(List string) { + nameparts = string; + } + + public List getMultipartName() { + return nameparts; + } + + public Function withName(String name) { + this.setName(name); + return this; + } + + public Function withName(List nameparts) { + this.nameparts = nameparts; + return this; + } + + public boolean isAllColumns() { + return allColumns; + } + + public void setAllColumns(boolean b) { + allColumns = b; + } + + public NullHandling getNullHandling() { + return nullHandling; + } + + public Function setNullHandling(NullHandling nullHandling) { + this.nullHandling = nullHandling; + return this; + } + + public boolean isIgnoreNullsOutside() { + return ignoreNullsOutside; + } + + public Function setIgnoreNullsOutside(boolean ignoreNullsOutside) { + this.ignoreNullsOutside = ignoreNullsOutside; + return this; + } + + public Limit getLimit() { + return limit; + } + + public Function setLimit(Limit limit) { + this.limit = limit; + return this; + } + + public boolean isIgnoreNulls() { + return nullHandling != null && nullHandling == NullHandling.IGNORE_NULLS; + } + + /** + * This is at the moment only necessary for AnalyticExpression initialization and not for normal + * functions. Therefore there is no deparsing for it for normal functions. + */ + public void setIgnoreNulls(boolean ignoreNulls) { + this.nullHandling = ignoreNulls ? NullHandling.IGNORE_NULLS : null; + } + + public HavingClause getHavingClause() { + return havingClause; + } + + public Function setHavingClause(HavingClause havingClause) { + this.havingClause = havingClause; + return this; + } + + public Function setHavingClause(String havingType, Expression expression) { + this.havingClause = new HavingClause( + HavingClause.HavingType.valueOf(havingType.trim().toUpperCase(Locale.ROOT)), + expression); + return this; + } + + /** + * true if the function is "distinct" + * + * @return true if the function is "distinct" + */ + public boolean isDistinct() { + return distinct; + } + + public void setDistinct(boolean b) { + distinct = b; + } + + /** + * true if the function is "unique" + * + * @return true if the function is "unique" + */ + public boolean isUnique() { + return unique; + } + + public void setUnique(boolean b) { + unique = b; + } + + /** + * The list of parameters of the function (if any, else null) If the parameter is "*", + * allColumns is set to true + * + * @return the list of parameters of the function (if any, else null) + */ + public ExpressionList getParameters() { + return parameters; + } + + public void setParameters(Expression... expressions) { + if (expressions.length == 1 && expressions[0] instanceof ExpressionList) { + parameters = (ExpressionList) expressions[0]; + } else { + parameters = new ExpressionList<>(expressions); + } + } + + public void setParameters(ExpressionList list) { + parameters = list; + } + + /** + * Additional function-call parameters for dialects that support chained function calls, e.g. + * quantile(0.95)(cost) in ClickHouse. + * + * @return the chained parameters of the function (if any, else null) + */ + public ExpressionList getChainedParameters() { + return chainedParameters; + } + + public void setChainedParameters(ExpressionList chainedParameters) { + this.chainedParameters = chainedParameters; + } + + /** + * the parameters might be named parameters, e.g. substring('foobar' from 2 for 3) + * + * @return the list of named parameters of the function (if any, else null) + */ + public NamedExpressionList getNamedParameters() { + return namedParameters; + } + + public void setNamedParameters(NamedExpressionList list) { + namedParameters = list; + } + + /** + * Return true if it's in the form "{fn function_body() }" + * + * @return true if it's java-escaped + */ + public boolean isEscaped() { + return isEscaped; + } + + public void setEscaped(boolean isEscaped) { + this.isEscaped = isEscaped; + } + + public Object getAttribute() { + return attributeExpression != null ? attributeExpression : attributeColumn; + } + + public void setAttribute(Expression attributeExpression) { + this.attributeExpression = attributeExpression; + } + + public void setAttribute(Column attributeColumn) { + attributeExpression = null; + this.attributeColumn = attributeColumn; + } + + @Deprecated + public String getAttributeName() { + return attributeColumn.toString(); + } + + public void setAttributeName(String attributeName) { + this.attributeColumn = new Column().withColumnName(attributeName); + } + + public Column getAttributeColumn() { + return attributeColumn; + } + + public Function withAttribute(Column attributeColumn) { + setAttribute(attributeColumn); + return this; + } + + public KeepExpression getKeep() { + return keep; + } + + public void setKeep(KeepExpression keep) { + this.keep = keep; + } + + public String getExtraKeyword() { + return extraKeyword; + } + + public Function setExtraKeyword(String extraKeyword) { + this.extraKeyword = extraKeyword; + return this; + } + + // ── Generic keyword argument support ─────────────────────────────── + + /** + * Returns the list of generic keyword arguments, e.g. {@code SEPARATOR ','}. + * + * @return keyword arguments or {@code null} + */ + public List getKeywordArguments() { + return keywordArguments; + } + + public void setKeywordArguments(List keywordArguments) { + this.keywordArguments = keywordArguments; + } + + /** + * Adds a single keyword argument (appends to the list, creating it if needed). + */ + public Function addKeywordArgument(String keyword, Expression expression) { + if (this.keywordArguments == null) { + this.keywordArguments = new ArrayList<>(); + } + this.keywordArguments.add(new KeywordArgument(keyword, expression)); + return this; + } + + public Function withKeywordArguments(List keywordArguments) { + this.keywordArguments = keywordArguments; + return this; + } + + /** + * Convenience lookup: returns the expression for the first keyword argument matching the given + * keyword (case-insensitive), or {@code null}. + */ + public Expression getKeywordArgumentValue(String keyword) { + if (keywordArguments == null) { + return null; + } + for (KeywordArgument ka : keywordArguments) { + if (ka.getKeyword().equalsIgnoreCase(keyword)) { + return ka.getExpression(); + } + } + return null; + } + + @Override + @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"}) + public String toString() { + String params; + + if (parameters != null || namedParameters != null) { + if (parameters != null) { + StringBuilder b = new StringBuilder(); + b.append("("); + if (isDistinct()) { + b.append("DISTINCT "); + } else if (isUnique()) { + b.append("UNIQUE "); + } + if (isAllColumns()) { + b.append("ALL "); + } + + if (extraKeyword != null) { + b.append(extraKeyword).append(" "); + } + + b.append(parameters); + appendCastTypeTo(b); + + if (havingClause != null) { + havingClause.appendTo(b); + } + + if (nullHandling != null && !isIgnoreNullsOutside()) { + switch (nullHandling) { + case IGNORE_NULLS: + b.append(" IGNORE NULLS"); + break; + case RESPECT_NULLS: + b.append(" RESPECT NULLS"); + break; + } + } + if (orderByElements != null) { + b.append(" ORDER BY "); + boolean comma = false; + for (OrderByElement orderByElement : orderByElements) { + if (comma) { + b.append(", "); + } else { + comma = true; + } + b.append(orderByElement); + } + } + if (limit != null) { + b.append(limit); + } + + if (onOverflowTruncate != null) { + b.append(" ON OVERFLOW ").append(onOverflowTruncate); + } + + // Generic keyword arguments (e.g. SEPARATOR ',') + if (keywordArguments != null) { + for (KeywordArgument ka : keywordArguments) { + ka.appendTo(b); + } + } + + b.append(")"); + params = b.toString(); + } else { + params = namedParameters.toString(); + } + } else { + params = "()"; + } + + String ans = getName() + params; + + if (chainedParameters != null) { + ans += "(" + chainedParameters + ")"; + } + + if (nullHandling != null && isIgnoreNullsOutside()) { + switch (nullHandling) { + case IGNORE_NULLS: + ans += " IGNORE NULLS"; + break; + case RESPECT_NULLS: + ans += " RESPECT NULLS"; + break; } - } else if (isAllColumns()) { - params = "(*)"; - } else { - params = "()"; - } + } + + if (attributeExpression != null) { + ans += "." + attributeExpression; + } else if (attributeColumn != null) { + ans += "." + attributeColumn; + } + + if (keep != null) { + ans += " " + keep; + } + + if (isEscaped) { + ans = "{fn " + ans + "}"; + } + + return resultColumnDefinitions == null ? ans + : appendResultColumnDefinitionsTo(new StringBuilder(ans)).toString(); + } + + public Function withAttribute(Expression attribute) { + this.setAttribute(attribute); + return this; + } + + @Deprecated + public Function withAttributeName(String attributeName) { + this.setAttributeName(attributeName); + return this; + } + + public Function withKeep(KeepExpression keep) { + this.setKeep(keep); + return this; + } + + public Function withIgnoreNulls(boolean ignoreNulls) { + this.setIgnoreNulls(ignoreNulls); + return this; + } + + public Function withParameters(ExpressionList parameters) { + this.setParameters(parameters); + return this; + } + + public Function withParameters(Expression... parameters) { + return withParameters(new ExpressionList<>(parameters)); + } + + public Function withChainedParameters(ExpressionList chainedParameters) { + this.setChainedParameters(chainedParameters); + return this; + } + + public Function withNamedParameters(NamedExpressionList namedParameters) { + this.setNamedParameters(namedParameters); + return this; + } + + public Function withAllColumns(boolean allColumns) { + this.setAllColumns(allColumns); + return this; + } + + public Function withDistinct(boolean distinct) { + this.setDistinct(distinct); + return this; + } + + public Function withUnique(boolean unique) { + this.setUnique(unique); + return this; + } + + public List getOrderByElements() { + return orderByElements; + } + + public void setOrderByElements(List orderByElements) { + this.orderByElements = orderByElements; + } + + public String getOnOverflowTruncate() { + return onOverflowTruncate; + } + + public Function setOnOverflowTruncate(String onOverflowTruncate) { + this.onOverflowTruncate = onOverflowTruncate; + return this; + } + + public E getAttribute(Class type) { + return type.cast(getAttribute()); + } + + public enum NullHandling { + IGNORE_NULLS, RESPECT_NULLS; + } + + // ── KeywordArgument inner class ──────────────────────────────────── + + /** + * Represents a generic {@code KEYWORD expression} pair inside a function call. + *

+ * Examples: + *

    + *
  • {@code GROUP_CONCAT(col SEPARATOR ',')} → keyword="SEPARATOR", expression=','
  • + *
+ */ + public static class KeywordArgument implements Serializable { + private String keyword; + private Expression expression; + + public KeywordArgument() {} + + public KeywordArgument(String keyword, Expression expression) { + this.keyword = keyword; + this.expression = expression; + } + + public String getKeyword() { + return keyword; + } + + public KeywordArgument setKeyword(String keyword) { + this.keyword = keyword; + return this; + } + + public Expression getExpression() { + return expression; + } + + public KeywordArgument setExpression(Expression expression) { + this.expression = expression; + return this; + } + + public StringBuilder appendTo(StringBuilder builder) { + builder.append(" ").append(keyword).append(" ").append(expression); + return builder; + } + + @Override + public String toString() { + return keyword + " " + expression; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof KeywordArgument)) { + return false; + } + KeywordArgument that = (KeywordArgument) o; + return Objects.equals(keyword, that.keyword) + && Objects.equals(expression, that.expression); + } + + @Override + public int hashCode() { + return Objects.hash(keyword, expression); + } + } + + public static class HavingClause extends ASTNodeAccessImpl implements Expression { + HavingType havingType; + Expression expression; + + public HavingClause(HavingType havingType, Expression expression) { + this.havingType = havingType; + this.expression = expression; + } + + public HavingType getHavingType() { + return havingType; + } + + public HavingClause setHavingType(HavingType havingType) { + this.havingType = havingType; + return this; + } + + public Expression getExpression() { + return expression; + } + + public HavingClause setExpression(Expression expression) { + this.expression = expression; + return this; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expression.accept(expressionVisitor, context); + } - String ans = name + "" + params + ""; + public StringBuilder appendTo(StringBuilder builder) { + builder.append(" HAVING ").append(havingType.name()).append(" ").append(expression); + return builder; + } - if (isEscaped) { - ans = "{fn " + ans + "}"; - } + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } - return ans; - } + enum HavingType { + MAX, MIN; + } + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/HexValue.java b/src/main/java/net/sf/jsqlparser/expression/HexValue.java new file mode 100644 index 0000000000..55ee5d0e97 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/HexValue.java @@ -0,0 +1,94 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.Locale; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +import java.nio.charset.StandardCharsets; + +public class HexValue extends ASTNodeAccessImpl implements Expression { + + private String value; + + public HexValue() { + // empty constructor + } + + public HexValue(final String value) { + String val = value; + this.value = val; + } + + public static byte[] hexStringToByteArray(String s) { + int len = s.length(); + byte[] data = new byte[len / 2]; + for (int i = 0; i < len; i += 2) { + data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + + Character.digit(s.charAt(i + 1), 16)); + } + return data; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public HexValue withValue(String value) { + this.setValue(value); + return this; + } + + @Override + public String toString() { + return value; + } + + public String getDigits() { + return value.toUpperCase(Locale.ROOT).startsWith("0X") + ? value.substring(2) + : value.substring(2, value.length() - 1); + } + + public Long getLong() { + return Long.parseLong( + getDigits(), 16); + } + + public LongValue getLongValue() { + return new LongValue(getLong()); + } + + // `X'C3BC'` --> `'ü'` + public StringValue getStringValue() { + return new StringValue( + new String(hexStringToByteArray(getDigits()), StandardCharsets.UTF_8)); + } + + // `X'C3BC'` --> `\xC3\xBC` + public StringValue getBlob() { + StringBuilder builder = new StringBuilder(); + String digits = getDigits(); + int len = digits.length(); + for (int i = 0; i < len; i += 2) { + builder.append("\\x").append(digits.charAt(i)).append(digits.charAt(i + 1)); + } + return new StringValue(builder.toString()); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/HighExpression.java b/src/main/java/net/sf/jsqlparser/expression/HighExpression.java new file mode 100644 index 0000000000..4d3a9cd63a --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/HighExpression.java @@ -0,0 +1,42 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class HighExpression extends ASTNodeAccessImpl implements Expression { + private Expression expression; + + public HighExpression() { + // empty constructor + } + + public HighExpression(Expression expression) { + this.expression = expression; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + @Override + public String toString() { + return "HIGH " + expression.toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/IntervalExpression.java b/src/main/java/net/sf/jsqlparser/expression/IntervalExpression.java index a8470307b5..7e496b4ce9 100644 --- a/src/main/java/net/sf/jsqlparser/expression/IntervalExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/IntervalExpression.java @@ -1,48 +1,140 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; -/** - * - * @author wumpz - */ -public class IntervalExpression implements Expression { - private String parameter = null; - - public String getParameter() { - return parameter; - } - - public void setParameter(String parameter) { - this.parameter = parameter; - } - - @Override - public String toString() { - return "INTERVAL " + parameter; - } - - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +import java.util.Objects; + +public class IntervalExpression extends ASTNodeAccessImpl implements Expression { + + private final boolean intervalKeyword; + private String parameter = null; + private String intervalType = null; + private IntervalQualifier intervalQualifier = null; + private Expression expression = null; + + public IntervalExpression() { + this(true); + } + + public IntervalExpression(boolean intervalKeyword) { + this.intervalKeyword = intervalKeyword; + } + + public IntervalExpression(int value, String type) { + this.parameter = null; + this.intervalKeyword = true; + this.expression = new LongValue(value); + this.intervalType = type; + } + + public boolean isUsingIntervalKeyword() { + return intervalKeyword; + } + + public String getParameter() { + return parameter; + } + + public void setParameter(String parameter) { + this.parameter = parameter; + } + + /** + * Returns the non-standard single-identifier interval type (e.g. MySQL {@code INTERVAL 1 foo}), + * or {@code null} when a structured {@link IntervalQualifier} is present. + * + * @deprecated the structured {@link #getIntervalQualifier()} is the canonical representation. + * This legacy field is kept only for the non-standard single-identifier form. + * @return the legacy interval type, or {@code null} if a qualifier is set + */ + @Deprecated + public String getIntervalType() { + return intervalType; + } + + /** + * Sets the non-standard single-identifier interval type (e.g. MySQL {@code INTERVAL 1 foo}) and + * clears any structured qualifier. + * + * @deprecated use {@link #setIntervalQualifier(IntervalQualifier)} for the standard form. + * @param intervalType the legacy interval type + */ + @Deprecated + public void setIntervalType(String intervalType) { + this.intervalType = intervalType; + this.intervalQualifier = null; + } + + public IntervalQualifier getIntervalQualifier() { + return intervalQualifier; + } + + /** + * Sets the structured interval qualifier and clears the legacy interval type. + */ + public void setIntervalQualifier(IntervalQualifier intervalQualifier) { + this.intervalQualifier = intervalQualifier; + this.intervalType = null; + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + @Override + public String toString() { + return (intervalKeyword ? "INTERVAL " : "") + + Objects.toString(expression, parameter) + + (intervalQualifier != null + ? " " + intervalQualifier.toString() + : (intervalType != null ? " " + intervalType : "")); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public IntervalExpression withParameter(String parameter) { + this.setParameter(parameter); + return this; + } + + /** + * @deprecated use {@link #withIntervalQualifier(IntervalQualifier)} for the standard form. + * @param intervalType the legacy interval type + * @return this instance + */ + @Deprecated + public IntervalExpression withIntervalType(String intervalType) { + this.setIntervalType(intervalType); + return this; + } + + public IntervalExpression withIntervalQualifier(IntervalQualifier intervalQualifier) { + this.setIntervalQualifier(intervalQualifier); + return this; + } + + public IntervalExpression withExpression(Expression expression) { + this.setExpression(expression); + return this; + } + + public E getExpression(Class type) { + return type.cast(getExpression()); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/IntervalQualifier.java b/src/main/java/net/sf/jsqlparser/expression/IntervalQualifier.java new file mode 100644 index 0000000000..a9676c69ca --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/IntervalQualifier.java @@ -0,0 +1,123 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.io.Serializable; +import java.util.Objects; + +/** + * Models an SQL interval qualifier as defined by the SQL standard (see + * PostgreSQL: Interval + * Input), e.g. {@code YEAR}, {@code DAY TO SECOND}, {@code DAY(9) TO SECOND} or + * {@code SECOND(2, 4)}. + *

+ * It is shared by {@link IntervalExpression} (the {@code INTERVAL ...} expression literal, used in + * DML) and by {@code net.sf.jsqlparser.statement.create.table.ColDataType} (the {@code INTERVAL} + * column / cast target type, used in DDL), so the qualifier is represented once and round-trips + * consistently across all contexts. + */ +public final class IntervalQualifier implements Serializable { + + private final String leadingField; + private final Integer leadingFieldPrecision; + private final String trailingField; + private final Integer fractionalSecondsPrecision; + + public IntervalQualifier( + String leadingField, Integer leadingFieldPrecision, String trailingField, + Integer fractionalSecondsPrecision) { + this.leadingField = leadingField; + this.leadingFieldPrecision = leadingFieldPrecision; + this.trailingField = trailingField; + this.fractionalSecondsPrecision = fractionalSecondsPrecision; + } + + public String getLeadingField() { + return leadingField; + } + + public Integer getLeadingFieldPrecision() { + return leadingFieldPrecision; + } + + public String getTrailingField() { + return trailingField; + } + + public Integer getFractionalSecondsPrecision() { + return fractionalSecondsPrecision; + } + + public IntervalQualifier withLeadingField(String leadingField) { + return new IntervalQualifier( + leadingField, leadingFieldPrecision, trailingField, fractionalSecondsPrecision); + } + + public IntervalQualifier withLeadingFieldPrecision(Integer leadingFieldPrecision) { + return new IntervalQualifier( + leadingField, leadingFieldPrecision, trailingField, fractionalSecondsPrecision); + } + + public IntervalQualifier withTrailingField(String trailingField) { + return new IntervalQualifier( + leadingField, leadingFieldPrecision, trailingField, fractionalSecondsPrecision); + } + + public IntervalQualifier withFractionalSecondsPrecision(Integer fractionalSecondsPrecision) { + return new IntervalQualifier( + leadingField, leadingFieldPrecision, trailingField, fractionalSecondsPrecision); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof IntervalQualifier)) { + return false; + } + IntervalQualifier that = (IntervalQualifier) o; + return Objects.equals(leadingField, that.leadingField) + && Objects.equals(leadingFieldPrecision, that.leadingFieldPrecision) + && Objects.equals(trailingField, that.trailingField) + && Objects.equals(fractionalSecondsPrecision, that.fractionalSecondsPrecision); + } + + @Override + public int hashCode() { + return Objects.hash( + leadingField, leadingFieldPrecision, trailingField, fractionalSecondsPrecision); + } + + /** + * Renders the qualifier back to SQL, e.g. {@code DAY}, {@code DAY TO SECOND}, + * {@code DAY(9) TO SECOND} or {@code SECOND(2, 4)}. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(Objects.toString(leadingField, "")); + if (leadingFieldPrecision != null) { + sb.append("(").append(leadingFieldPrecision); + // For a single-field qualifier such as SECOND(2, 4), the fractional seconds + // precision is rendered together with the leading precision. + if (trailingField == null && fractionalSecondsPrecision != null) { + sb.append(", ").append(fractionalSecondsPrecision); + } + sb.append(")"); + } + if (trailingField != null) { + sb.append(" TO ").append(trailingField); + if (fractionalSecondsPrecision != null) { + sb.append("(").append(fractionalSecondsPrecision).append(")"); + } + } + return sb.toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/Inverse.java b/src/main/java/net/sf/jsqlparser/expression/Inverse.java new file mode 100644 index 0000000000..b50d8be8fd --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/Inverse.java @@ -0,0 +1,42 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class Inverse extends ASTNodeAccessImpl implements Expression { + private Expression expression; + + public Inverse() { + // empty constructor + } + + public Inverse(Expression expression) { + this.expression = expression; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + @Override + public String toString() { + return "INVERSE (" + expression.toString() + ")"; + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/JdbcNamedParameter.java b/src/main/java/net/sf/jsqlparser/expression/JdbcNamedParameter.java index 438c6e24e2..84aa0b34e7 100644 --- a/src/main/java/net/sf/jsqlparser/expression/JdbcNamedParameter.java +++ b/src/main/java/net/sf/jsqlparser/expression/JdbcNamedParameter.java @@ -1,54 +1,55 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; -/** - * - * @author aud - */ -public class JdbcNamedParameter implements Expression { - - private String name; - - /** - * The name of the parameter - * - * @return the name of the parameter - */ - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } - - @Override - public String toString() { - return ":" + name; - } +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class JdbcNamedParameter extends ASTNodeAccessImpl implements Expression { + private String parameterCharacter = ":"; + private String name; + + public JdbcNamedParameter() {} + + public JdbcNamedParameter(String name) { + this.name = name; + } + + public String getParameterCharacter() { + return parameterCharacter; + } + + public JdbcNamedParameter setParameterCharacter(String parameterCharacter) { + this.parameterCharacter = parameterCharacter; + return this; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + return parameterCharacter + name; + } + + public JdbcNamedParameter withName(String name) { + this.setName(name); + return this; + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/JdbcParameter.java b/src/main/java/net/sf/jsqlparser/expression/JdbcParameter.java index 030e8b0ac7..f512c47fc3 100644 --- a/src/main/java/net/sf/jsqlparser/expression/JdbcParameter.java +++ b/src/main/java/net/sf/jsqlparser/expression/JdbcParameter.java @@ -1,38 +1,88 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /** - * A '?' in a statement + * A '?' in a statement or a ?<number> e.g. ?4 */ -public class JdbcParameter implements Expression { +public class JdbcParameter extends ASTNodeAccessImpl implements Expression { + + private String parameterCharacter = "?"; + private Integer index; + private boolean useFixedIndex = false; + + public JdbcParameter() {} + + public JdbcParameter(Integer index, boolean useFixedIndex, String parameterCharacter) { + this.index = index; + this.useFixedIndex = useFixedIndex; + this.parameterCharacter = parameterCharacter; + + // This is needed for Parameters starting with "$" like "$2" + // Those will contain the index in the parameterCharacter + final Pattern pattern = Pattern.compile("(\\$)(\\d*)"); + final Matcher matcher = pattern.matcher(parameterCharacter); + if (matcher.find() && matcher.groupCount() == 2) { + this.useFixedIndex = true; + this.parameterCharacter = matcher.group(1); + this.index = Integer.valueOf(matcher.group(2)); + } + } + + public String getParameterCharacter() { + return parameterCharacter; + } + + public JdbcParameter setParameterCharacter(String parameterCharacter) { + this.parameterCharacter = parameterCharacter; + return this; + } + + public Integer getIndex() { + return index; + } + + public void setIndex(Integer index) { + this.index = index; + } + + public boolean isUseFixedIndex() { + return useFixedIndex; + } + + public void setUseFixedIndex(boolean useFixedIndex) { + this.useFixedIndex = useFixedIndex; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + return useFixedIndex ? parameterCharacter + index : parameterCharacter; + } - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public JdbcParameter withIndex(Integer index) { + this.setIndex(index); + return this; + } - @Override - public String toString() { - return "?"; - } + public JdbcParameter withUseFixedIndex(boolean useFixedIndex) { + this.setUseFixedIndex(useFixedIndex); + return this; + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/JsonAggregateFunction.java b/src/main/java/net/sf/jsqlparser/expression/JsonAggregateFunction.java new file mode 100644 index 0000000000..a60e52b7fa --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/JsonAggregateFunction.java @@ -0,0 +1,296 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.List; +import java.util.Locale; +import java.util.Objects; + +import net.sf.jsqlparser.statement.select.OrderByElement; + +/** + * @author Andreas Reichel + */ + +public class JsonAggregateFunction extends FilterOverImpl implements Expression { + private final OrderByClause expressionOrderBy = new OrderByClause(); + private JsonFunctionType functionType; + private Expression expression = null; + private boolean usingKeyKeyword = false; + private Object key; + private boolean usingValueKeyword = false; + private Object value; + + private boolean usingFormatJson = false; + + private JsonAggregateOnNullType onNullType; + private JsonAggregateUniqueKeysType uniqueKeysType; + + + public JsonAggregateOnNullType getOnNullType() { + return onNullType; + } + + public void setOnNullType(JsonAggregateOnNullType onNullType) { + this.onNullType = onNullType; + } + + public JsonAggregateFunction withOnNullType(JsonAggregateOnNullType onNullType) { + this.setOnNullType(onNullType); + return this; + } + + public JsonAggregateUniqueKeysType getUniqueKeysType() { + return uniqueKeysType; + } + + public void setUniqueKeysType(JsonAggregateUniqueKeysType uniqueKeysType) { + this.uniqueKeysType = uniqueKeysType; + } + + public JsonAggregateFunction withUniqueKeysType(JsonAggregateUniqueKeysType uniqueKeysType) { + this.setUniqueKeysType(uniqueKeysType); + return this; + } + + public JsonFunctionType getType() { + return functionType; + } + + public void setType(JsonFunctionType type) { + this.functionType = Objects.requireNonNull(type, + "The Type of the JSON Aggregate Function must not be null"); + } + + public void setType(String typeName) { + this.functionType = JsonFunctionType + .valueOf(Objects + .requireNonNull(typeName, + "The Type of the JSON Aggregate Function must not be null") + .toUpperCase(Locale.ROOT)); + } + + public JsonAggregateFunction withType(JsonFunctionType type) { + this.setType(type); + return this; + } + + public JsonAggregateFunction withType(String typeName) { + this.setType(typeName); + return this; + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + public JsonAggregateFunction withExpression(Expression expression) { + this.setExpression(expression); + return this; + } + + public boolean isUsingKeyKeyword() { + return usingKeyKeyword; + } + + public void setUsingKeyKeyword(boolean usingKeyKeyword) { + this.usingKeyKeyword = usingKeyKeyword; + } + + public JsonAggregateFunction withUsingKeyKeyword(boolean usingKeyKeyword) { + this.setUsingKeyKeyword(usingKeyKeyword); + return this; + } + + public Object getKey() { + return key; + } + + public void setKey(Object key) { + this.key = key; + } + + public JsonAggregateFunction withKey(Object key) { + this.setKey(key); + return this; + } + + public boolean isUsingValueKeyword() { + return usingValueKeyword; + } + + public void setUsingValueKeyword(boolean usingValueKeyword) { + this.usingValueKeyword = usingValueKeyword; + } + + public JsonAggregateFunction withUsingValueKeyword(boolean usingValueKeyword) { + this.setUsingValueKeyword(usingValueKeyword); + return this; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + public JsonAggregateFunction withValue(Object value) { + this.setValue(value); + return this; + } + + public boolean isUsingFormatJson() { + return usingFormatJson; + } + + public void setUsingFormatJson(boolean usingFormatJson) { + this.usingFormatJson = usingFormatJson; + } + + public JsonAggregateFunction withUsingFormatJson(boolean usingFormatJson) { + this.setUsingFormatJson(usingFormatJson); + return this; + } + + public List getExpressionOrderByElements() { + return expressionOrderBy.getOrderByElements(); + } + + public void setExpressionOrderByElements(List orderByElements) { + expressionOrderBy.setOrderByElements(orderByElements); + } + + public JsonAggregateFunction withExpressionOrderByElements( + List orderByElements) { + this.setExpressionOrderByElements(orderByElements); + return this; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + // avoid countless Builder --> String conversion + @Override + public StringBuilder append(StringBuilder builder) { + switch (functionType) { + case OBJECT: + case MYSQL_OBJECT: + appendObject(builder); + break; + case ARRAY: + appendArray(builder); + break; + default: + // this should never happen really + throw new UnsupportedOperationException("JSON Aggregate Function of the type " + + functionType.name() + " has not been implemented yet."); + } + return builder; + } + + @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"}) + public StringBuilder appendObject(StringBuilder builder) { + builder.append("JSON_OBJECTAGG( "); + if (usingValueKeyword) { + if (usingKeyKeyword) { + builder.append("KEY "); + } + builder.append(key).append(" VALUE ").append(value); + } else if (functionType == JsonFunctionType.MYSQL_OBJECT) { + builder.append(key).append(", ").append(value); + } else { + builder.append(key).append(":").append(value); + } + + if (usingFormatJson) { + builder.append(" FORMAT JSON"); + } + + if (onNullType != null) { + switch (onNullType) { + case NULL: + builder.append(" NULL ON NULL"); + break; + case ABSENT: + builder.append(" ABSENT On NULL"); + break; + default: + // this should never happen + } + } + + if (uniqueKeysType != null) { + switch (uniqueKeysType) { + case WITH: + builder.append(" WITH UNIQUE KEYS"); + break; + case WITHOUT: + builder.append(" WITHOUT UNIQUE KEYS"); + break; + default: + // this should never happen + } + } + + builder.append(" ) "); + + + // FILTER( WHERE expression ) OVER windowNameOrSpecification + super.append(builder); + + return builder; + } + + @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"}) + public StringBuilder appendArray(StringBuilder builder) { + builder.append("JSON_ARRAYAGG( "); + builder.append(expression).append(" "); + + if (usingFormatJson) { + builder.append("FORMAT JSON "); + } + + expressionOrderBy.toStringOrderByElements(builder); + + if (onNullType != null) { + switch (onNullType) { + case NULL: + builder.append(" NULL ON NULL "); + break; + case ABSENT: + builder.append(" ABSENT On NULL "); + break; + default: + // "ON NULL" was ommitted + } + } + builder.append(") "); + + + // FILTER( WHERE expression ) OVER windowNameOrSpecification + super.append(builder); + + return builder; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return append(builder).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/JsonAggregateOnNullType.java b/src/main/java/net/sf/jsqlparser/expression/JsonAggregateOnNullType.java new file mode 100644 index 0000000000..0cfcf4e025 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/JsonAggregateOnNullType.java @@ -0,0 +1,39 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2021 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +/* + * Copyright (C) 2021 JSQLParser. + * + * This library is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version + * 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; + * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +package net.sf.jsqlparser.expression; + +import java.util.Locale; + +/** + * @author Andreas Reichel + */ +public enum JsonAggregateOnNullType { + NULL, ABSENT; + + public static JsonAggregateOnNullType from(String type) { + return Enum.valueOf(JsonAggregateOnNullType.class, type.toUpperCase(Locale.ROOT)); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/JsonAggregateUniqueKeysType.java b/src/main/java/net/sf/jsqlparser/expression/JsonAggregateUniqueKeysType.java new file mode 100644 index 0000000000..b1c1cd2350 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/JsonAggregateUniqueKeysType.java @@ -0,0 +1,39 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2021 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +/* + * Copyright (C) 2021 JSQLParser. + * + * This library is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version + * 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; + * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +package net.sf.jsqlparser.expression; + +import java.util.Locale; + +/** + * @author Andreas Reichel + */ +public enum JsonAggregateUniqueKeysType { + WITH, WITHOUT; + + public static JsonAggregateUniqueKeysType from(String type) { + return Enum.valueOf(JsonAggregateUniqueKeysType.class, type.toUpperCase(Locale.ROOT)); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/JsonExpression.java b/src/main/java/net/sf/jsqlparser/expression/JsonExpression.java index 7e977f37c4..7cd34b53d7 100644 --- a/src/main/java/net/sf/jsqlparser/expression/JsonExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/JsonExpression.java @@ -1,91 +1,102 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2014 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ -/* - * Copyright (C) 2014 JSQLParser. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301 USA - */ - package net.sf.jsqlparser.expression; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +import java.util.AbstractMap; import java.util.ArrayList; +import java.util.Collection; import java.util.List; -import net.sf.jsqlparser.schema.Column; +import java.util.Map; -/** - * - * @author toben - */ -public class JsonExpression implements Expression { +public class JsonExpression extends ASTNodeAccessImpl implements Expression { + private final List> idents = new ArrayList<>(); + private Expression expr; + + public JsonExpression() { + + } + + public JsonExpression(Expression expr) { + this.expr = expr; + } + + public JsonExpression(Expression expr, List> idents) { + this.expr = expr; + this.idents.addAll(idents); + } - private Column column; - - private List idents = new ArrayList(); - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public Expression getExpression() { + return expr; + } + + public void setExpression(Expression expr) { + this.expr = expr; } - public Column getColumn() { - return column; + public void addIdent(Expression ident, String operator) { + idents.add(new AbstractMap.SimpleEntry<>(ident, operator)); } - public void setColumn(Column column) { - this.column = column; + public void addAllIdents(Collection> idents) { + this.idents.addAll(idents); } - public List getIdents() { + public List> getIdentList() { return idents; } - public void setIdents(List idents) { - this.idents = idents; + public Map.Entry getIdent(int index) { + return idents.get(index); + } + + @Deprecated + public List getIdents() { + ArrayList l = new ArrayList<>(); + for (Map.Entry ident : idents) { + l.add(ident.getKey()); + } + + return l; } - - public void addIdent(String ident) { - idents.add(ident); + + @Deprecated + public List getOperators() { + ArrayList l = new ArrayList<>(); + for (Map.Entry ident : idents) { + l.add(ident.getValue()); + } + return l; } - + @Override public String toString() { StringBuilder b = new StringBuilder(); - b.append(column.toString()); - for (String ident : idents) { - b.append("->").append(ident); + b.append(expr.toString()); + for (Map.Entry ident : idents) { + // Separate the operator with spaces: without them `#>`/`#>>` glue onto + // the operand (e.g. `a#>'{b}'`), and since `#` is a legal identifier + // character the result re-parses as `a#` `>` `...` -- a different tree. + b.append(' ').append(ident.getValue()).append(' ').append(ident.getKey()); } return b.toString(); } + + public JsonExpression withExpression(Expression expr) { + this.setExpression(expr); + return this; + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/JsonFunction.java b/src/main/java/net/sf/jsqlparser/expression/JsonFunction.java new file mode 100644 index 0000000000..7331ded7d3 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/JsonFunction.java @@ -0,0 +1,653 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.ArrayList; +import java.util.Locale; +import java.util.Objects; +import java.util.function.Consumer; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.create.table.ColDataType; + +/** + * Represents a JSON-Function.
+ * Currently supported are the types in {@link JsonFunctionType}.
+ *
+ * For JSON_OBJECT the parameters are available from {@link #getKeyValuePairs()}
+ *
+ * For JSON_ARRAY the parameters are availble from {@link #getExpressions()}.
+ * + * @author Andreas Reichel + */ +public class JsonFunction extends ASTNodeAccessImpl implements Expression { + public enum JsonOnResponseBehaviorType { + ERROR, NULL, DEFAULT, EMPTY, EMPTY_ARRAY, EMPTY_OBJECT, TRUE, FALSE, UNKNOWN + } + + public enum JsonWrapperType { + WITHOUT, WITH + } + + public enum JsonWrapperMode { + CONDITIONAL, UNCONDITIONAL + } + + public enum JsonQuotesType { + KEEP, OMIT + } + + public enum ScalarsType { + ALLOW, DISALLOW + } + + public static class JsonOnResponseBehavior { + private JsonOnResponseBehaviorType type; + private Expression expression; + + public JsonOnResponseBehavior(JsonOnResponseBehaviorType type) { + this(type, null); + } + + public JsonOnResponseBehavior(JsonOnResponseBehaviorType type, Expression expression) { + this.type = type; + this.expression = expression; + } + + public JsonOnResponseBehaviorType getType() { + return type; + } + + public void setType(JsonOnResponseBehaviorType type) { + this.type = type; + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + public StringBuilder append(StringBuilder builder) { + return appendTo(builder, builder::append); + } + + public StringBuilder appendTo(StringBuilder builder, + Consumer expressionPrinter) { + switch (type) { + case ERROR: + builder.append("ERROR"); + break; + case NULL: + builder.append("NULL"); + break; + case DEFAULT: + builder.append("DEFAULT "); + if (expression == null) { + builder.append("null"); + } else { + expressionPrinter.accept(expression); + } + break; + case EMPTY: + builder.append("EMPTY "); + break; + case EMPTY_ARRAY: + builder.append("EMPTY ARRAY"); + break; + case EMPTY_OBJECT: + builder.append("EMPTY OBJECT"); + break; + case TRUE: + builder.append("TRUE"); + break; + case FALSE: + builder.append("FALSE"); + break; + case UNKNOWN: + builder.append("UNKNOWN"); + break; + default: + throw new IllegalStateException("Unhandled JsonOnResponseBehavior: " + type); + // this should never happen + } + return builder; + } + + @Override + public String toString() { + return append(new StringBuilder()).toString(); + } + } + + private final ArrayList keyValuePairs = new ArrayList<>(); + private final ArrayList expressions = new ArrayList<>(); + private final ArrayList passingExpressions = new ArrayList<>(); + private final ArrayList additionalQueryPathArguments = new ArrayList<>(); + private JsonFunctionType functionType; + private JsonAggregateOnNullType onNullType; + private JsonAggregateUniqueKeysType uniqueKeysType; + + private boolean isStrict = false; + private JsonFunctionExpression inputExpression; + private Expression jsonPathExpression; + private ColDataType returningType; + private boolean returningFormatJson; + private String returningEncoding; + private JsonOnResponseBehavior onEmptyBehavior; + private JsonOnResponseBehavior onErrorBehavior; + private JsonWrapperType wrapperType; + private JsonWrapperMode wrapperMode; + private boolean wrapperArray; + private JsonQuotesType quotesType; + private boolean quotesOnScalarString; + private ScalarsType scalarsType; + + public JsonFunction() {} + + public JsonFunction(JsonFunctionType functionType) { + this.functionType = functionType; + } + + /** + * Returns the Parameters of an JSON_OBJECT
+ * The KeyValuePairs may not have both key and value set, in some cases only the Key is set. + * + * @see net.sf.jsqlparser.parser.feature.Feature#allowCommaAsKeyValueSeparator + * + * @return A List of KeyValuePairs, never NULL + */ + public ArrayList getKeyValuePairs() { + return keyValuePairs; + } + + /** + * Returns the parameters of JSON_ARRAY
+ * + * @return A List of {@link JsonFunctionExpression}s, never NULL + */ + public ArrayList getExpressions() { + return expressions; + } + + public JsonKeyValuePair getKeyValuePair(int i) { + return keyValuePairs.get(i); + } + + public JsonFunctionExpression getExpression(int i) { + return expressions.get(i); + } + + public boolean add(JsonKeyValuePair keyValuePair) { + return keyValuePairs.add(keyValuePair); + } + + public void add(int i, JsonKeyValuePair keyValuePair) { + keyValuePairs.add(i, keyValuePair); + } + + public boolean add(JsonFunctionExpression expression) { + return expressions.add(expression); + } + + public void add(int i, JsonFunctionExpression expression) { + expressions.add(i, expression); + } + + public ArrayList getPassingExpressions() { + return passingExpressions; + } + + public boolean addPassingExpression(Expression expression) { + return passingExpressions.add(expression); + } + + public ArrayList getAdditionalQueryPathArguments() { + return additionalQueryPathArguments; + } + + public boolean addAdditionalQueryPathArgument(String argument) { + return additionalQueryPathArguments.add(argument); + } + + public JsonFunctionExpression getInputExpression() { + return inputExpression; + } + + public void setInputExpression(JsonFunctionExpression inputExpression) { + this.inputExpression = inputExpression; + } + + public Expression getJsonPathExpression() { + return jsonPathExpression; + } + + public void setJsonPathExpression(Expression jsonPathExpression) { + this.jsonPathExpression = jsonPathExpression; + } + + public ColDataType getReturningType() { + return returningType; + } + + public void setReturningType(ColDataType returningType) { + this.returningType = returningType; + } + + public boolean isReturningFormatJson() { + return returningFormatJson; + } + + public void setReturningFormatJson(boolean returningFormatJson) { + this.returningFormatJson = returningFormatJson; + } + + public String getReturningEncoding() { + return returningEncoding; + } + + public void setReturningEncoding(String returningEncoding) { + this.returningEncoding = returningEncoding; + } + + public JsonOnResponseBehavior getOnEmptyBehavior() { + return onEmptyBehavior; + } + + public void setOnEmptyBehavior(JsonOnResponseBehavior onEmptyBehavior) { + this.onEmptyBehavior = onEmptyBehavior; + } + + public JsonOnResponseBehavior getOnErrorBehavior() { + return onErrorBehavior; + } + + public void setOnErrorBehavior(JsonOnResponseBehavior onErrorBehavior) { + this.onErrorBehavior = onErrorBehavior; + } + + public JsonWrapperType getWrapperType() { + return wrapperType; + } + + public void setWrapperType(JsonWrapperType wrapperType) { + this.wrapperType = wrapperType; + } + + public JsonWrapperMode getWrapperMode() { + return wrapperMode; + } + + public void setWrapperMode(JsonWrapperMode wrapperMode) { + this.wrapperMode = wrapperMode; + } + + public boolean isWrapperArray() { + return wrapperArray; + } + + public void setWrapperArray(boolean wrapperArray) { + this.wrapperArray = wrapperArray; + } + + public JsonQuotesType getQuotesType() { + return quotesType; + } + + public void setQuotesType(JsonQuotesType quotesType) { + this.quotesType = quotesType; + } + + public boolean isQuotesOnScalarString() { + return quotesOnScalarString; + } + + public void setQuotesOnScalarString(boolean quotesOnScalarString) { + this.quotesOnScalarString = quotesOnScalarString; + } + + public ScalarsType getScalarsType() { + return scalarsType; + } + + public void setScalarsType(ScalarsType type) { + this.scalarsType = type; + } + + public boolean isEmpty() { + return keyValuePairs.isEmpty(); + } + + public JsonAggregateOnNullType getOnNullType() { + return onNullType; + } + + public void setOnNullType(JsonAggregateOnNullType onNullType) { + this.onNullType = onNullType; + } + + public JsonFunction withOnNullType(JsonAggregateOnNullType onNullType) { + this.setOnNullType(onNullType); + return this; + } + + public JsonAggregateUniqueKeysType getUniqueKeysType() { + return uniqueKeysType; + } + + public void setUniqueKeysType(JsonAggregateUniqueKeysType uniqueKeysType) { + this.uniqueKeysType = uniqueKeysType; + } + + public JsonFunction withUniqueKeysType(JsonAggregateUniqueKeysType uniqueKeysType) { + this.setUniqueKeysType(uniqueKeysType); + return this; + } + + public JsonFunctionType getType() { + return functionType; + } + + public void setType(JsonFunctionType type) { + this.functionType = + Objects.requireNonNull(type, + "The Type of the JSON Aggregate Function must not be null"); + } + + public void setType(String typeName) { + this.functionType = JsonFunctionType.valueOf( + Objects.requireNonNull(typeName, + "The Type of the JSON Aggregate Function must not be null") + .toUpperCase(Locale.ROOT)); + } + + public JsonFunction withType(JsonFunctionType type) { + this.setType(type); + return this; + } + + public JsonFunction withType(String typeName) { + this.setType(typeName); + return this; + } + + public boolean isStrict() { + return isStrict; + } + + public void setStrict(boolean strict) { + isStrict = strict; + } + + public JsonFunction withStrict(boolean strict) { + this.setStrict(strict); + return this; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + // avoid countless Builder --> String conversion + public StringBuilder append(StringBuilder builder) { + return appendTo(builder, builder::append); + } + + /** Renders structured children through the supplied expression printer. */ + public StringBuilder appendTo(StringBuilder builder, Consumer expressionPrinter) { + switch (functionType) { + case OBJECT: + case POSTGRES_OBJECT: + case MYSQL_OBJECT: + appendObject(builder, expressionPrinter); + break; + case ARRAY: + appendArray(builder, expressionPrinter); + break; + case VALUE: + appendValue(builder, expressionPrinter); + break; + case QUERY: + appendQuery(builder, expressionPrinter); + break; + case EXISTS: + appendExists(builder, expressionPrinter); + break; + default: + // this should never happen really + } + return builder; + } + + public StringBuilder appendObject(StringBuilder builder) { + return appendObject(builder, builder::append); + } + + @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"}) + public StringBuilder appendObject(StringBuilder builder, + Consumer expressionPrinter) { + builder.append("JSON_OBJECT("); + int start = builder.length(); + int i = 0; + for (JsonKeyValuePair keyValuePair : keyValuePairs) { + builder.append(i > 0 ? ", " : " "); + keyValuePair.appendTo(builder, expressionPrinter); + i++; + } + + appendOnNullType(builder); + if (isStrict) { + builder.append(" STRICT"); + } + appendUniqueKeys(builder); + appendReturningClause(builder, true); + + // An empty argument list renders as JSON_OBJECT() + builder.append(builder.length() > start ? " )" : ")"); + + return builder; + } + + private void appendOnNullType(StringBuilder builder) { + if (onNullType != null) { + switch (onNullType) { + case NULL: + builder.append(" NULL ON NULL"); + break; + case ABSENT: + builder.append(" ABSENT ON NULL"); + break; + default: + // this should never happen + } + } + } + + private void appendUniqueKeys(StringBuilder builder) { + if (uniqueKeysType != null) { + switch (uniqueKeysType) { + case WITH: + builder.append(" WITH UNIQUE KEYS"); + break; + case WITHOUT: + builder.append(" WITHOUT UNIQUE KEYS"); + break; + default: + // this should never happen + } + } + } + + public StringBuilder appendArray(StringBuilder builder) { + return appendArray(builder, builder::append); + } + + @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"}) + public StringBuilder appendArray(StringBuilder builder, + Consumer expressionPrinter) { + builder.append("JSON_ARRAY("); + int i = 0; + + for (JsonFunctionExpression expr : expressions) { + builder.append(i > 0 ? ", " : " "); + expr.appendTo(builder, expressionPrinter); + i++; + } + + appendOnNullType(builder); + appendReturningClause(builder, true); + builder.append(')'); + + return builder; + } + + public StringBuilder appendValue(StringBuilder builder) { + return appendValue(builder, builder::append); + } + + @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"}) + public StringBuilder appendValue(StringBuilder builder, + Consumer expressionPrinter) { + builder.append("JSON_VALUE("); + appendValueOrQueryPrefix(builder, expressionPrinter); + + if (returningType != null) { + builder.append(" RETURNING ").append(returningType); + } + + appendOnResponseClause(builder, onEmptyBehavior, "EMPTY", expressionPrinter); + appendOnResponseClause(builder, onErrorBehavior, "ERROR", expressionPrinter); + + builder.append(")"); + return builder; + } + + public StringBuilder appendQuery(StringBuilder builder) { + return appendQuery(builder, builder::append); + } + + @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"}) + public StringBuilder appendQuery(StringBuilder builder, + Consumer expressionPrinter) { + builder.append("JSON_QUERY("); + appendValueOrQueryPrefix(builder, expressionPrinter); + + appendReturningClause(builder, true); + + appendWrapperClause(builder); + appendQuotesClause(builder); + appendOnResponseClause(builder, onEmptyBehavior, "EMPTY", expressionPrinter); + appendOnResponseClause(builder, onErrorBehavior, "ERROR", expressionPrinter); + + for (String additionalQueryPathArgument : additionalQueryPathArguments) { + builder.append(", ").append(additionalQueryPathArgument); + } + + builder.append(")"); + return builder; + } + + public StringBuilder appendExists(StringBuilder builder) { + return appendExists(builder, builder::append); + } + + @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"}) + public StringBuilder appendExists(StringBuilder builder, + Consumer expressionPrinter) { + builder.append("JSON_EXISTS("); + appendValueOrQueryPrefix(builder, expressionPrinter); + appendOnResponseClause(builder, onErrorBehavior, "ERROR", expressionPrinter); + builder.append(")"); + return builder; + } + + private void appendValueOrQueryPrefix(StringBuilder builder, + Consumer expressionPrinter) { + if (inputExpression != null) { + inputExpression.appendTo(builder, expressionPrinter); + } + + if (jsonPathExpression != null) { + if (inputExpression != null) { + builder.append(", "); + } + expressionPrinter.accept(jsonPathExpression); + } + + if (!passingExpressions.isEmpty()) { + builder.append(" PASSING "); + boolean comma = false; + for (Expression passingExpression : passingExpressions) { + if (comma) { + builder.append(", "); + } else { + comma = true; + } + if (passingExpression == null) { + builder.append("null"); + } else { + expressionPrinter.accept(passingExpression); + } + } + } + } + + private void appendOnResponseClause(StringBuilder builder, JsonOnResponseBehavior behavior, + String clause, Consumer expressionPrinter) { + if (behavior != null) { + builder.append(" "); + behavior.appendTo(builder, expressionPrinter); + builder.append(" ON ").append(clause); + } + } + + private void appendReturningClause(StringBuilder builder, boolean formatJsonAllowed) { + if (returningType != null) { + builder.append(" RETURNING ").append(returningType); + if (formatJsonAllowed && returningFormatJson) { + builder.append(" FORMAT JSON"); + if (returningEncoding != null) { + builder.append(" ENCODING ").append(returningEncoding); + } + } + } + } + + private void appendWrapperClause(StringBuilder builder) { + if (wrapperType != null) { + builder.append(" ").append(wrapperType); + if (wrapperMode != null) { + builder.append(" ").append(wrapperMode); + } + if (wrapperArray) { + builder.append(" ARRAY"); + } + builder.append(" WRAPPER"); + } + } + + private void appendQuotesClause(StringBuilder builder) { + if (quotesType != null) { + builder.append(" ").append(quotesType).append(" QUOTES"); + if (quotesOnScalarString) { + builder.append(" ON SCALAR STRING"); + } + } + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return append(builder).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/JsonFunctionExpression.java b/src/main/java/net/sf/jsqlparser/expression/JsonFunctionExpression.java new file mode 100644 index 0000000000..b8a7007f5b --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/JsonFunctionExpression.java @@ -0,0 +1,80 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2021 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ + +package net.sf.jsqlparser.expression; + +import java.io.Serializable; +import java.util.Objects; +import java.util.function.Consumer; + +/** + * @author Andreas Reichel + */ + +public class JsonFunctionExpression implements Serializable { + private final Expression expression; + + private boolean usingFormatJson = false; + private String encoding; + + public JsonFunctionExpression(Expression expression) { + this.expression = Objects.requireNonNull(expression, "The EXPRESSION must not be null"); + } + + public Expression getExpression() { + return expression; + } + + public boolean isUsingFormatJson() { + return usingFormatJson; + } + + public void setUsingFormatJson(boolean usingFormatJson) { + this.usingFormatJson = usingFormatJson; + } + + public JsonFunctionExpression withUsingFormatJson(boolean usingFormatJson) { + this.setUsingFormatJson(usingFormatJson); + return this; + } + + public String getEncoding() { + return encoding; + } + + public void setEncoding(String encoding) { + this.encoding = encoding; + } + + public JsonFunctionExpression withEncoding(String encoding) { + this.setEncoding(encoding); + return this; + } + + public StringBuilder append(StringBuilder builder) { + return appendTo(builder, builder::append); + } + + public StringBuilder appendTo(StringBuilder builder, Consumer expressionPrinter) { + expressionPrinter.accept(getExpression()); + if (isUsingFormatJson()) { + builder.append(" FORMAT JSON"); + if (encoding != null) { + builder.append(" ENCODING ").append(encoding); + } + } + return builder; + } + + @Override + public String toString() { + return append(new StringBuilder()).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/JsonFunctionType.java b/src/main/java/net/sf/jsqlparser/expression/JsonFunctionType.java new file mode 100644 index 0000000000..b9889d1ea7 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/JsonFunctionType.java @@ -0,0 +1,36 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2021 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ + +package net.sf.jsqlparser.expression; + +import java.util.Locale; + +/** + * @author Andreas Reichel + */ +public enum JsonFunctionType { + OBJECT, ARRAY, VALUE, QUERY, EXISTS, + + /** + * Not used anymore + */ + @Deprecated + POSTGRES_OBJECT, + + /** + * Not used anymore + */ + @Deprecated + MYSQL_OBJECT; + + public static JsonFunctionType from(String type) { + return Enum.valueOf(JsonFunctionType.class, type.toUpperCase(Locale.ROOT)); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/JsonKeyValuePair.java b/src/main/java/net/sf/jsqlparser/expression/JsonKeyValuePair.java new file mode 100644 index 0000000000..bd0ed4dad4 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/JsonKeyValuePair.java @@ -0,0 +1,195 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2021 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ + +package net.sf.jsqlparser.expression; + +import java.io.Serializable; +import java.util.Objects; +import java.util.function.Consumer; + +/** + * @author Andreas Reichel + */ + +public class JsonKeyValuePair implements Serializable { + private final Object key; + private final Object value; + private boolean usingKeyKeyword; + private JsonKeyValuePairSeparator separator; + private boolean usingFormatJson = false; + private String encoding; + + /** + * Please use the Constructor with {@link JsonKeyValuePairSeparator} parameter. + */ + @Deprecated + public JsonKeyValuePair(Object key, Object value, boolean usingKeyKeyword, + boolean usingValueKeyword) { + this(key, value, usingKeyKeyword, usingValueKeyword ? JsonKeyValuePairSeparator.VALUE + : JsonKeyValuePairSeparator.COLON); + } + + public JsonKeyValuePair(Object key, Object value, boolean usingKeyKeyword, + JsonKeyValuePairSeparator separator) { + this.key = Objects.requireNonNull(key, "The KEY of the Pair must not be null"); + this.value = value; + this.usingKeyKeyword = usingKeyKeyword; + this.separator = + Objects.requireNonNull(separator, "The KeyValuePairSeparator must not be NULL"); + } + + public boolean isUsingKeyKeyword() { + return usingKeyKeyword; + } + + public void setUsingKeyKeyword(boolean usingKeyKeyword) { + this.usingKeyKeyword = usingKeyKeyword; + } + + public JsonKeyValuePair withUsingKeyKeyword(boolean usingKeyKeyword) { + this.setUsingKeyKeyword(usingKeyKeyword); + return this; + } + + /** + * Use {@link #getSeparator()} + */ + @Deprecated + public boolean isUsingValueKeyword() { + return separator == JsonKeyValuePairSeparator.VALUE; + } + + /** + * Use {@link #setSeparator(JsonKeyValuePairSeparator)} + */ + @Deprecated + public void setUsingValueKeyword(boolean usingValueKeyword) { + separator = usingValueKeyword ? JsonKeyValuePairSeparator.VALUE + : JsonKeyValuePairSeparator.COLON; + } + + /** + * Use {@link #withSeparator(JsonKeyValuePairSeparator)} + */ + @Deprecated + public JsonKeyValuePair withUsingValueKeyword(boolean usingValueKeyword) { + this.setUsingValueKeyword(usingValueKeyword); + return this; + } + + public JsonKeyValuePairSeparator getSeparator() { + return separator; + } + + public void setSeparator(JsonKeyValuePairSeparator separator) { + this.separator = separator; + } + + public JsonKeyValuePair withSeparator(JsonKeyValuePairSeparator separator) { + this.setSeparator(separator); + return this; + } + + public boolean isUsingFormatJson() { + return usingFormatJson; + } + + public void setUsingFormatJson(boolean usingFormatJson) { + this.usingFormatJson = usingFormatJson; + } + + public JsonKeyValuePair withUsingFormatJson(boolean usingFormatJson) { + this.setUsingFormatJson(usingFormatJson); + return this; + } + + public String getEncoding() { + return encoding; + } + + public void setEncoding(String encoding) { + this.encoding = encoding; + } + + public JsonKeyValuePair withEncoding(String encoding) { + this.setEncoding(encoding); + return this; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 83 * hash + Objects.hashCode(this.key); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final JsonKeyValuePair other = (JsonKeyValuePair) obj; + return Objects.equals(this.key, other.key); + } + + public Object getKey() { + return key; + } + + public Object getValue() { + return value; + } + + public StringBuilder append(StringBuilder builder) { + return appendTo(builder, builder::append); + } + + public StringBuilder appendTo(StringBuilder builder, Consumer expressionPrinter) { + if (isUsingKeyKeyword() && getSeparator() == JsonKeyValuePairSeparator.VALUE) { + builder.append("KEY "); + } + appendValue(builder, getKey(), expressionPrinter); + + if (getValue() != null) { + builder.append(getSeparator().getSeparatorString()); + appendValue(builder, getValue(), expressionPrinter); + } + + if (isUsingFormatJson()) { + builder.append(" FORMAT JSON"); + if (encoding != null) { + builder.append(" ENCODING ").append(encoding); + } + } + + return builder; + } + + private static void appendValue(StringBuilder builder, Object value, + Consumer expressionPrinter) { + if (value instanceof Expression) { + expressionPrinter.accept((Expression) value); + } else { + builder.append(value); + } + } + + @Override + public String toString() { + return append(new StringBuilder()).toString(); + } + +} diff --git a/src/main/java/net/sf/jsqlparser/expression/JsonKeyValuePairSeparator.java b/src/main/java/net/sf/jsqlparser/expression/JsonKeyValuePairSeparator.java new file mode 100644 index 0000000000..e4e998aa54 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/JsonKeyValuePairSeparator.java @@ -0,0 +1,33 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2025 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +/** + * Describes the string used to separate the key from the value. + */ +public enum JsonKeyValuePairSeparator { + VALUE(" VALUE "), COLON(":"), + + // Used in MySQL dialect + COMMA(","), + + // Is used in case they KeyValuePair has only a key and no value + NOT_USED(""); + + private final String separator; + + JsonKeyValuePairSeparator(String separator) { + this.separator = separator; + } + + public String getSeparatorString() { + return separator; + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/JsonTableFunction.java b/src/main/java/net/sf/jsqlparser/expression/JsonTableFunction.java new file mode 100644 index 0000000000..65bb76f5fb --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/JsonTableFunction.java @@ -0,0 +1,1008 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.function.Consumer; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.create.table.ColDataType; + +public class JsonTableFunction extends Function { + + private Expression jsonInputExpression; + private Expression jsonPathExpression; + private String pathName; + private final List passingClauses = new ArrayList<>(); + private JsonTableColumnsClause columnsClause; + private JsonTablePlanClause planClause; + private JsonTableOnErrorClause onErrorClause; + private JsonTableParsingTypeClause parsingTypeClause; + private JsonTableOnEmptyClause onEmptyClause; + private boolean formatJson; + + public enum JsonTablePlanOperator { + COMMA(", "), INNER(" INNER "), OUTER(" OUTER "), CROSS(" CROSS "), UNION(" UNION "); + + private final String display; + + JsonTablePlanOperator(String display) { + this.display = display; + } + + public String getDisplay() { + return display; + } + } + + public enum JsonTableOnErrorType { + ERROR, NULL, EMPTY, TRUE, FALSE + } + + public enum JsonTableOnEmptyType { + ERROR, NULL, EMPTY, TRUE, FALSE + } + + public enum JsonTableParsingType { + STRICT, LAX + } + + public static class JsonTablePassingClause extends ASTNodeAccessImpl implements Serializable { + private Expression valueExpression; + private String parameterName; + + public JsonTablePassingClause() {} + + public JsonTablePassingClause(Expression valueExpression, String parameterName) { + this.valueExpression = valueExpression; + this.parameterName = parameterName; + } + + public Expression getValueExpression() { + return valueExpression; + } + + public JsonTablePassingClause setValueExpression(Expression valueExpression) { + this.valueExpression = valueExpression; + return this; + } + + public String getParameterName() { + return parameterName; + } + + public JsonTablePassingClause setParameterName(String parameterName) { + this.parameterName = parameterName; + return this; + } + + public void collectExpressions(List expressions) { + if (valueExpression != null) { + expressions.add(valueExpression); + } + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, builder::append).toString(); + } + + public StringBuilder appendTo(StringBuilder builder, + Consumer expressionPrinter) { + printExpression(builder, valueExpression, expressionPrinter); + return builder.append(" AS ").append(parameterName); + } + } + + public static class JsonTableWrapperClause extends ASTNodeAccessImpl implements Serializable { + private boolean beforePathExpression; + private JsonFunction.JsonWrapperType wrapperType; + private JsonFunction.JsonWrapperMode wrapperMode; + private boolean array; + + /** + * Creates a wrapper clause. Depending on the dialect, this clause can come before or after + * the PATH expression. + *

    + *
  • Trino: after PATH
  • + *
  • Oracle: before PATH
  • + *
+ * + * @param beforePathExpression A flag to determine wether the clause is rendered before or + * after the PATH expression + */ + public JsonTableWrapperClause(boolean beforePathExpression) { + this.beforePathExpression = beforePathExpression; + } + + public boolean isBeforePathExpression() { + return beforePathExpression; + } + + public JsonFunction.JsonWrapperType getWrapperType() { + return wrapperType; + } + + public JsonTableWrapperClause setWrapperType(JsonFunction.JsonWrapperType wrapperType) { + this.wrapperType = wrapperType; + return this; + } + + public JsonFunction.JsonWrapperMode getWrapperMode() { + return wrapperMode; + } + + public JsonTableWrapperClause setWrapperMode(JsonFunction.JsonWrapperMode wrapperMode) { + this.wrapperMode = wrapperMode; + return this; + } + + public boolean isArray() { + return array; + } + + public JsonTableWrapperClause setArray(boolean array) { + this.array = array; + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append(wrapperType); + if (wrapperMode != null) { + builder.append(" ").append(wrapperMode); + } + if (array) { + builder.append(" ARRAY"); + } + builder.append(" WRAPPER"); + return builder.toString(); + } + } + + public static class JsonTableQuotesClause extends ASTNodeAccessImpl implements Serializable { + private JsonFunction.JsonQuotesType quotesType; + private boolean onScalarString; + + public JsonFunction.JsonQuotesType getQuotesType() { + return quotesType; + } + + public JsonTableQuotesClause setQuotesType(JsonFunction.JsonQuotesType quotesType) { + this.quotesType = quotesType; + return this; + } + + public boolean isOnScalarString() { + return onScalarString; + } + + public JsonTableQuotesClause setOnScalarString(boolean onScalarString) { + this.onScalarString = onScalarString; + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append(quotesType).append(" QUOTES"); + if (onScalarString) { + builder.append(" ON SCALAR STRING"); + } + return builder.toString(); + } + } + + public static class JsonTableOnErrorClause extends ASTNodeAccessImpl implements Serializable { + private JsonTableOnErrorType type; + private boolean beforeColumns = true; + + public JsonTableOnErrorClause(boolean beforeColumns) { + this.beforeColumns = beforeColumns; + } + + public boolean isBeforeColumns() { + return beforeColumns; + } + + public JsonTableOnErrorType getType() { + return type; + } + + public JsonTableOnErrorClause setType(JsonTableOnErrorType type) { + this.type = type; + return this; + } + + @Override + public String toString() { + return type + " ON ERROR"; + } + } + + public static class JsonTableOnEmptyClause extends ASTNodeAccessImpl implements Serializable { + private JsonTableOnEmptyType type; + + public JsonTableOnEmptyType getType() { + return type; + } + + public JsonTableOnEmptyClause setType(JsonTableOnEmptyType type) { + this.type = type; + return this; + } + + @Override + public String toString() { + return type + " ON EMPTY"; + } + } + + public static class JsonTableParsingTypeClause extends ASTNodeAccessImpl + implements Serializable { + private JsonTableParsingType type; + + public JsonTableParsingType getType() { + return type; + } + + public JsonTableParsingTypeClause setType(JsonTableParsingType type) { + this.type = type; + return this; + } + + @Override + public String toString() { + return "TYPE(" + type + ")"; + } + } + + public static class JsonTablePlanTerm extends ASTNodeAccessImpl implements Serializable { + private JsonTablePlanExpression nestedPlanExpression; + private String name; + private Expression expression; + + public JsonTablePlanExpression getNestedPlanExpression() { + return nestedPlanExpression; + } + + public JsonTablePlanTerm setNestedPlanExpression( + JsonTablePlanExpression nestedPlanExpression) { + this.nestedPlanExpression = nestedPlanExpression; + return this; + } + + public String getName() { + return name; + } + + public JsonTablePlanTerm setName(String name) { + this.name = name; + return this; + } + + public Expression getExpression() { + return expression; + } + + public JsonTablePlanTerm setExpression(Expression expression) { + this.expression = expression; + return this; + } + + public void collectExpressions(List expressions) { + if (expression != null) { + expressions.add(expression); + } + if (nestedPlanExpression != null) { + nestedPlanExpression.collectExpressions(expressions); + } + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, builder::append).toString(); + } + + public StringBuilder appendTo(StringBuilder builder, + Consumer expressionPrinter) { + if (nestedPlanExpression != null) { + builder.append("("); + nestedPlanExpression.appendTo(builder, expressionPrinter); + builder.append(")"); + } else if (name != null) { + builder.append(name); + } else if (expression != null) { + expressionPrinter.accept(expression); + } + return builder; + } + } + + public static class JsonTablePlanExpression extends ASTNodeAccessImpl implements Serializable { + private final List terms = new ArrayList<>(); + private final List operators = new ArrayList<>(); + + public List getTerms() { + return terms; + } + + public JsonTablePlanExpression addTerm(JsonTablePlanTerm term) { + terms.add(term); + return this; + } + + public List getOperators() { + return operators; + } + + public JsonTablePlanExpression addOperator(JsonTablePlanOperator operator) { + operators.add(operator); + return this; + } + + public void collectExpressions(List expressions) { + for (JsonTablePlanTerm term : terms) { + if (term != null) { + term.collectExpressions(expressions); + } + } + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, builder::append).toString(); + } + + public StringBuilder appendTo(StringBuilder builder, + Consumer expressionPrinter) { + if (!terms.isEmpty()) { + appendTerm(builder, terms.get(0), expressionPrinter); + } + for (int i = 0; i < operators.size() && i + 1 < terms.size(); i++) { + builder.append(operators.get(i).getDisplay()); + appendTerm(builder, terms.get(i + 1), expressionPrinter); + } + return builder; + } + + private static void appendTerm(StringBuilder builder, JsonTablePlanTerm term, + Consumer expressionPrinter) { + if (term == null) { + builder.append("null"); + } else { + term.appendTo(builder, expressionPrinter); + } + } + } + + public static class JsonTablePlanClause extends ASTNodeAccessImpl implements Serializable { + private boolean defaultPlan; + private JsonTablePlanExpression planExpression; + + public boolean isDefaultPlan() { + return defaultPlan; + } + + public JsonTablePlanClause setDefaultPlan(boolean defaultPlan) { + this.defaultPlan = defaultPlan; + return this; + } + + public JsonTablePlanExpression getPlanExpression() { + return planExpression; + } + + public JsonTablePlanClause setPlanExpression(JsonTablePlanExpression planExpression) { + this.planExpression = planExpression; + return this; + } + + public void collectExpressions(List expressions) { + if (planExpression != null) { + planExpression.collectExpressions(expressions); + } + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, builder::append).toString(); + } + + public StringBuilder appendTo(StringBuilder builder, + Consumer expressionPrinter) { + builder.append("PLAN"); + if (defaultPlan) { + builder.append(" DEFAULT"); + } + builder.append(" ("); + if (planExpression == null) { + builder.append("null"); + } else { + planExpression.appendTo(builder, expressionPrinter); + } + builder.append(")"); + return builder; + } + } + + public abstract static class JsonTableColumnDefinition extends ASTNodeAccessImpl + implements Serializable { + public abstract void collectExpressions(List expressions); + + /** Custom column definitions retain their existing SQL renderer by default. */ + public StringBuilder appendTo(StringBuilder builder, + Consumer expressionPrinter) { + return builder.append(this); + } + } + + public static class JsonTableNestedColumnDefinition extends JsonTableColumnDefinition { + private boolean pathKeyword; + private Expression pathExpression; + private String pathName; + private JsonTableColumnsClause columnsClause; + + public boolean isPathKeyword() { + return pathKeyword; + } + + public JsonTableNestedColumnDefinition setPathKeyword(boolean pathKeyword) { + this.pathKeyword = pathKeyword; + return this; + } + + public Expression getPathExpression() { + return pathExpression; + } + + public JsonTableNestedColumnDefinition setPathExpression(Expression pathExpression) { + this.pathExpression = pathExpression; + return this; + } + + public String getPathName() { + return pathName; + } + + public JsonTableNestedColumnDefinition setPathName(String pathName) { + this.pathName = pathName; + return this; + } + + public JsonTableColumnsClause getColumnsClause() { + return columnsClause; + } + + public JsonTableNestedColumnDefinition setColumnsClause( + JsonTableColumnsClause columnsClause) { + this.columnsClause = columnsClause; + return this; + } + + @Override + public void collectExpressions(List expressions) { + if (pathExpression != null) { + expressions.add(pathExpression); + } + if (columnsClause != null) { + columnsClause.collectExpressions(expressions); + } + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, builder::append).toString(); + } + + public StringBuilder appendTo(StringBuilder builder, + Consumer expressionPrinter) { + builder.append("NESTED"); + if (pathKeyword) { + builder.append(" PATH"); + } + builder.append(" "); + printExpression(builder, pathExpression, expressionPrinter); + if (pathName != null) { + builder.append(" AS ").append(pathName); + } + builder.append(" "); + if (columnsClause == null) { + builder.append("null"); + } else { + columnsClause.appendTo(builder, expressionPrinter); + } + return builder; + } + } + + public static class JsonTableValueColumnDefinition extends JsonTableColumnDefinition { + private String columnName; + private boolean forOrdinality; + private ColDataType dataType; + private String collation; + private boolean formatJson; + private boolean exists; + private boolean onEmptyAfterOnError; + private String encoding; + private Expression pathExpression; + private JsonTableWrapperClause wrapperClause; + private JsonTableQuotesClause quotesClause; + private JsonFunction.JsonOnResponseBehavior onEmptyBehavior; + private JsonFunction.JsonOnResponseBehavior onErrorBehavior; + private JsonFunction.ScalarsType scalarsType; + + public String getColumnName() { + return columnName; + } + + public JsonTableValueColumnDefinition setColumnName(String columnName) { + this.columnName = columnName; + return this; + } + + public boolean isExists() { + return exists; + } + + public JsonTableValueColumnDefinition setExistsKeyword(boolean exists) { + this.exists = exists; + return this; + } + + public JsonTableValueColumnDefinition setOnEmptyAfterOnError(boolean b) { + this.onEmptyAfterOnError = b; + return this; + } + + public boolean isForOrdinality() { + return forOrdinality; + } + + public JsonTableValueColumnDefinition setForOrdinality(boolean forOrdinality) { + this.forOrdinality = forOrdinality; + return this; + } + + public ColDataType getDataType() { + return dataType; + } + + public JsonTableValueColumnDefinition setDataType(ColDataType dataType) { + this.dataType = dataType; + return this; + } + + /** Returns the column collation, including any identifier quoting, or null if absent. */ + public String getCollation() { + return collation; + } + + public JsonTableValueColumnDefinition setCollation(String collation) { + this.collation = collation; + return this; + } + + public boolean isFormatJson() { + return formatJson; + } + + public JsonTableValueColumnDefinition setFormatJson(boolean formatJson) { + this.formatJson = formatJson; + return this; + } + + public String getEncoding() { + return encoding; + } + + public JsonTableValueColumnDefinition setEncoding(String encoding) { + this.encoding = encoding; + return this; + } + + public Expression getPathExpression() { + return pathExpression; + } + + public JsonTableValueColumnDefinition setPathExpression(Expression pathExpression) { + this.pathExpression = pathExpression; + return this; + } + + public JsonTableWrapperClause getWrapperClause() { + return wrapperClause; + } + + public JsonTableValueColumnDefinition setWrapperClause( + JsonTableWrapperClause wrapperClause) { + this.wrapperClause = wrapperClause; + return this; + } + + public JsonTableQuotesClause getQuotesClause() { + return quotesClause; + } + + public JsonTableValueColumnDefinition setQuotesClause(JsonTableQuotesClause quotesClause) { + this.quotesClause = quotesClause; + return this; + } + + public JsonFunction.JsonOnResponseBehavior getOnEmptyBehavior() { + return onEmptyBehavior; + } + + public JsonTableValueColumnDefinition setOnEmptyBehavior( + JsonFunction.JsonOnResponseBehavior onEmptyBehavior) { + this.onEmptyBehavior = onEmptyBehavior; + return this; + } + + public JsonFunction.JsonOnResponseBehavior getOnErrorBehavior() { + return onErrorBehavior; + } + + public JsonTableValueColumnDefinition setOnErrorBehavior( + JsonFunction.JsonOnResponseBehavior onErrorBehavior) { + this.onErrorBehavior = onErrorBehavior; + return this; + } + + public void setScalarsType(JsonFunction.ScalarsType scalarsType) { + this.scalarsType = scalarsType; + } + + public JsonFunction.ScalarsType getScalarsType() { + return scalarsType; + } + + @Override + public void collectExpressions(List expressions) { + if (pathExpression != null) { + expressions.add(pathExpression); + } + if (onEmptyBehavior != null && onEmptyBehavior.getExpression() != null) { + expressions.add(onEmptyBehavior.getExpression()); + } + if (onErrorBehavior != null && onErrorBehavior.getExpression() != null) { + expressions.add(onErrorBehavior.getExpression()); + } + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, builder::append).toString(); + } + + public StringBuilder appendTo(StringBuilder builder, + Consumer expressionPrinter) { + builder.append(columnName); + if (forOrdinality) { + builder.append(" FOR ORDINALITY"); + return builder; + } + appendTypeOptions(builder); + appendPathOptions(builder, expressionPrinter); + if (onEmptyBehavior != null && !onEmptyAfterOnError) { + builder.append(" "); + onEmptyBehavior.appendTo(builder, expressionPrinter); + builder.append(" ON EMPTY"); + } + if (onErrorBehavior != null) { + builder.append(" "); + onErrorBehavior.appendTo(builder, expressionPrinter); + builder.append(" ON ERROR"); + } + if (onEmptyBehavior != null && onEmptyAfterOnError) { + builder.append(" "); + onEmptyBehavior.appendTo(builder, expressionPrinter); + builder.append(" ON EMPTY"); + } + return builder; + } + + private void appendTypeOptions(StringBuilder builder) { + if (dataType != null) { + builder.append(" ").append(dataType); + } + if (collation != null) { + builder.append(" COLLATE ").append(collation); + } + if (formatJson) { + builder.append(" FORMAT JSON"); + if (encoding != null) { + builder.append(" ENCODING ").append(encoding); + } + } + if (scalarsType != null) { + builder.append(" "); + builder.append(scalarsType); + builder.append(" SCALARS"); + } + if (exists) { + builder.append(" EXISTS"); + } + } + + private void appendPathOptions(StringBuilder builder, + Consumer expressionPrinter) { + if (wrapperClause != null && wrapperClause.isBeforePathExpression()) { + builder.append(" ").append(wrapperClause); + } + if (pathExpression != null) { + builder.append(" PATH "); + expressionPrinter.accept(pathExpression); + } + if (wrapperClause != null && !wrapperClause.isBeforePathExpression()) { + builder.append(" ").append(wrapperClause); + } + if (quotesClause != null) { + builder.append(" ").append(quotesClause); + } + } + } + + public static class JsonTableColumnsClause extends ASTNodeAccessImpl implements Serializable { + private final List columnDefinitions = new ArrayList<>(); + + public List getColumnDefinitions() { + return columnDefinitions; + } + + public JsonTableColumnsClause addColumnDefinition( + JsonTableColumnDefinition columnDefinition) { + columnDefinitions.add(columnDefinition); + return this; + } + + public void collectExpressions(List expressions) { + for (JsonTableColumnDefinition columnDefinition : columnDefinitions) { + if (columnDefinition != null) { + columnDefinition.collectExpressions(expressions); + } + } + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, builder::append).toString(); + } + + public StringBuilder appendTo(StringBuilder builder, + Consumer expressionPrinter) { + builder.append("COLUMNS ("); + boolean first = true; + for (JsonTableColumnDefinition columnDefinition : columnDefinitions) { + if (!first) { + builder.append(", "); + } + if (columnDefinition == null) { + builder.append("null"); + } else { + columnDefinition.appendTo(builder, expressionPrinter); + } + first = false; + } + builder.append(")"); + return builder; + } + } + + public JsonTableFunction() { + setName("JSON_TABLE"); + } + + public boolean getFormatJson() { + return formatJson; + } + + public JsonTableFunction setFormatJson(boolean formatJson) { + this.formatJson = formatJson; + return this; + } + + public Expression getJsonInputExpression() { + return jsonInputExpression; + } + + public JsonTableFunction setJsonInputExpression(Expression jsonInputExpression) { + this.jsonInputExpression = jsonInputExpression; + return this; + } + + public Expression getJsonPathExpression() { + return jsonPathExpression; + } + + public JsonTableFunction setJsonPathExpression(Expression jsonPathExpression) { + this.jsonPathExpression = jsonPathExpression; + return this; + } + + public String getPathName() { + return pathName; + } + + public JsonTableFunction setPathName(String pathName) { + this.pathName = pathName; + return this; + } + + public List getPassingClauses() { + return passingClauses; + } + + public JsonTableFunction addPassingClause(JsonTablePassingClause passingClause) { + passingClauses.add(Objects.requireNonNull(passingClause, "passingClause")); + return this; + } + + public JsonTableColumnsClause getColumnsClause() { + return columnsClause; + } + + public JsonTableFunction setColumnsClause(JsonTableColumnsClause columnsClause) { + this.columnsClause = columnsClause; + return this; + } + + public JsonTablePlanClause getPlanClause() { + return planClause; + } + + public JsonTableFunction setPlanClause(JsonTablePlanClause planClause) { + this.planClause = planClause; + return this; + } + + public JsonTableOnErrorClause getOnErrorClause() { + return onErrorClause; + } + + public JsonTableFunction setOnErrorClause(JsonTableOnErrorClause onErrorClause) { + this.onErrorClause = onErrorClause; + return this; + } + + public JsonTableParsingTypeClause getParsingTypeClause() { + return parsingTypeClause; + } + + public JsonTableFunction setParsingTypeClause(JsonTableParsingTypeClause parsingTypeClause) { + this.parsingTypeClause = parsingTypeClause; + return this; + } + + public JsonTableOnEmptyClause getOnEmptyClause() { + return onEmptyClause; + } + + public JsonTableFunction setOnEmptyClause(JsonTableOnEmptyClause onEmptyClause) { + this.onEmptyClause = onEmptyClause; + return this; + } + + public List getAllExpressions() { + List expressions = new ArrayList<>(); + if (jsonInputExpression != null) { + expressions.add(jsonInputExpression); + } + if (jsonPathExpression != null) { + expressions.add(jsonPathExpression); + } + for (JsonTablePassingClause passingClause : passingClauses) { + passingClause.collectExpressions(expressions); + } + if (columnsClause != null) { + columnsClause.collectExpressions(expressions); + } + if (planClause != null) { + planClause.collectExpressions(expressions); + } + return expressions; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, builder::append).toString(); + } + + public StringBuilder appendTo(StringBuilder builder, Consumer expressionPrinter) { + builder.append("JSON_TABLE("); + appendInputAndPath(builder, expressionPrinter); + appendPassingClauses(builder, expressionPrinter); + if (onErrorClause != null && onErrorClause.isBeforeColumns()) { + builder.append(" ").append(onErrorClause); + } + if (parsingTypeClause != null) { + builder.append(" ").append(parsingTypeClause); + } + if (onEmptyClause != null) { + builder.append(" ").append(onEmptyClause); + } + builder.append(" "); + if (columnsClause == null) { + builder.append("null"); + } else { + columnsClause.appendTo(builder, expressionPrinter); + } + if (planClause != null) { + builder.append(" "); + planClause.appendTo(builder, expressionPrinter); + } + if (onErrorClause != null && !onErrorClause.isBeforeColumns()) { + builder.append(" ").append(onErrorClause); + } + builder.append(")"); + return builder; + } + + private void appendInputAndPath(StringBuilder builder, + Consumer expressionPrinter) { + printExpression(builder, jsonInputExpression, expressionPrinter); + if (formatJson) { + builder.append(" FORMAT JSON"); + } + if (jsonPathExpression != null) { + builder.append(", "); + expressionPrinter.accept(jsonPathExpression); + } + if (pathName != null) { + builder.append(" AS ").append(pathName); + } + } + + private void appendPassingClauses(StringBuilder builder, + Consumer expressionPrinter) { + if (!passingClauses.isEmpty()) { + builder.append(" PASSING "); + boolean first = true; + for (JsonTablePassingClause passingClause : passingClauses) { + if (!first) { + builder.append(", "); + } + if (passingClause == null) { + builder.append("null"); + } else { + passingClause.appendTo(builder, expressionPrinter); + } + first = false; + } + } + } + + private static void printExpression(StringBuilder builder, Expression expression, + Consumer expressionPrinter) { + if (expression == null) { + builder.append("null"); + } else { + expressionPrinter.accept(expression); + } + } + +} diff --git a/src/main/java/net/sf/jsqlparser/expression/KeepExpression.java b/src/main/java/net/sf/jsqlparser/expression/KeepExpression.java new file mode 100644 index 0000000000..b8e4932442 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/KeepExpression.java @@ -0,0 +1,110 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.select.OrderByElement; + +public class KeepExpression extends ASTNodeAccessImpl implements Expression { + + private String name; + private List orderByElements; + private boolean first = false; + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public List getOrderByElements() { + return orderByElements; + } + + public void setOrderByElements(List orderByElements) { + this.orderByElements = orderByElements; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean isFirst() { + return first; + } + + public void setFirst(boolean first) { + this.first = first; + } + + @Override + public String toString() { + StringBuilder b = new StringBuilder(); + + b.append("KEEP (").append(name); + + b.append(" ").append(first ? "FIRST" : "LAST").append(" "); + toStringOrderByElements(b); + + b.append(")"); + + return b.toString(); + } + + private void toStringOrderByElements(StringBuilder b) { + if (orderByElements != null && !orderByElements.isEmpty()) { + b.append("ORDER BY "); + for (int i = 0; i < orderByElements.size(); i++) { + if (i > 0) { + b.append(", "); + } + b.append(orderByElements.get(i).toString()); + } + } + } + + public KeepExpression withName(String name) { + this.setName(name); + return this; + } + + public KeepExpression withOrderByElements(List orderByElements) { + this.setOrderByElements(orderByElements); + return this; + } + + public KeepExpression withFirst(boolean first) { + this.setFirst(first); + return this; + } + + public KeepExpression addOrderByElements(OrderByElement... orderByElements) { + List collection = + Optional.ofNullable(getOrderByElements()).orElseGet(ArrayList::new); + Collections.addAll(collection, orderByElements); + return this.withOrderByElements(collection); + } + + public KeepExpression addOrderByElements(Collection orderByElements) { + List collection = + Optional.ofNullable(getOrderByElements()).orElseGet(ArrayList::new); + collection.addAll(orderByElements); + return this.withOrderByElements(collection); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/KeyExpression.java b/src/main/java/net/sf/jsqlparser/expression/KeyExpression.java new file mode 100644 index 0000000000..2bb0638751 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/KeyExpression.java @@ -0,0 +1,44 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.Objects; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** + * Dialect specific expression for constructs such as {@code KEY chain.entity}. + */ +public class KeyExpression extends ASTNodeAccessImpl implements Expression { + private final Expression expression; + + public KeyExpression(Expression expression) { + this.expression = Objects.requireNonNull(expression, + "The EXPRESSION of the KEY expression must not be null"); + } + + public Expression getExpression() { + return expression; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public StringBuilder appendTo(StringBuilder builder) { + builder.append("KEY ").append(expression); + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/LambdaExpression.java b/src/main/java/net/sf/jsqlparser/expression/LambdaExpression.java new file mode 100644 index 0000000000..2b992173f2 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/LambdaExpression.java @@ -0,0 +1,119 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2024 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.expression.operators.relational.ParenthesedExpressionList; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.function.Consumer; + +public class LambdaExpression extends ASTNodeAccessImpl implements Expression { + private List identifiers; + private Expression expression; + private boolean parenthesized; + private boolean lambdaKeyword; + + public LambdaExpression(String identifier, Expression expression) { + this.identifiers = Collections.singletonList(identifier); + this.expression = expression; + } + + public LambdaExpression(List identifiers, Expression expression) { + this.identifiers = identifiers; + this.expression = expression; + } + + public static LambdaExpression from(ExpressionList expressionList, + Expression expression) { + List identifiers = new ArrayList<>(expressionList.size()); + for (Expression variable : expressionList) { + identifiers.add(variable.toString()); + } + return new LambdaExpression(identifiers, expression) + .setParenthesized(expressionList instanceof ParenthesedExpressionList); + } + + /** Whether the parameter list was explicitly parenthesized, including a single parameter. */ + public boolean isParenthesized() { + return parenthesized; + } + + public LambdaExpression setParenthesized(boolean parenthesized) { + this.parenthesized = parenthesized; + return this; + } + + /** Whether it was written with DuckDB's lambda keyword: {@code lambda x, y : expr}. */ + public boolean isLambdaKeyword() { + return lambdaKeyword; + } + + public LambdaExpression setLambdaKeyword(boolean lambdaKeyword) { + this.lambdaKeyword = lambdaKeyword; + return this; + } + + public List getIdentifiers() { + return identifiers; + } + + public LambdaExpression setIdentifiers(List identifiers) { + this.identifiers = identifiers; + return this; + } + + public Expression getExpression() { + return expression; + } + + public LambdaExpression setExpression(Expression expression) { + this.expression = expression; + return this; + } + + public StringBuilder appendTo(StringBuilder builder) { + return appendTo(builder, builder::append); + } + + public StringBuilder appendTo(StringBuilder builder, Consumer expressionPrinter) { + if (lambdaKeyword) { + builder.append("lambda ").append(String.join(", ", identifiers)).append(" : "); + expressionPrinter.accept(expression); + return builder; + } + if (identifiers.size() == 1 && !parenthesized) { + builder.append(identifiers.get(0)); + } else { + int i = 0; + builder.append("( "); + for (String s : identifiers) { + builder.append(i++ > 0 ? ", " : "").append(s); + } + builder.append(" )"); + } + builder.append(" -> "); + expressionPrinter.accept(expression); + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/ListComprehension.java b/src/main/java/net/sf/jsqlparser/expression/ListComprehension.java new file mode 100644 index 0000000000..e65fab8853 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/ListComprehension.java @@ -0,0 +1,98 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +import java.util.List; +import java.util.function.Consumer; + +/** + * DuckDB's list comprehension {@code [expression FOR x[, i] IN list [IF condition]]}, where + * {@code i} is the 1-based index of {@code x}. + * + * @see List + * comprehension + */ +public class ListComprehension extends ASTNodeAccessImpl implements Expression { + private Expression expression; + private List variables; + private Expression list; + private Expression condition; + + public ListComprehension(Expression expression, List variables, Expression list, + Expression condition) { + this.expression = expression; + this.variables = variables; + this.list = list; + this.condition = condition; + } + + public Expression getExpression() { + return expression; + } + + public ListComprehension setExpression(Expression expression) { + this.expression = expression; + return this; + } + + /** The element variable, followed by the index variable if any. */ + public List getVariables() { + return variables; + } + + public ListComprehension setVariables(List variables) { + this.variables = variables; + return this; + } + + public Expression getList() { + return list; + } + + public ListComprehension setList(Expression list) { + this.list = list; + return this; + } + + /** The {@code IF} filter, or {@code null}. */ + public Expression getCondition() { + return condition; + } + + public ListComprehension setCondition(Expression condition) { + this.condition = condition; + return this; + } + + public StringBuilder appendTo(StringBuilder builder, Consumer expressionRenderer) { + builder.append("["); + expressionRenderer.accept(expression); + builder.append(" FOR ").append(String.join(", ", variables)).append(" IN "); + expressionRenderer.accept(list); + if (condition != null) { + builder.append(" IF "); + expressionRenderer.accept(condition); + } + return builder.append("]"); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, builder::append).toString(); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/LongValue.java b/src/main/java/net/sf/jsqlparser/expression/LongValue.java index c201ae7750..eeba186cc9 100644 --- a/src/main/java/net/sf/jsqlparser/expression/LongValue.java +++ b/src/main/java/net/sf/jsqlparser/expression/LongValue.java @@ -1,71 +1,99 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import java.math.BigInteger; +import java.util.Objects; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + /** - * Every number without a point or an exponential format is a LongValue + * Every number without a point or an exponential format is a LongValue. */ -public class LongValue implements Expression { +public class LongValue extends ASTNodeAccessImpl implements Expression { - private long value; - private String stringValue; + private String stringValue; - public LongValue(final String value) { - String val = value; - if (val.charAt(0) == '+') { - val = val.substring(1); - } - this.value = Long.parseLong(val); + public LongValue() { + // empty constructor + } + + public LongValue(final String value) { + if (value == null || value.length() == 0) { + throw new IllegalArgumentException("value can neither be null nor empty."); + } + String val = value; + if (val.charAt(0) == '+') { + val = val.substring(1); + } this.stringValue = val; - } - - public LongValue(long value) { - this.value=value; - stringValue = String.valueOf(value); - } - - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } - - public long getValue() { - return value; - } - - public void setValue(long d) { - value = d; - } - - public String getStringValue() { - return stringValue; - } - - public void setStringValue(String string) { - stringValue = string; - } - - @Override - public String toString() { - return getStringValue(); - } + } + + public LongValue(long value) { + stringValue = String.valueOf(value); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public long getValue() { + return Long.parseLong(stringValue); + } + + public void setValue(long d) { + stringValue = String.valueOf(d); + } + + public BigInteger getBigIntegerValue() { + return new BigInteger(stringValue); + } + + public LongValue withValue(long d) { + setValue(d); + return this; + } + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(String string) { + stringValue = string; + } + + @Override + public String toString() { + return getStringValue(); + } + + public LongValue withStringValue(String stringValue) { + this.setStringValue(stringValue); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LongValue longValue = (LongValue) o; + return stringValue.equals(longValue.stringValue); + } + + @Override + public int hashCode() { + return Objects.hash(stringValue); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/LowExpression.java b/src/main/java/net/sf/jsqlparser/expression/LowExpression.java new file mode 100644 index 0000000000..2d2882a53a --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/LowExpression.java @@ -0,0 +1,42 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class LowExpression extends ASTNodeAccessImpl implements Expression { + private Expression expression; + + public LowExpression() { + // empty constructor + } + + public LowExpression(Expression expression) { + this.expression = expression; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + @Override + public String toString() { + return "LOW " + expression.toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/MapExpression.java b/src/main/java/net/sf/jsqlparser/expression/MapExpression.java new file mode 100644 index 0000000000..1e64a7db84 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/MapExpression.java @@ -0,0 +1,79 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** + * DuckDB's {@code MAP {key: value, ...}} literal expression. + * + * @see DuckDB MAP type + */ +public class MapExpression extends ASTNodeAccessImpl implements Expression { + + private List> entries = new ArrayList<>(); + + public MapExpression() {} + + public MapExpression(Collection> entries) { + this.entries.addAll(entries); + } + + public List> getEntries() { + return entries; + } + + public void setEntries(List> entries) { + this.entries = entries; + } + + public MapExpression withEntries(List> entries) { + setEntries(entries); + return this; + } + + public MapExpression addEntries( + Collection> entries) { + this.entries.addAll(entries); + return this; + } + + public MapExpression addEntry(Expression key, Expression value) { + entries.add(new AbstractMap.SimpleEntry<>(key, value)); + return this; + } + + public StringBuilder appendTo(StringBuilder builder) { + builder.append("MAP {"); + for (int i = 0; i < entries.size(); i++) { + if (i > 0) { + builder.append(", "); + } + Map.Entry entry = entries.get(i); + builder.append(entry.getKey()).append(": ").append(entry.getValue()); + } + return builder.append("}"); + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/MethodCallExpression.java b/src/main/java/net/sf/jsqlparser/expression/MethodCallExpression.java new file mode 100644 index 0000000000..30fb798891 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/MethodCallExpression.java @@ -0,0 +1,58 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.function.Consumer; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** A method applied to an expression, such as a SQL Server XML subquery result. */ +public class MethodCallExpression extends ASTNodeAccessImpl implements Expression { + private Expression expression; + private Function method; + + public MethodCallExpression(Expression expression, Function method) { + this.expression = expression; + this.method = method; + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + public Function getMethod() { + return method; + } + + public void setMethod(Function method) { + this.method = method; + } + + public StringBuilder appendTo(StringBuilder builder, Consumer printer) { + printer.accept(expression); + builder.append('.'); + printer.accept(method); + return builder; + } + + @Override + public T accept(ExpressionVisitor visitor, S context) { + return visitor.visit(this, context); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, value -> builder.append(value)).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/MySQLGroupConcat.java b/src/main/java/net/sf/jsqlparser/expression/MySQLGroupConcat.java new file mode 100644 index 0000000000..aa4a53357b --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/MySQLGroupConcat.java @@ -0,0 +1,124 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.select.OrderByElement; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +public class MySQLGroupConcat extends ASTNodeAccessImpl implements Expression { + + private ExpressionList expressionList; + private boolean distinct = false; + private List orderByElements; + private String separator; + + public ExpressionList getExpressionList() { + return expressionList; + } + + public void setExpressionList(ExpressionList expressionList) { + this.expressionList = expressionList; + } + + public boolean isDistinct() { + return distinct; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public List getOrderByElements() { + return orderByElements; + } + + public void setOrderByElements(List orderByElements) { + this.orderByElements = orderByElements; + } + + public String getSeparator() { + return separator; + } + + public void setSeparator(String separator) { + this.separator = separator; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + StringBuilder b = new StringBuilder(); + b.append("GROUP_CONCAT("); + if (isDistinct()) { + b.append("DISTINCT "); + } + b.append(expressionList); + if (orderByElements != null && !orderByElements.isEmpty()) { + b.append(" ORDER BY "); + for (int i = 0; i < orderByElements.size(); i++) { + if (i > 0) { + b.append(", "); + } + b.append(orderByElements.get(i).toString()); + } + } + if (separator != null) { + b.append(" SEPARATOR ").append(separator); + } + b.append(")"); + return b.toString(); + } + + public MySQLGroupConcat withExpressionList(ExpressionList expressionList) { + this.setExpressionList(expressionList); + return this; + } + + public MySQLGroupConcat withDistinct(boolean distinct) { + this.setDistinct(distinct); + return this; + } + + public MySQLGroupConcat withOrderByElements(List orderByElements) { + this.setOrderByElements(orderByElements); + return this; + } + + public MySQLGroupConcat withSeparator(String separator) { + this.setSeparator(separator); + return this; + } + + public MySQLGroupConcat addOrderByElements(OrderByElement... orderByElements) { + List collection = + Optional.ofNullable(getOrderByElements()).orElseGet(ArrayList::new); + Collections.addAll(collection, orderByElements); + return this.withOrderByElements(collection); + } + + public MySQLGroupConcat addOrderByElements( + Collection orderByElements) { + List collection = + Optional.ofNullable(getOrderByElements()).orElseGet(ArrayList::new); + collection.addAll(orderByElements); + return this.withOrderByElements(collection); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/MySQLIndexHint.java b/src/main/java/net/sf/jsqlparser/expression/MySQLIndexHint.java new file mode 100644 index 0000000000..17044a9fb3 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/MySQLIndexHint.java @@ -0,0 +1,104 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.io.Serializable; +import java.util.List; + +/** + * A MySQL index hint after a table reference: + * {@code {USE|IGNORE|FORCE} {INDEX|KEY} [FOR {JOIN|ORDER BY|GROUP BY}] (index_list)}. + *

+ * A table may carry several hints, see {@code Table.getIndexHints()}. {@code USE INDEX ()} has an + * empty index list. + */ +public class MySQLIndexHint implements Serializable { + + private final String action; + private final String indexQualifier; + private final Scope scope; + private final List indexNames; + + public MySQLIndexHint(String action, String indexQualifier, List indexNames) { + this(action, indexQualifier, null, indexNames); + } + + /** + * @param action {@code USE}, {@code IGNORE} or {@code FORCE} + * @param indexQualifier {@code INDEX} or {@code KEY} + * @param scope the {@code FOR JOIN|ORDER BY|GROUP BY} scope, or {@code null} for every use + * @param indexNames the index names, empty for {@code USE INDEX ()} + */ + public MySQLIndexHint(String action, String indexQualifier, Scope scope, + List indexNames) { + this.action = action; + this.indexQualifier = indexQualifier; + this.scope = scope; + this.indexNames = indexNames; + } + + public String getAction() { + return action; + } + + public String getIndexQualifier() { + return indexQualifier; + } + + /** + * Returns the part of the query the hint applies to, or {@code null} when no {@code FOR} clause + * was given. + */ + public Scope getScope() { + return scope; + } + + public List getIndexNames() { + return indexNames; + } + + /** Appends {@code " USE INDEX [FOR scope] (i1,i2)"}, with a leading space. */ + public StringBuilder appendTo(StringBuilder builder) { + // use|ignore|force key|index [for join|order by|group by] (index1,...,indexN) + builder.append(" ").append(action).append(" ").append(indexQualifier); + if (scope != null) { + builder.append(" FOR ").append(scope.getKeywords()); + } + builder.append(" ("); + for (int i = 0; i < indexNames.size(); i++) { + if (i > 0) { + builder.append(","); + } + builder.append(indexNames.get(i)); + } + return builder.append(")"); + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } + + /** The {@code FOR} clause of an index hint. */ + public enum Scope { + JOIN("JOIN"), ORDER_BY("ORDER BY"), GROUP_BY("GROUP BY"); + + private final String keywords; + + Scope(String keywords) { + this.keywords = keywords; + } + + /** Returns the keywords after {@code FOR}, for example {@code ORDER BY}. */ + public String getKeywords() { + return keywords; + } + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/NextValExpression.java b/src/main/java/net/sf/jsqlparser/expression/NextValExpression.java new file mode 100644 index 0000000000..a56723851d --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/NextValExpression.java @@ -0,0 +1,71 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2024 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.List; +import java.util.regex.Pattern; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class NextValExpression extends ASTNodeAccessImpl implements Expression { + + public static final Pattern NEXT_VALUE_PATTERN = + Pattern.compile("NEXT\\s+VALUE\\s+FOR", Pattern.CASE_INSENSITIVE); + private final List nameList; + private boolean usingNextValueFor = false; + + public NextValExpression(List nameList, String image) { + this.nameList = nameList; + // Test if we shall use NEXT VALUE FOR instead of NEXTVAL FOR + if (NEXT_VALUE_PATTERN.matcher(image).matches()) { + usingNextValueFor = true; + } + } + + public boolean isUsingNextValueFor() { + return usingNextValueFor; + } + + public void setUsingNextValueFor(boolean usingNextValueFor) { + this.usingNextValueFor = usingNextValueFor; + } + + public NextValExpression withNextValueFor(boolean usingNextValueFor) { + setUsingNextValueFor(usingNextValueFor); + return this; + } + + public List getNameList() { + return nameList; + } + + public String getName() { + StringBuilder b = new StringBuilder(); + for (String name : nameList) { + if (b.length() > 0) { + b.append("."); + } + b.append(name); + } + return b.toString(); + } + + @Override + public String toString() { + return (usingNextValueFor + ? "NEXT VALUE FOR " + : "NEXTVAL FOR ") + getName(); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/NotExpression.java b/src/main/java/net/sf/jsqlparser/expression/NotExpression.java new file mode 100644 index 0000000000..bb2769fdd1 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/NotExpression.java @@ -0,0 +1,75 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** + * It represents a "not " or "!" before an expression. + */ +public class NotExpression extends ASTNodeAccessImpl implements Expression { + + private Expression expression; + + private boolean exclamationMark = false; + + public NotExpression() { + // empty constructor + } + + public NotExpression(Expression expression) { + this(expression, false); + } + + public NotExpression(Expression expression, boolean useExclamationMark) { + setExpression(expression); + this.exclamationMark = useExclamationMark; + } + + public Expression getExpression() { + return expression; + } + + public final void setExpression(Expression expression) { + this.expression = expression; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + return (exclamationMark ? "! " : "NOT ") + expression.toString(); + } + + public boolean isExclamationMark() { + return exclamationMark; + } + + public void setExclamationMark(boolean exclamationMark) { + this.exclamationMark = exclamationMark; + } + + public NotExpression withExpression(Expression expression) { + this.setExpression(expression); + return this; + } + + public NotExpression withExclamationMark(boolean exclamationMark) { + this.setExclamationMark(exclamationMark); + return this; + } + + public E getExpression(Class type) { + return type.cast(getExpression()); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/NullValue.java b/src/main/java/net/sf/jsqlparser/expression/NullValue.java index f9659a3ea7..fb096eff6d 100644 --- a/src/main/java/net/sf/jsqlparser/expression/NullValue.java +++ b/src/main/java/net/sf/jsqlparser/expression/NullValue.java @@ -1,38 +1,25 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; -/** - * A "NULL" in a sql statement - */ -public class NullValue implements Expression { +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class NullValue extends ASTNodeAccessImpl implements Expression { - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } - @Override - public String toString() { - return "NULL"; - } + @Override + public String toString() { + return "NULL"; + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/NumericBind.java b/src/main/java/net/sf/jsqlparser/expression/NumericBind.java new file mode 100644 index 0000000000..f38ff15d4b --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/NumericBind.java @@ -0,0 +1,40 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class NumericBind extends ASTNodeAccessImpl implements Expression { + + private int bindId; + + public int getBindId() { + return bindId; + } + + public void setBindId(int bindId) { + this.bindId = bindId; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + return ":" + bindId; + } + + public NumericBind withBindId(int bindId) { + this.setBindId(bindId); + return this; + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/OracleHierarchicalExpression.java b/src/main/java/net/sf/jsqlparser/expression/OracleHierarchicalExpression.java index 935349ec13..693128d030 100644 --- a/src/main/java/net/sf/jsqlparser/expression/OracleHierarchicalExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/OracleHierarchicalExpression.java @@ -1,76 +1,110 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; -/** - * - * @author toben - */ -public class OracleHierarchicalExpression implements Expression { - - private Expression startExpression; - private Expression connectExpression; - private boolean noCycle = false; - - public Expression getStartExpression() { - return startExpression; - } - - public void setStartExpression(Expression startExpression) { - this.startExpression = startExpression; - } - - public Expression getConnectExpression() { - return connectExpression; - } - - public void setConnectExpression(Expression connectExpression) { - this.connectExpression = connectExpression; - } - - public boolean isNoCycle() { - return noCycle; - } - - public void setNoCycle(boolean noCycle) { - this.noCycle = noCycle; - } - - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } - - @Override - public String toString() { - StringBuilder b = new StringBuilder(); - if (startExpression != null) { - b.append(" START WITH ").append(startExpression.toString()); - } - b.append(" CONNECT BY "); - if (isNoCycle()) { - b.append("NOCYCLE "); - } - b.append(connectExpression.toString()); - return b.toString(); - } +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class OracleHierarchicalExpression extends ASTNodeAccessImpl implements Expression { + + boolean connectFirst = false; + private Expression startExpression; + private Expression connectExpression; + private boolean noCycle = false; + + public Expression getStartExpression() { + return startExpression; + } + + public void setStartExpression(Expression startExpression) { + this.startExpression = startExpression; + } + + public Expression getConnectExpression() { + return connectExpression; + } + + public void setConnectExpression(Expression connectExpression) { + this.connectExpression = connectExpression; + } + + public boolean isNoCycle() { + return noCycle; + } + + public void setNoCycle(boolean noCycle) { + this.noCycle = noCycle; + } + + public boolean isConnectFirst() { + return connectFirst; + } + + public void setConnectFirst(boolean connectFirst) { + this.connectFirst = connectFirst; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + StringBuilder b = new StringBuilder(); + if (isConnectFirst()) { + b.append(" CONNECT BY "); + if (isNoCycle()) { + b.append("NOCYCLE "); + } + b.append(connectExpression.toString()); + if (startExpression != null) { + b.append(" START WITH ").append(startExpression); + } + } else { + if (startExpression != null) { + b.append(" START WITH ").append(startExpression); + } + b.append(" CONNECT BY "); + if (isNoCycle()) { + b.append("NOCYCLE "); + } + b.append(connectExpression.toString()); + } + return b.toString(); + } + + public OracleHierarchicalExpression withStartExpression(Expression startExpression) { + this.setStartExpression(startExpression); + return this; + } + + public OracleHierarchicalExpression withConnectExpression(Expression connectExpression) { + this.setConnectExpression(connectExpression); + return this; + } + + public OracleHierarchicalExpression withNoCycle(boolean noCycle) { + this.setNoCycle(noCycle); + return this; + } + + public OracleHierarchicalExpression withConnectFirst(boolean connectFirst) { + this.setConnectFirst(connectFirst); + return this; + } + + public E getStartExpression(Class type) { + return type.cast(getStartExpression()); + } + + public E getConnectExpression(Class type) { + return type.cast(getConnectExpression()); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/OracleHint.java b/src/main/java/net/sf/jsqlparser/expression/OracleHint.java new file mode 100644 index 0000000000..166e19e08d --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/OracleHint.java @@ -0,0 +1,101 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.select.ParenthesedSelect; +import net.sf.jsqlparser.statement.select.PlainSelect; +import net.sf.jsqlparser.statement.select.Select; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Oracle Hint Expression + */ +public class OracleHint extends ASTNodeAccessImpl implements Expression { + + private static final Pattern SINGLE_LINE = Pattern.compile("--\\+ *([^ ].*[^ ])"); + private static final Pattern MULTI_LINE = + Pattern.compile("\\A/\\*\\+ *([^ ].*[^ ]) *\\*+/", Pattern.MULTILINE | Pattern.DOTALL); + + private String value; + private boolean singleLine = false; + + public static boolean isHintMatch(String comment) { + return SINGLE_LINE.matcher(comment).find() || MULTI_LINE.matcher(comment).find(); + } + + public static OracleHint getHintFromSelectBody(Select selectBody) { + + if (selectBody instanceof PlainSelect) { + return ((PlainSelect) selectBody).getOracleHint(); + } else if (selectBody instanceof ParenthesedSelect) { + return getHintFromSelectBody(((ParenthesedSelect) selectBody).getSelect()); + } else { + return null; + } + } + + public final void setComment(String comment) { + Matcher m; + m = SINGLE_LINE.matcher(comment); + if (m.find()) { + this.value = m.group(1); + this.singleLine = true; + return; + } + m = MULTI_LINE.matcher(comment); + if (m.find()) { + this.value = m.group(1); + this.singleLine = false; + } + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public boolean isSingleLine() { + return singleLine; + } + + public void setSingleLine(boolean singleLine) { + this.singleLine = singleLine; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + if (singleLine) { + return "--+ " + value + "\n"; + } else { + return "/*+ " + value + " */"; + } + } + + public OracleHint withValue(String value) { + this.setValue(value); + return this; + } + + public OracleHint withSingleLine(boolean singleLine) { + this.setSingleLine(singleLine); + return this; + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/OracleNamedFunctionParameter.java b/src/main/java/net/sf/jsqlparser/expression/OracleNamedFunctionParameter.java new file mode 100644 index 0000000000..0dd76b5f69 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/OracleNamedFunctionParameter.java @@ -0,0 +1,55 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2021 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.Objects; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** + * @author Andreas Reichel + */ +public class OracleNamedFunctionParameter extends ASTNodeAccessImpl implements Expression { + private final String name; + private final Expression expression; + + public OracleNamedFunctionParameter(String name, Expression expression) { + this.name = Objects.requireNonNull(name, + "The NAME of the OracleNamedFunctionParameter must not be null."); + this.expression = Objects.requireNonNull(expression, + "The EXPRESSION of the OracleNamedFunctionParameter must not be null."); + } + + public String getName() { + return name; + } + + public Expression getExpression() { + return expression; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public StringBuilder appendTo(StringBuilder builder) { + builder.append(name) + .append(" => ") + .append(expression); + + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/OrderByClause.java b/src/main/java/net/sf/jsqlparser/expression/OrderByClause.java new file mode 100644 index 0000000000..fbf21de87e --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/OrderByClause.java @@ -0,0 +1,62 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import net.sf.jsqlparser.statement.select.OrderByElement; + +public class OrderByClause implements Serializable { + private List orderByElements; + + public List getOrderByElements() { + return orderByElements; + } + + public void setOrderByElements(List orderByElements) { + this.orderByElements = orderByElements; + } + + public void toStringOrderByElements(StringBuilder b) { + if (orderByElements != null && !orderByElements.isEmpty()) { + b.append("ORDER BY "); + for (int i = 0; i < orderByElements.size(); i++) { + if (i > 0) { + b.append(", "); + } + b.append(orderByElements.get(i).toString()); + } + } + } + + public OrderByClause withOrderByElements(List orderByElements) { + this.setOrderByElements(orderByElements); + return this; + } + + public OrderByClause addOrderByElements(OrderByElement... orderByElements) { + List collection = + Optional.ofNullable(getOrderByElements()).orElseGet(ArrayList::new); + Collections.addAll(collection, orderByElements); + return this.withOrderByElements(collection); + } + + public OrderByClause addOrderByElements(Collection orderByElements) { + List collection = + Optional.ofNullable(getOrderByElements()).orElseGet(ArrayList::new); + collection.addAll(orderByElements); + return this.withOrderByElements(collection); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/OverlapsCondition.java b/src/main/java/net/sf/jsqlparser/expression/OverlapsCondition.java new file mode 100644 index 0000000000..09ccd61837 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/OverlapsCondition.java @@ -0,0 +1,41 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2022 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class OverlapsCondition extends ASTNodeAccessImpl implements Expression { + private final ExpressionList left; + private final ExpressionList right; + + public OverlapsCondition(ExpressionList left, ExpressionList right) { + this.left = left; + this.right = right; + } + + public ExpressionList getLeft() { + return left; + } + + public ExpressionList getRight() { + return right; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + return String.format("%s OVERLAPS %s", left.toString(), right.toString()); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/Parenthesis.java b/src/main/java/net/sf/jsqlparser/expression/Parenthesis.java index 673a0a2d09..c162cd1efb 100644 --- a/src/main/java/net/sf/jsqlparser/expression/Parenthesis.java +++ b/src/main/java/net/sf/jsqlparser/expression/Parenthesis.java @@ -1,64 +1,37 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import net.sf.jsqlparser.expression.operators.relational.ParenthesedExpressionList; + /** - * It represents an expression like "(" expression ")" + * @deprecated This class is deprecated since version 5.0. Use {@link ParenthesedExpressionList} + * instead. The reason for deprecation is the ambiguity and redundancy. */ -public class Parenthesis implements Expression { - - private Expression expression; - private boolean not = false; - - public Parenthesis() { - } - - public Parenthesis(Expression expression) { - setExpression(expression); - } - - public Expression getExpression() { - return expression; - } - - public final void setExpression(Expression expression) { - this.expression = expression; - } +@Deprecated(since = "5.0", forRemoval = true) +public class Parenthesis extends ParenthesedExpressionList { + public Expression getExpression() { + return isEmpty() ? null : get(0); + } - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public Parenthesis setExpression(Expression expression) { + this.set(0, expression); + return this; + } - public void setNot() { - not = true; - } + public Parenthesis withExpression(Expression expression) { + return this.setExpression(expression); + } - public boolean isNot() { - return not; - } + public E getExpression(Class type) { + return type.cast(getExpression()); + } - @Override - public String toString() { - return (not ? "NOT " : "") + "(" + expression + ")"; - } } diff --git a/src/main/java/net/sf/jsqlparser/expression/PartitionByClause.java b/src/main/java/net/sf/jsqlparser/expression/PartitionByClause.java new file mode 100644 index 0000000000..6ad41e994d --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/PartitionByClause.java @@ -0,0 +1,65 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.statement.select.PlainSelect; + +import java.io.Serializable; + +public class PartitionByClause extends ExpressionList implements Serializable { + boolean brackets = false; + + @Deprecated + public ExpressionList getPartitionExpressionList() { + return this; + } + + @Deprecated + public void setPartitionExpressionList(ExpressionList partitionExpressionList) { + setPartitionExpressionList(partitionExpressionList, false); + } + + @Deprecated + public void setPartitionExpressionList(ExpressionList partitionExpressionList, + boolean brackets) { + setExpressions(partitionExpressionList, brackets); + } + + public PartitionByClause setExpressions(ExpressionList partitionExpressionList, + boolean brackets) { + clear(); + if (partitionExpressionList != null) { + addAll(partitionExpressionList); + } + this.brackets = brackets; + return this; + } + + public void toStringPartitionBy(StringBuilder b) { + if (!isEmpty()) { + b.append("PARTITION BY "); + b.append(PlainSelect.getStringList(this, true, + brackets)); + b.append(" "); + } + } + + public boolean isBrackets() { + return brackets; + } + + @Deprecated + public PartitionByClause withPartitionExpressionList( + ExpressionList partitionExpressionList) { + this.setPartitionExpressionList(partitionExpressionList); + return this; + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/PostgresNamedFunctionParameter.java b/src/main/java/net/sf/jsqlparser/expression/PostgresNamedFunctionParameter.java new file mode 100644 index 0000000000..573ad60f21 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/PostgresNamedFunctionParameter.java @@ -0,0 +1,55 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2021 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +import java.util.Objects; + +/** + * @author Andreas Reichel + */ +public class PostgresNamedFunctionParameter extends ASTNodeAccessImpl implements Expression { + private final String name; + private final Expression expression; + + public PostgresNamedFunctionParameter(String name, Expression expression) { + this.name = Objects.requireNonNull(name, + "The NAME of the PostgresNamedFunctionParameter must not be null."); + this.expression = Objects.requireNonNull(expression, + "The EXPRESSION of the PostgresNamedFunctionParameter must not be null."); + } + + public String getName() { + return name; + } + + public Expression getExpression() { + return expression; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public StringBuilder appendTo(StringBuilder builder) { + builder.append(name) + .append(" := ") + .append(expression); + + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/PreferringClause.java b/src/main/java/net/sf/jsqlparser/expression/PreferringClause.java new file mode 100644 index 0000000000..2db468dbbf --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/PreferringClause.java @@ -0,0 +1,66 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; + +import java.io.Serializable; + +public class PreferringClause implements Serializable { + private Expression preferring; + private PartitionByClause partitionBy; + + public PreferringClause(Expression preferring) { + this.preferring = preferring; + } + + public void setPartitionExpressionList(ExpressionList expressionList, + boolean brackets) { + if (this.partitionBy == null) { + this.partitionBy = new PartitionByClause(); + } + partitionBy.setExpressions(expressionList, brackets); + } + + public void toStringPreferring(StringBuilder b) { + b.append("PREFERRING "); + b.append(preferring.toString()); + + if (partitionBy != null) { + b.append(" "); + partitionBy.toStringPartitionBy(b); + } + } + + public Expression getPreferring() { + return preferring; + } + + public PreferringClause setPreferring(Expression preferring) { + this.preferring = preferring; + return this; + } + + public PartitionByClause getPartitionBy() { + return partitionBy; + } + + public PreferringClause setPartitionBy(PartitionByClause partitionBy) { + this.partitionBy = partitionBy; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + toStringPreferring(sb); + return sb.toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/RangeExpression.java b/src/main/java/net/sf/jsqlparser/expression/RangeExpression.java new file mode 100644 index 0000000000..326f5b7da5 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/RangeExpression.java @@ -0,0 +1,84 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2023 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class RangeExpression extends ASTNodeAccessImpl implements Expression { + private Expression startExpression; + private Expression endExpression; + private Expression stepExpression; + + public RangeExpression(Expression startExpression, Expression endExpression) { + this.startExpression = startExpression; + this.endExpression = endExpression; + } + + public Expression getStartExpression() { + return startExpression; + } + + public RangeExpression setStartExpression(Expression startExpression) { + this.startExpression = startExpression; + return this; + } + + public Expression getEndExpression() { + return endExpression; + } + + public RangeExpression setEndExpression(Expression endExpression) { + this.endExpression = endExpression; + return this; + } + + public Expression getStepExpression() { + return stepExpression; + } + + public RangeExpression setStepExpression(Expression stepExpression) { + this.stepExpression = stepExpression; + return this; + } + + public RangeExpression withStepExpression(Expression stepExpression) { + return setStepExpression(stepExpression); + } + + /** + * Renders {@code [start]:[end][:step]}, a missing end before a step as DuckDB's {@code -}. + */ + public static String toString(Expression start, Expression end, Expression step) { + StringBuilder builder = new StringBuilder(); + if (start != null) { + builder.append(start); + } + builder.append(":"); + if (end != null) { + builder.append(end); + } else if (step != null) { + builder.append("-"); + } + if (step != null) { + builder.append(":").append(step); + } + return builder.toString(); + } + + @Override + public String toString() { + return toString(startExpression, endExpression, stepExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/RawFunction.java b/src/main/java/net/sf/jsqlparser/expression/RawFunction.java new file mode 100644 index 0000000000..1c2d5b874a --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/RawFunction.java @@ -0,0 +1,41 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +/** + * Function with a raw argument body preserved as-is for deparsing. + */ +public class RawFunction extends Function { + private String rawArguments; + + public RawFunction() {} + + public RawFunction(String name, String rawArguments) { + setName(name); + this.rawArguments = rawArguments; + } + + public String getRawArguments() { + return rawArguments; + } + + public void setRawArguments(String rawArguments) { + this.rawArguments = rawArguments; + } + + @Override + public String toString() { + String name = getName(); + if (rawArguments == null) { + return name + "()"; + } + return name + "(" + rawArguments + ")"; + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/RowConstructor.java b/src/main/java/net/sf/jsqlparser/expression/RowConstructor.java new file mode 100644 index 0000000000..2f5844ea04 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/RowConstructor.java @@ -0,0 +1,48 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.expression.operators.relational.ParenthesedExpressionList; + +public class RowConstructor extends ParenthesedExpressionList + implements Expression { + private String name = null; + + public RowConstructor() {} + + public RowConstructor(String name, ExpressionList expressionList) { + this.name = name; + addAll(expressionList); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return (name != null ? name : "") + super.toString(); + } + + public RowConstructor withName(String name) { + this.setName(name); + return this; + } + + @Override + public K accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/RowGetExpression.java b/src/main/java/net/sf/jsqlparser/expression/RowGetExpression.java new file mode 100644 index 0000000000..0aaefa1aa3 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/RowGetExpression.java @@ -0,0 +1,48 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2021 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public final class RowGetExpression extends ASTNodeAccessImpl implements Expression { + private Expression expression; + private String columnName; + + public RowGetExpression(Expression expression, String columnName) { + this.expression = expression; + this.columnName = columnName; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + return expression + "." + columnName; + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + public String getColumnName() { + return columnName; + } + + public void setColumnName(String columnName) { + this.columnName = columnName; + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/RowPatternFunction.java b/src/main/java/net/sf/jsqlparser/expression/RowPatternFunction.java new file mode 100644 index 0000000000..a6ee2cd986 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/RowPatternFunction.java @@ -0,0 +1,63 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.function.Consumer; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** An explicit RUNNING or FINAL evaluation mode on a row-pattern function. */ +public class RowPatternFunction extends ASTNodeAccessImpl implements Expression { + public enum EvaluationMode { + RUNNING, FINAL + } + + private EvaluationMode evaluationMode; + private Function function; + + public RowPatternFunction(EvaluationMode evaluationMode, Function function) { + this.evaluationMode = evaluationMode; + this.function = function; + } + + public EvaluationMode getEvaluationMode() { + return evaluationMode; + } + + public RowPatternFunction setEvaluationMode(EvaluationMode mode) { + evaluationMode = mode; + return this; + } + + public Function getFunction() { + return function; + } + + public RowPatternFunction setFunction(Function function) { + this.function = function; + return this; + } + + @Override + public T accept(ExpressionVisitor visitor, S context) { + return visitor.visit(this, context); + } + + public StringBuilder appendTo(StringBuilder builder, Consumer expressions) { + builder.append(evaluationMode).append(' '); + expressions.accept(function); + return builder; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, expression -> builder.append(expression)).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/SQLServerHints.java b/src/main/java/net/sf/jsqlparser/expression/SQLServerHints.java new file mode 100644 index 0000000000..1d82304043 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/SQLServerHints.java @@ -0,0 +1,82 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +public class SQLServerHints implements Serializable { + + private Boolean noLock; + private String indexName; + private final List lockHints = new ArrayList<>(); + + /** Additional argument-free locking hints; NOLOCK retains its existing accessors. */ + public enum LockHint { + HOLDLOCK, NOWAIT, PAGLOCK, READCOMMITTED, READCOMMITTEDLOCK, READPAST, READUNCOMMITTED, REPEATABLEREAD, ROWLOCK, SERIALIZABLE, SNAPSHOT, TABLOCK, TABLOCKX, UPDLOCK, XLOCK + } + + /** Returns the mutable list of locking hints, in their original order. */ + public List getLockHints() { + return lockHints; + } + + + public SQLServerHints() {} + + public SQLServerHints withNoLock() { + this.noLock = true; + return this; + } + + public Boolean getNoLock() { + return noLock; + } + + public void setNoLock(Boolean noLock) { + this.noLock = noLock; + } + + public String getIndexName() { + return indexName; + } + + public void setIndexName(String indexName) { + this.indexName = indexName; + } + + @Override + public String toString() { + List hints = new ArrayList<>(); + if (indexName != null) { + hints.add("INDEX (" + indexName + ")"); + } + if (Boolean.TRUE.equals(noLock)) { + hints.add("NOLOCK"); + } + for (LockHint hint : lockHints) { + hints.add(hint.name()); + } + return " WITH (" + + String.join(", ", hints) + + ")"; + } + + public SQLServerHints withNoLock(Boolean noLock) { + this.setNoLock(noLock); + return this; + } + + public SQLServerHints withIndexName(String indexName) { + this.setIndexName(indexName); + return this; + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/SignedExpression.java b/src/main/java/net/sf/jsqlparser/expression/SignedExpression.java index 1db5051ff6..43c92e29b3 100644 --- a/src/main/java/net/sf/jsqlparser/expression/SignedExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/SignedExpression.java @@ -1,65 +1,89 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + /** - * It represents a "-" or "+" before an expression + * It represents a "-" or "+" or "~" before an expression */ -public class SignedExpression implements Expression { - - private char sign; - private Expression expression; - - public SignedExpression(char sign, Expression expression) { - setSign(sign); - setExpression(expression); - } - - public char getSign() { - return sign; - } - - public final void setSign(char sign) { - this.sign = sign; - if (sign != '+' && sign != '-') { - throw new IllegalArgumentException("illegal sign character, only + - allowed"); - } - } - - public Expression getExpression() { - return expression; - } - - public final void setExpression(Expression expression) { - this.expression = expression; - } - - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } - - @Override - public String toString() { - return getSign() + expression.toString(); - } +public class SignedExpression extends ASTNodeAccessImpl implements Expression { + + private char sign; + private Expression expression; + + public SignedExpression() { + // empty constructor + } + + public SignedExpression(char sign, Expression expression) { + setSign(sign); + setExpression(expression); + } + + public char getSign() { + return sign; + } + + public final void setSign(char sign) { + this.sign = sign; + if (sign != '+' && sign != '-' && sign != '~') { + throw new IllegalArgumentException("illegal sign character, only + - ~ allowed"); + } + } + + public Expression getExpression() { + return expression; + } + + public final void setExpression(Expression expression) { + this.expression = expression; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + String operand = expression.toString(); + return getSign() + (needsSpaceBefore(operand) ? " " : "") + operand; + } + + /** + * Whether the sign must be separated from an operand starting with {@code firstChar}: "- -1" + * must not become the line comment "--1", nor "~ -a" or "~ ~a" a single operator such as "~-" + * or the LIKE operator "~~", as DuckDB and PostgreSQL read a run of signs containing {@code ~}. + */ + public boolean needsSpaceBefore(char firstChar) { + boolean signedOperand = firstChar == '+' || firstChar == '-' || firstChar == '~'; + return sign == '-' && firstChar == '-' || sign == '~' && signedOperand + || firstChar == '~' && (sign == '+' || sign == '-'); + } + + private boolean needsSpaceBefore(String operand) { + return !operand.isEmpty() && needsSpaceBefore(operand.charAt(0)); + } + + public SignedExpression withSign(char sign) { + this.setSign(sign); + return this; + } + + public SignedExpression withExpression(Expression expression) { + this.setExpression(expression); + return this; + } + + public E getExpression(Class type) { + return type.cast(getExpression()); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/SpannerInterleaveIn.java b/src/main/java/net/sf/jsqlparser/expression/SpannerInterleaveIn.java new file mode 100644 index 0000000000..dc5e56d208 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/SpannerInterleaveIn.java @@ -0,0 +1,81 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2021 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.io.Serializable; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import net.sf.jsqlparser.schema.Table; + +public class SpannerInterleaveIn implements Serializable { + + private Table table; + private OnDelete onDelete; + + public SpannerInterleaveIn() { + + } + + public SpannerInterleaveIn(Table table, OnDelete action) { + setTable(table); + setOnDelete(action); + } + + public SpannerInterleaveIn(List nameParts) { + this(new Table(nameParts), null); + } + + public SpannerInterleaveIn(String tableName) { + this(Collections.singletonList(tableName)); + } + + public Table getTable() { + return table; + } + + public void setTable(Table table) { + this.table = table; + } + + public OnDelete getOnDelete() { + return onDelete; + } + + public void setOnDelete(OnDelete action) { + this.onDelete = action; + } + + @Override + public String toString() { + return "INTERLEAVE IN PARENT " + getTable().getName() + + (getOnDelete() == null ? "" + : " ON DELETE " + + (getOnDelete() == OnDelete.CASCADE ? "CASCADE" : "NO ACTION")); + } + + public SpannerInterleaveIn withTable(Table table) { + this.setTable(table); + return this; + } + + public SpannerInterleaveIn withOnDelete(OnDelete action) { + this.setOnDelete(action); + return this; + } + + public enum OnDelete { + CASCADE, NO_ACTION; + + public static OnDelete from(String action) { + return Enum.valueOf(OnDelete.class, action.toUpperCase(Locale.ROOT)); + } + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/StringValue.java b/src/main/java/net/sf/jsqlparser/expression/StringValue.java index 3bc799d869..55f44fee94 100644 --- a/src/main/java/net/sf/jsqlparser/expression/StringValue.java +++ b/src/main/java/net/sf/jsqlparser/expression/StringValue.java @@ -1,65 +1,613 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + /** * A string as in 'example_string' */ -public class StringValue implements Expression { - - private String value = ""; - - public StringValue(String escapedValue) { - // romoving "'" at the start and at the end - value = escapedValue.substring(1, escapedValue.length() - 1); - } - - public String getValue() { - return value; - } - - public String getNotExcapedValue() { - StringBuilder buffer = new StringBuilder(value); - int index = 0; - int deletesNum = 0; - while ((index = value.indexOf("''", index)) != -1) { - buffer.deleteCharAt(index - deletesNum); - index += 2; - deletesNum++; - } - return buffer.toString(); - } - - public void setValue(String string) { - value = string; - } - - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } - - @Override - public String toString() { - return "'" + value + "'"; - } +public final class StringValue extends ASTNodeAccessImpl implements Expression { + + public static final List ALLOWED_PREFIXES = + Arrays.asList("N", "U", "E", "R", "B", "RB", "_utf8", "Q"); + + /** The prefix of a PostgreSQL Unicode escape string, as in {@code U&'\0041'}. */ + private static final String UNICODE_ESCAPE_PREFIX = "U&"; + + /** + * How a backslash in the literal body was read. The parser records the escaping of the + * configuration that lexed the literal; constructed values default to {@link #STANDARD}. + */ + public enum Escaping { + /** Only a doubled quote character is an escape, as in standard SQL. */ + STANDARD, + /** MySQL/MariaDB backslash escapes, for example {@code \n}, {@code \'} and {@code \\}. */ + MYSQL_BACKSLASH, + /** PostgreSQL escape string escapes, for example {@code E'\n'} and {@code E'\x41'}. */ + POSTGRESQL_ESCAPE_STRING, + /** + * PostgreSQL Unicode escapes of a {@code U&'...'} string: the escape character followed by + * four hexadecimal digits or by {@code +} and six, and a doubled escape character. The + * escape character is a backslash unless {@link #getUnicodeEscapeCharacter()} names another + * one. + */ + POSTGRESQL_UNICODE_ESCAPE + } + + private String value = ""; + private String prefix = null; + private String quoteStr = "'"; + private Escaping escaping = Escaping.STANDARD; + private Character unicodeEscapeCharacter = null; + + public StringValue() { + // empty constructor + } + + public StringValue(String escapedValue) { + // removing "'" at the start and at the end + if (escapedValue.length() >= 2 && escapedValue.startsWith("'") + && escapedValue.endsWith("'")) { + value = escapedValue.substring(1, escapedValue.length() - 1); + return; + } else if (escapedValue.length() >= 2 && escapedValue.startsWith("\"") + && escapedValue.endsWith("\"")) { + // double quoted String Literals (Feature.allowDoubleQuotedStrings) + value = escapedValue.substring(1, escapedValue.length() - 1); + quoteStr = "\""; + return; + } + + String delimiter = getDollarQuoteDelimiter(escapedValue); + if (delimiter != null && escapedValue.length() >= 2 * delimiter.length() + && escapedValue.endsWith(delimiter)) { + quoteStr = delimiter; + value = escapedValue.substring(delimiter.length(), + escapedValue.length() - delimiter.length()); + return; + } + + if (readUnicodeEscapeString(escapedValue)) { + return; + } + + if (escapedValue.length() > 2) { + // Databricks raw literal R"..." + if (escapedValue.regionMatches(true, 0, "R\"", 0, 2) && escapedValue.endsWith("\"")) { + prefix = "R"; + quoteStr = "\""; + value = escapedValue.substring(2, escapedValue.length() - 1); + return; + } + for (String p : ALLOWED_PREFIXES) { + if (escapedValue.length() > p.length() + && escapedValue.substring(0, p.length()).equalsIgnoreCase(p) + && escapedValue.charAt(p.length()) == '\'') { + this.prefix = p; + value = escapedValue.substring(p.length() + 1, escapedValue.length() - 1); + return; + } + } + } + + value = escapedValue; + } + + /** + * Reads {@code U&'body'} with an optional {@code UESCAPE 'c'} clause. Returns false, leaving + * this value unchanged, when the text has another shape. + */ + private boolean readUnicodeEscapeString(String text) { + if (!text.regionMatches(true, 0, UNICODE_ESCAPE_PREFIX + "'", 0, 3)) { + return false; + } + int close = 3; + while (close < text.length()) { + if (text.charAt(close) != '\'') { + close++; + } else if (close + 1 < text.length() && text.charAt(close + 1) == '\'') { + close += 2; + } else { + break; + } + } + if (close >= text.length()) { + return false; + } + String clause = text.substring(close + 1).trim(); + Character escape = null; + if (!clause.isEmpty()) { + if (!clause.regionMatches(true, 0, "UESCAPE", 0, 7)) { + return false; + } + String quoted = clause.substring(7).trim(); + if (quoted.length() != 3 || quoted.charAt(0) != '\'' || quoted.charAt(2) != '\'') { + return false; + } + escape = quoted.charAt(1); + } + prefix = UNICODE_ESCAPE_PREFIX; + value = text.substring(3, close); + escaping = Escaping.POSTGRESQL_UNICODE_ESCAPE; + unicodeEscapeCharacter = escape; + return true; + } + + /** + * Returns the opening PostgreSQL dollar-quote delimiter, or null if there is none. A tag + * follows unquoted identifier rules, excluding dollar signs. This method does not require the + * closing delimiter or inspect the body. + */ + public static String getDollarQuoteDelimiter(String text) { + if (text == null || text.length() < 2 || text.charAt(0) != '$') { + return null; + } + int end = text.indexOf('$', 1); + if (end < 0) { + return null; + } + for (int i = 1; i < end;) { + int character = text.codePointAt(i); + boolean valid = + i == 1 ? Character.isUnicodeIdentifierStart(character) || character == '_' + : Character.isUnicodeIdentifierPart(character); + if (!valid) { + return null; + } + i += Character.charCount(character); + } + return text.substring(0, end + 1); + } + + public String getValue() { + return value; + } + + public void setValue(String string) { + value = string; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public String getQuoteStr() { + return quoteStr; + } + + public StringValue setQuoteStr(String quoteStr) { + this.quoteStr = quoteStr; + return this; + } + + public Escaping getEscaping() { + return escaping; + } + + public void setEscaping(Escaping escaping) { + this.escaping = escaping == null ? Escaping.STANDARD : escaping; + } + + public StringValue withEscaping(Escaping escaping) { + setEscaping(escaping); + return this; + } + + /** + * Returns the escape character named by the {@code UESCAPE} clause of a PostgreSQL Unicode + * escape string, or null when the literal has no such clause and the escape character is a + * backslash. + */ + public Character getUnicodeEscapeCharacter() { + return unicodeEscapeCharacter; + } + + /** + * Sets the escape character rendered as {@code UESCAPE 'c'} after the literal; null removes the + * clause. It applies to {@link Escaping#POSTGRESQL_UNICODE_ESCAPE} values, whose + * {@link #getNotExcapedValue()} rejects a character that PostgreSQL rejects. + */ + public void setUnicodeEscapeCharacter(Character unicodeEscapeCharacter) { + this.unicodeEscapeCharacter = unicodeEscapeCharacter; + } + + public StringValue withUnicodeEscapeCharacter(Character unicodeEscapeCharacter) { + setUnicodeEscapeCharacter(unicodeEscapeCharacter); + return this; + } + + /** + * Returns the literal's characters with its escapes resolved: a doubled quote character and, + * depending on {@link #getEscaping()}, backslash or Unicode escape sequences. PostgreSQL octal + * and hexadecimal escapes denote bytes, which are decoded as UTF-8. Dollar-quoted bodies are + * returned unchanged. + * + * @throws IllegalArgumentException if a {@link Escaping#POSTGRESQL_UNICODE_ESCAPE} value has an + * escape that PostgreSQL rejects, or a {@link Escaping#POSTGRESQL_ESCAPE_STRING} value + * has a Unicode escape that PostgreSQL rejects; the parser rejects such literals + */ + public String getNotExcapedValue() { + if (quoteStr != null && quoteStr.startsWith("$")) { + return value; + } + char quote = "\"".equals(quoteStr) ? '"' : '\''; + if (escaping == Escaping.POSTGRESQL_UNICODE_ESCAPE) { + return unescapeUnicode(value, quote, + unicodeEscapeCharacter == null ? '\\' : unicodeEscapeCharacter); + } + Unescaped result = new Unescaped(value.length()); + int i = 0; + while (i < value.length()) { + char c = value.charAt(i); + if (c == '\\' && escaping != Escaping.STANDARD && i + 1 < value.length()) { + i = escaping == Escaping.MYSQL_BACKSLASH + ? appendMySqlEscape(result, value.charAt(i + 1), i + 1) + : appendPostgresEscape(result, value, i + 1); + } else if (c == quote && i + 1 < value.length() && value.charAt(i + 1) == quote) { + result.append(quote); + i += 2; + } else { + result.append(c); + i++; + } + } + return result.toString(); + } + + /** Appends the MySQL escape {@code c} at {@code index} and returns the index after it. */ + private static int appendMySqlEscape(Unescaped result, char c, int index) { + switch (c) { + case '0': + result.append('\0'); + break; + case 'b': + result.append('\b'); + break; + case 'n': + result.append('\n'); + break; + case 'r': + result.append('\r'); + break; + case 't': + result.append('\t'); + break; + case 'Z': + result.append((char) 0x1A); + break; + case '%': + case '_': + // kept with the backslash, so that LIKE patterns still match them literally + result.append('\\'); + result.append(c); + break; + default: + result.append(c); + } + return index + 1; + } + + /** Appends the PostgreSQL escape string escape at {@code index}; returns the next index. */ + private static int appendPostgresEscape(Unescaped result, String text, int index) { + char c = text.charAt(index); + switch (c) { + case 'b': + result.append('\b'); + return index + 1; + case 'f': + result.append('\f'); + return index + 1; + case 'n': + result.append('\n'); + return index + 1; + case 'r': + result.append('\r'); + return index + 1; + case 't': + result.append('\t'); + return index + 1; + case 'x': + return appendByte(result, text, index + 1, 16, 1, 2, c); + case 'u': + return appendCodePoint(result, text, index, 4); + case 'U': + return appendCodePoint(result, text, index, 8); + default: + if (c >= '0' && c <= '7') { + return appendByte(result, text, index, 8, 1, 3, c); + } + result.append(c); + return index + 1; + } + } + + /** + * Appends the byte spelled by {@code min} to {@code max} digits at {@code start}, or + * {@code fallback} when fewer digits follow, and returns the next index. + */ + private static int appendByte(Unescaped result, String text, int start, int radix, int min, + int max, char fallback) { + int end = start; + while (end < text.length() && end - start < max + && Character.digit(text.charAt(end), radix) >= 0) { + end++; + } + if (end - start < min) { + result.append(fallback); + return start; + } + result.appendByte(Integer.parseInt(text.substring(start, end), radix)); + return end; + } + + /** + * Appends the code point spelled by exactly {@code digits} hexadecimal digits after the escape + * letter at {@code index} and returns the next index. As in a Unicode escape string, the code + * point must be valid and a UTF-16 surrogate pair must be written as two consecutive escapes. + */ + private static int appendCodePoint(Unescaped result, String text, int index, int digits) { + int start = index + 1; + int end = start + digits; + long codePoint = parseHex(text, start, end); + if (codePoint < 0) { + throw new IllegalArgumentException("invalid Unicode escape at position " + (index - 1) + + ": Unicode escapes must be \\u followed by 4 or \\U by 8 hexadecimal digits"); + } + if (codePoint == 0 || codePoint > Character.MAX_CODE_POINT) { + throw new IllegalArgumentException( + "invalid Unicode escape value at position " + (index - 1)); + } + result.appendCodePoint((int) codePoint, index - 1); + return end; + } + + /** + * Resolves PostgreSQL Unicode escapes the way the server does: {@code escape} followed by four + * hexadecimal digits, or by {@code +} and six, names a code point, and a UTF-16 surrogate pair + * must be written as two consecutive escapes. A doubled escape or quote character stands for + * itself. + */ + private static String unescapeUnicode(String text, char quote, char escape) { + checkUnicodeEscapeCharacter(escape); + UnicodeUnescaped result = new UnicodeUnescaped(text.length()); + int i = 0; + while (i < text.length()) { + char c = text.charAt(i); + boolean doubled = i + 1 < text.length() && text.charAt(i + 1) == c; + if (c == escape && !doubled) { + i = appendUnicodeEscape(result, text, i, escape); + } else { + result.append(c, i); + i += doubled && (c == escape || c == quote) ? 2 : 1; + } + } + return result.finish(text.length()); + } + + private static void checkUnicodeEscapeCharacter(char escape) { + if (escape > 0x7F || isHexDigit(escape) || "+'\" \t\n\r\f\u000B".indexOf(escape) >= 0) { + throw new IllegalArgumentException("invalid Unicode escape character '" + escape + "'"); + } + } + + /** + * Appends the code point of the escape at {@code position}, {@code escape} followed by four + * hexadecimal digits or by {@code +} and six, and returns the next index. + */ + private static int appendUnicodeEscape(UnicodeUnescaped result, String text, int position, + char escape) { + boolean plus = position + 1 < text.length() && text.charAt(position + 1) == '+'; + int start = plus ? position + 2 : position + 1; + int end = start + (plus ? 6 : 4); + long codePoint = parseHex(text, start, end); + if (codePoint < 0) { + throw new IllegalArgumentException("invalid Unicode escape at position " + position + + ": Unicode escapes must be " + escape + "XXXX or " + escape + "+XXXXXX"); + } + if (codePoint == 0 || codePoint > Character.MAX_CODE_POINT) { + throw new IllegalArgumentException( + "invalid Unicode escape value at position " + position); + } + result.appendCodePoint((int) codePoint, position); + return end; + } + + private static IllegalArgumentException invalidSurrogatePair(int position) { + return new IllegalArgumentException( + "invalid Unicode surrogate pair at position " + position); + } + + private static boolean isHexDigit(char c) { + return c >= '0' && c <= '9' || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F'; + } + + /** Returns the ASCII hexadecimal number spelled by text[start, end), or -1. */ + private static long parseHex(String text, int start, int end) { + if (end > text.length()) { + return -1; + } + long number = 0; + for (int i = start; i < end; i++) { + char c = text.charAt(i); + if (!isHexDigit(c)) { + return -1; + } + number = number * 16 + Character.digit(c, 16); + } + return number; + } + + /** + * Collects unescaped characters; consecutive escaped bytes are decoded as UTF-8. A UTF-16 + * surrogate pair must be written as two consecutive Unicode escapes, as PostgreSQL requires. + */ + private static final class Unescaped { + private final StringBuilder chars; + private final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + private char highSurrogate; + private int highSurrogatePosition; + + Unescaped(int capacity) { + chars = new StringBuilder(capacity); + } + + void append(char c) { + requireNoPendingSurrogate(); + flushBytes(); + chars.append(c); + } + + /** Appends the code point of the Unicode escape at {@code position}. */ + void appendCodePoint(int codePoint, int position) { + flushBytes(); + if (codePoint >= Character.MIN_LOW_SURROGATE + && codePoint <= Character.MAX_LOW_SURROGATE) { + if (highSurrogate == 0) { + throw invalidSurrogatePair(position); + } + chars.appendCodePoint(Character.toCodePoint(highSurrogate, (char) codePoint)); + highSurrogate = 0; + return; + } + requireNoPendingSurrogate(); + if (codePoint >= Character.MIN_HIGH_SURROGATE + && codePoint <= Character.MAX_HIGH_SURROGATE) { + highSurrogate = (char) codePoint; + highSurrogatePosition = position; + } else { + chars.appendCodePoint(codePoint); + } + } + + void appendByte(int value) { + requireNoPendingSurrogate(); + bytes.write(value); + } + + private void flushBytes() { + if (bytes.size() > 0) { + chars.append(new String(bytes.toByteArray(), StandardCharsets.UTF_8)); + bytes.reset(); + } + } + + private void requireNoPendingSurrogate() { + if (highSurrogate != 0) { + throw invalidSurrogatePair(highSurrogatePosition); + } + } + + @Override + public String toString() { + requireNoPendingSurrogate(); + flushBytes(); + return chars.toString(); + } + } + + /** + * Collects resolved Unicode escapes. A UTF-16 surrogate pair must be written as two consecutive + * escapes, as PostgreSQL requires. + */ + private static final class UnicodeUnescaped { + private final StringBuilder chars; + private char highSurrogate; + + UnicodeUnescaped(int capacity) { + chars = new StringBuilder(capacity); + } + + void append(char c, int position) { + requireNoPendingSurrogate(position); + chars.append(c); + } + + void appendCodePoint(int codePoint, int position) { + if (codePoint >= Character.MIN_LOW_SURROGATE + && codePoint <= Character.MAX_LOW_SURROGATE) { + if (highSurrogate == 0) { + throw invalidSurrogatePair(position); + } + chars.appendCodePoint(Character.toCodePoint(highSurrogate, (char) codePoint)); + highSurrogate = 0; + return; + } + requireNoPendingSurrogate(position); + if (codePoint >= Character.MIN_HIGH_SURROGATE + && codePoint <= Character.MAX_HIGH_SURROGATE) { + highSurrogate = (char) codePoint; + } else { + chars.appendCodePoint(codePoint); + } + } + + String finish(int position) { + requireNoPendingSurrogate(position); + return chars.toString(); + } + + private void requireNoPendingSurrogate(int position) { + if (highSurrogate != 0) { + throw invalidSurrogatePair(position); + } + } + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + String unicodeEscape = unicodeEscapeCharacter != null + ? " UESCAPE '" + unicodeEscapeCharacter + "'" + : ""; + return (prefix != null ? prefix : "") + quoteStr + value + quoteStr + unicodeEscape; + } + + public StringValue withPrefix(String prefix) { + this.setPrefix(prefix); + return this; + } + + public StringValue withValue(String value) { + this.setValue(value); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StringValue that = (StringValue) o; + return Objects.equals(value, that.value) && Objects.equals(prefix, that.prefix); + } + + @Override + public int hashCode() { + return Objects.hash(value, prefix); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/StructType.java b/src/main/java/net/sf/jsqlparser/expression/StructType.java new file mode 100644 index 0000000000..c2b59c51a3 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/StructType.java @@ -0,0 +1,188 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2024 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.create.table.ColDataType; +import net.sf.jsqlparser.statement.select.SelectItem; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; + +/* + * STRUCT + * + * Type Declaration Meaning STRUCT Simple struct with a single unnamed 64-bit integer field. + * STRUCT Simple struct with a single parameterized string field named x. STRUCT> A struct with a nested struct named x inside it. The struct x has two + * fields, y and z, both of which are 64-bit integers. STRUCT> A struct + * containing an array named inner_array that holds 64-bit integer elements. + * + * STRUCT( expr1 [AS field_name] [, ... ]) + * + * Syntax Output Type STRUCT(1,2,3) STRUCT STRUCT() STRUCT<> STRUCT('abc') + * STRUCT STRUCT(1, t.str_col) STRUCT STRUCT(1 AS a, 'abc' AS b) + * STRUCT STRUCT(str_col AS abc) STRUCT + * + * + * Struct Literals + * + * Example Output Type (1, 2, 3) STRUCT (1, 'abc') STRUCT + * STRUCT(1 AS foo, 'abc' AS bar) STRUCT STRUCT(1, 'abc') + * STRUCT STRUCT(1) STRUCT STRUCT(1) STRUCT + * + */ +public class StructType extends ASTNodeAccessImpl implements Expression { + private Dialect dialect = Dialect.BIG_QUERY;; + private String keyword; + private List> parameters; + private List> arguments; + + public StructType(Dialect dialect, String keyword, + List> parameters, + List> arguments) { + this.dialect = dialect; + this.keyword = keyword; + this.parameters = parameters; + this.arguments = arguments; + } + + public StructType(Dialect dialect, List> parameters, + List> arguments) { + this.dialect = dialect; + this.parameters = parameters; + this.arguments = arguments; + } + + public StructType(Dialect dialect, List> arguments) { + this.dialect = dialect; + this.arguments = arguments; + } + + public Dialect getDialect() { + return dialect; + } + + public StructType setDialect(Dialect dialect) { + this.dialect = dialect; + return this; + } + + public String getKeyword() { + return keyword; + } + + public StructType setKeyword(String keyword) { + this.keyword = keyword; + return this; + } + + public List> getParameters() { + return parameters; + } + + public StructType setParameters(List> parameters) { + this.parameters = parameters; + return this; + } + + public List> getArguments() { + return arguments; + } + + public StructType setArguments(List> arguments) { + this.arguments = arguments; + return this; + } + + public StructType add(Expression expression, String aliasName) { + if (arguments == null) { + arguments = new ArrayList<>(); + } + arguments.add(new SelectItem<>(expression, aliasName)); + + return this; + } + + public StringBuilder appendTo(StringBuilder builder) { + return appendTo(builder, expression -> builder.append(expression)); + } + + /** Renders current argument expressions through the caller's visitor. */ + public StringBuilder appendTo(StringBuilder builder, Consumer expressions) { + if (dialect == Dialect.DUCKDB) { + appendArguments(builder, expressions); + appendTypeParameters(builder, true); + } else { + if (keyword != null) { + builder.append(keyword); + } + appendTypeParameters(builder, false); + appendArguments(builder, expressions); + } + return builder; + } + + private void appendTypeParameters(StringBuilder builder, boolean cast) { + if (parameters == null || parameters.isEmpty()) { + return; + } + builder.append(cast ? "::STRUCT( " : "<"); + int i = 0; + for (Map.Entry parameter : parameters) { + if (i++ > 0) { + builder.append(','); + } + if (cast || parameter.getKey() != null && !parameter.getKey().isEmpty()) { + builder.append(parameter.getKey()).append(' '); + } + builder.append(parameter.getValue()); + } + builder.append(cast ? ')' : '>'); + } + + private void appendArguments(StringBuilder builder, Consumer expressions) { + if (arguments == null || arguments.isEmpty()) { + return; + } + boolean structLiteral = dialect == Dialect.DUCKDB; + builder.append(structLiteral ? "{ " : "("); + int i = 0; + for (SelectItem argument : arguments) { + if (i++ > 0) { + builder.append(','); + } + if (structLiteral) { + builder.append(argument.getAlias().getName()).append(':'); + } + expressions.accept(argument.getExpression()); + if (!structLiteral && argument.getAlias() != null) { + builder.append(argument.getAlias()); + } + } + builder.append(structLiteral ? " }" : ")"); + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public enum Dialect { + BIG_QUERY, DUCKDB + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/TernaryExpression.java b/src/main/java/net/sf/jsqlparser/expression/TernaryExpression.java new file mode 100644 index 0000000000..3d67d4ea38 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/TernaryExpression.java @@ -0,0 +1,68 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2025 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** + * The C-style ternary conditional operator {@code condition ? thenExpression : elseExpression}, + * supported for instance by ClickHouse as an alias for {@code if(condition, then, else)}. + */ +public class TernaryExpression extends ASTNodeAccessImpl implements Expression { + private Expression condition; + private Expression thenExpression; + private Expression elseExpression; + + public TernaryExpression() {} + + public TernaryExpression(Expression condition, Expression thenExpression, + Expression elseExpression) { + this.condition = condition; + this.thenExpression = thenExpression; + this.elseExpression = elseExpression; + } + + public Expression getCondition() { + return condition; + } + + public TernaryExpression setCondition(Expression condition) { + this.condition = condition; + return this; + } + + public Expression getThenExpression() { + return thenExpression; + } + + public TernaryExpression setThenExpression(Expression thenExpression) { + this.thenExpression = thenExpression; + return this; + } + + public Expression getElseExpression() { + return elseExpression; + } + + public TernaryExpression setElseExpression(Expression elseExpression) { + this.elseExpression = elseExpression; + return this; + } + + @Override + public String toString() { + return condition + " ? " + thenExpression + " : " + elseExpression; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/TimeKeyExpression.java b/src/main/java/net/sf/jsqlparser/expression/TimeKeyExpression.java new file mode 100644 index 0000000000..759da0e7a4 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/TimeKeyExpression.java @@ -0,0 +1,48 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class TimeKeyExpression extends ASTNodeAccessImpl implements Expression { + + private String stringValue; + + public TimeKeyExpression() { + // empty constructor + } + + public TimeKeyExpression(final String value) { + this.stringValue = value; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public String getStringValue() { + return stringValue; + } + + public void setStringValue(String string) { + stringValue = string; + } + + @Override + public String toString() { + return getStringValue(); + } + + public TimeKeyExpression withStringValue(String stringValue) { + this.setStringValue(stringValue); + return this; + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/TimeValue.java b/src/main/java/net/sf/jsqlparser/expression/TimeValue.java index 7b4e5422de..2b3f74394b 100644 --- a/src/main/java/net/sf/jsqlparser/expression/TimeValue.java +++ b/src/main/java/net/sf/jsqlparser/expression/TimeValue.java @@ -1,54 +1,56 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + import java.sql.Time; /** * A Time in the form {t 'hh:mm:ss'} */ -public class TimeValue implements Expression { - - private Time value; - - public TimeValue(String value) { - this.value = Time.valueOf(value.substring(1, value.length() - 1)); - } - - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } - - public Time getValue() { - return value; - } - - public void setValue(Time d) { - value = d; - } - - @Override - public String toString() { - return "{t '" + value + "'}"; - } +public class TimeValue extends ASTNodeAccessImpl implements Expression { + + private Time value; + + public TimeValue() { + // empty constructor + } + + public TimeValue(String value) { + if (value == null || value.isEmpty()) { + throw new IllegalArgumentException("value can neither be null nor empty."); + } + this.value = Time.valueOf(value.substring(1, value.length() - 1)); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public Time getValue() { + return value; + } + + public void setValue(Time d) { + value = d; + } + + @Override + public String toString() { + return "{t '" + value + "'}"; + } + + public TimeValue withValue(Time value) { + this.setValue(value); + return this; + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/TimestampValue.java b/src/main/java/net/sf/jsqlparser/expression/TimestampValue.java index bfba0fd76b..a06082304b 100644 --- a/src/main/java/net/sf/jsqlparser/expression/TimestampValue.java +++ b/src/main/java/net/sf/jsqlparser/expression/TimestampValue.java @@ -1,54 +1,74 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + import java.sql.Timestamp; +import java.util.Objects; /** * A Timestamp in the form {ts 'yyyy-mm-dd hh:mm:ss.f . . .'} */ -public class TimestampValue implements Expression { +public final class TimestampValue extends ASTNodeAccessImpl implements Expression { + + private static final char QUOTATION = '\''; + private Timestamp value; + private String rawValue; + + public TimestampValue() { + // empty constructor + } + + public TimestampValue(String value) { + // if (value == null) { + // throw new IllegalArgumentException("null string"); + // } else { + // setRawValue(value); + // } + setRawValue(Objects.requireNonNull(value, "The Timestamp string value must not be null.")); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } - private Timestamp value; + public Timestamp getValue() { + return value; + } - public TimestampValue(String value) { - this.value = Timestamp.valueOf(value.substring(1, value.length() - 1)); - } + public void setValue(Timestamp d) { + value = d; + } - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public String getRawValue() { + return rawValue; + } - public Timestamp getValue() { - return value; - } + public void setRawValue(String rawValue) { + this.rawValue = rawValue; + if (rawValue.charAt(0) == QUOTATION) { + this.value = Timestamp.valueOf(rawValue.substring(1, rawValue.length() - 1)); + } else { + this.value = Timestamp.valueOf(rawValue.substring(0, rawValue.length())); + } + } - public void setValue(Timestamp d) { - value = d; - } + @Override + public String toString() { + return "{ts '" + value + "'}"; + } - @Override - public String toString() { - return "{ts '" + value + "'}"; - } + public TimestampValue withValue(Timestamp value) { + this.setValue(value); + return this; + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/TimezoneExpression.java b/src/main/java/net/sf/jsqlparser/expression/TimezoneExpression.java new file mode 100644 index 0000000000..6959549879 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/TimezoneExpression.java @@ -0,0 +1,89 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Consumer; + +public class TimezoneExpression extends ASTNodeAccessImpl implements Expression { + + private final ExpressionList timezoneExpressions = new ExpressionList<>(); + private Expression leftExpression; + private boolean atLocal; + + public TimezoneExpression() { + leftExpression = null; + } + + public TimezoneExpression(Expression leftExpression, Expression... timezoneExpressions) { + this.leftExpression = leftExpression; + this.timezoneExpressions.addAll(Arrays.asList(timezoneExpressions)); + } + + public Expression getLeftExpression() { + return leftExpression; + } + + public TimezoneExpression setLeftExpression(Expression expression) { + this.leftExpression = expression; + return this; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public List getTimezoneExpressions() { + return timezoneExpressions; + } + + public void addTimezoneExpression(Expression... timezoneExpr) { + this.timezoneExpressions.addAll(Arrays.asList(timezoneExpr)); + } + + /** + * Whether the expression ends with {@code AT LOCAL}, which converts to the session time zone. + * It follows the {@code AT TIME ZONE} conversions of this expression, if there are any. + */ + public boolean isAtLocal() { + return atLocal; + } + + public TimezoneExpression setAtLocal(boolean atLocal) { + this.atLocal = atLocal; + return this; + } + + /** + * Appends the expression, rendering the operand and each time zone through the renderer. + */ + public StringBuilder appendTo(StringBuilder builder, Consumer expressionRenderer) { + expressionRenderer.accept(leftExpression); + for (Expression expr : timezoneExpressions) { + builder.append(" AT TIME ZONE "); + expressionRenderer.accept(expr); + } + if (atLocal) { + builder.append(" AT LOCAL"); + } + return builder; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, builder::append).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/TranscodingFunction.java b/src/main/java/net/sf/jsqlparser/expression/TranscodingFunction.java new file mode 100644 index 0000000000..a784518c50 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/TranscodingFunction.java @@ -0,0 +1,154 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2023 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.Locale; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.create.table.ColDataType; + +import java.util.Objects; +import java.util.function.Consumer; + +public class TranscodingFunction extends ASTNodeAccessImpl implements Expression { + private String keyword = "CONVERT"; + + public enum Syntax { + USING, TYPE_FIRST, TYPE_LAST + } + + private Syntax syntax = Syntax.USING; + private ColDataType colDataType; + private Expression expression; + private String transcodingName; + + public TranscodingFunction(String keyword, Expression expression, String transcodingName) { + this.keyword = Objects.requireNonNullElse(keyword, "CONVERT").toUpperCase(Locale.ROOT); + this.expression = expression; + this.transcodingName = transcodingName; + } + + public TranscodingFunction(Expression expression, String transcodingName) { + this.expression = expression; + this.transcodingName = transcodingName; + } + + public TranscodingFunction(String keyword, ColDataType colDataType, Expression expression, + String transcodingName) { + this.keyword = Objects.requireNonNullElse(keyword, "CONVERT").toUpperCase(Locale.ROOT); + this.colDataType = colDataType; + this.expression = expression; + this.transcodingName = transcodingName; + this.syntax = Syntax.TYPE_FIRST; + } + + public TranscodingFunction(ColDataType colDataType, Expression expression, + String transcodingName) { + this.colDataType = colDataType; + this.expression = expression; + this.transcodingName = transcodingName; + this.syntax = Syntax.TYPE_FIRST; + } + + public TranscodingFunction() { + this(null, null); + } + + public String getKeyword() { + return keyword; + } + + public TranscodingFunction setKeyword(String keyword) { + this.keyword = Objects.requireNonNullElse(keyword, "CONVERT").toUpperCase(Locale.ROOT); + return this; + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + public TranscodingFunction withExpression(Expression expression) { + this.setExpression(expression); + return this; + } + + public String getTranscodingName() { + return transcodingName; + } + + public void setTranscodingName(String transcodingName) { + this.transcodingName = transcodingName; + } + + public TranscodingFunction withTranscodingName(String transcodingName) { + this.setTranscodingName(transcodingName); + return this; + + } + + public ColDataType getColDataType() { + return colDataType; + } + + public TranscodingFunction setColDataType(ColDataType colDataType) { + this.colDataType = colDataType; + return this; + } + + public boolean isTranscodeStyle() { + return syntax == Syntax.USING; + } + + public TranscodingFunction setTranscodeStyle(boolean transcodeStyle) { + syntax = transcodeStyle ? Syntax.USING : Syntax.TYPE_FIRST; + return this; + } + + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public Syntax getSyntax() { + return syntax; + } + + public TranscodingFunction setSyntax(Syntax syntax) { + this.syntax = Objects.requireNonNull(syntax); + return this; + } + + public StringBuilder appendTo(StringBuilder builder) { + return appendTo(builder, builder::append); + } + + public StringBuilder appendTo(StringBuilder builder, Consumer expressionRenderer) { + builder.append(keyword).append("( "); + if (syntax == Syntax.TYPE_FIRST) { + builder.append(colDataType).append(", "); + } + expressionRenderer.accept(expression); + if (syntax == Syntax.USING) { + builder.append(" USING ").append(transcodingName); + } else if (syntax == Syntax.TYPE_LAST) { + builder.append(", ").append(colDataType); + } else if (transcodingName != null && !transcodingName.isEmpty()) { + builder.append(", ").append(transcodingName); + } + return builder.append(" )"); + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/TrimFunction.java b/src/main/java/net/sf/jsqlparser/expression/TrimFunction.java new file mode 100644 index 0000000000..e8ea0305d4 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/TrimFunction.java @@ -0,0 +1,124 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2023 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class TrimFunction extends ASTNodeAccessImpl implements Expression { + private TrimSpecification trimSpecification; + private Expression expression; + private Expression fromExpression; + private boolean isUsingFromKeyword; + + public TrimFunction(TrimSpecification trimSpecification, + Expression expression, + Expression fromExpression, + boolean isUsingFromKeyword) { + + this.trimSpecification = trimSpecification; + this.expression = expression; + this.fromExpression = fromExpression; + this.isUsingFromKeyword = isUsingFromKeyword; + } + + public TrimFunction() { + this(null, null, null, false); + } + + public TrimSpecification getTrimSpecification() { + return trimSpecification; + } + + public void setTrimSpecification(TrimSpecification trimSpecification) { + this.trimSpecification = trimSpecification; + } + + public TrimFunction withTrimSpecification(TrimSpecification trimSpecification) { + this.setTrimSpecification(trimSpecification); + return this; + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + public TrimFunction withExpression(Expression expression) { + this.setExpression(expression); + return this; + } + + public Expression getFromExpression() { + return fromExpression; + } + + public void setFromExpression(Expression fromExpression) { + if (fromExpression == null) { + setUsingFromKeyword(false); + } + this.fromExpression = fromExpression; + } + + public TrimFunction withFromExpression(Expression fromExpression) { + this.setFromExpression(fromExpression); + return this; + } + + public boolean isUsingFromKeyword() { + return isUsingFromKeyword; + } + + public void setUsingFromKeyword(boolean useFromKeyword) { + isUsingFromKeyword = useFromKeyword; + } + + public TrimFunction withUsingFromKeyword(boolean useFromKeyword) { + this.setUsingFromKeyword(useFromKeyword); + return this; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public StringBuilder appendTo(StringBuilder builder) { + builder.append("Trim("); + + if (trimSpecification != null) { + builder.append(" ").append(trimSpecification.name()); + } + + if (expression != null) { + builder.append(" ").append(expression); + } + + if (fromExpression != null) { + builder + .append(isUsingFromKeyword ? " FROM " : ", ") + .append(fromExpression); + } + builder.append(" )"); + + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } + + public enum TrimSpecification { + LEADING, TRAILING, BOTH + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/UserVariable.java b/src/main/java/net/sf/jsqlparser/expression/UserVariable.java new file mode 100644 index 0000000000..b0599a3c5d --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/UserVariable.java @@ -0,0 +1,73 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** + * Simple uservariables like @test. + */ +public class UserVariable extends ASTNodeAccessImpl implements Expression { + + private String name; + private boolean doubleAdd = false; + + public UserVariable() { + // empty constructor + } + + public UserVariable(String name) { + setName(name); + } + + public String getName() { + return name; + } + + public void setName(String name) { + if (name.startsWith("@@")) { + this.name = name.substring(2); + doubleAdd = true; + } else if (name.startsWith("@")) { + this.name = name.substring(1); + doubleAdd = false; + } else { + this.name = name; + } + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public boolean isDoubleAdd() { + return doubleAdd; + } + + public void setDoubleAdd(boolean doubleAdd) { + this.doubleAdd = doubleAdd; + } + + @Override + public String toString() { + return "@" + (doubleAdd ? "@" : "") + name; + } + + public UserVariable withName(String name) { + this.setName(name); + return this; + } + + public UserVariable withDoubleAdd(boolean doubleAdd) { + this.setDoubleAdd(doubleAdd); + return this; + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/VariableAssignment.java b/src/main/java/net/sf/jsqlparser/expression/VariableAssignment.java new file mode 100644 index 0000000000..2ad773205a --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/VariableAssignment.java @@ -0,0 +1,58 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** + * Assignment to a user variable like in select @a = 5. + */ +public class VariableAssignment extends ASTNodeAccessImpl implements Expression { + + private UserVariable variable; + private String operation; + private Expression expression; + + public UserVariable getVariable() { + return variable; + } + + public void setVariable(UserVariable variable) { + this.variable = variable; + } + + public String getOperation() { + return operation; + } + + public void setOperation(String operation) { + this.operation = operation; + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + @Override + public String toString() { + return variable.toString() + " " + operation + " " + expression.toString(); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + +} diff --git a/src/main/java/net/sf/jsqlparser/expression/WhenClause.java b/src/main/java/net/sf/jsqlparser/expression/WhenClause.java index c2a105eddb..5ed58de119 100644 --- a/src/main/java/net/sf/jsqlparser/expression/WhenClause.java +++ b/src/main/java/net/sf/jsqlparser/expression/WhenClause.java @@ -1,77 +1,78 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + /** - * A clause of following syntax: WHEN condition THEN expression. Which is part - * of a CaseExpression. - * - * @author Havard Rast Blok + * A clause of following syntax: WHEN condition THEN expression. Which is part of a CaseExpression. */ -public class WhenClause implements Expression { +public class WhenClause extends ASTNodeAccessImpl implements Expression { + + private Expression whenExpression; + private Expression thenExpression; + + public WhenClause() {} + + public WhenClause(Expression whenExpression, Expression thenExpression) { + this.whenExpression = whenExpression; + this.thenExpression = thenExpression; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public Expression getThenExpression() { + return thenExpression; + } + + public void setThenExpression(Expression thenExpression) { + this.thenExpression = thenExpression; + } - private Expression whenExpression; - private Expression thenExpression; + /** + * @return Returns the whenExpression. + */ + public Expression getWhenExpression() { + return whenExpression; + } - /* - * (non-Javadoc) - * - * @see net.sf.jsqlparser.expression.Expression#accept(net.sf.jsqlparser.expression.ExpressionVisitor) - */ - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + /** + * @param whenExpression The whenExpression to set. + */ + public void setWhenExpression(Expression whenExpression) { + this.whenExpression = whenExpression; + } - /** - * @return Returns the thenExpression. - */ - public Expression getThenExpression() { - return thenExpression; - } + @Override + public String toString() { + return "WHEN " + whenExpression + " THEN " + thenExpression; + } - /** - * @param thenExpression The thenExpression to set. - */ - public void setThenExpression(Expression thenExpression) { - this.thenExpression = thenExpression; - } + public WhenClause withWhenExpression(Expression whenExpression) { + this.setWhenExpression(whenExpression); + return this; + } - /** - * @return Returns the whenExpression. - */ - public Expression getWhenExpression() { - return whenExpression; - } + public WhenClause withThenExpression(Expression thenExpression) { + this.setThenExpression(thenExpression); + return this; + } - /** - * @param whenExpression The whenExpression to set. - */ - public void setWhenExpression(Expression whenExpression) { - this.whenExpression = whenExpression; - } + public E getThenExpression(Class type) { + return type.cast(getThenExpression()); + } - @Override - public String toString() { - return "WHEN " + whenExpression + " THEN " + thenExpression; - } + public E getWhenExpression(Class type) { + return type.cast(getWhenExpression()); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/WindowDefinition.java b/src/main/java/net/sf/jsqlparser/expression/WindowDefinition.java new file mode 100644 index 0000000000..cbf6253548 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/WindowDefinition.java @@ -0,0 +1,147 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2022 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.statement.select.OrderByElement; + +public class WindowDefinition implements Serializable { + + + final OrderByClause orderBy = new OrderByClause(); + final PartitionByClause partitionBy = new PartitionByClause(); + WindowElement windowElement = null; + private String windowName; + private String baseWindowName; + + public OrderByClause getOrderBy() { + return orderBy; + } + + public PartitionByClause getPartitionBy() { + return partitionBy; + } + + public WindowElement getWindowElement() { + return windowElement; + } + + public void setWindowElement(WindowElement windowElement) { + this.windowElement = windowElement; + } + + public List getOrderByElements() { + return orderBy.getOrderByElements(); + } + + public void setOrderByElements(List orderByElements) { + orderBy.setOrderByElements(orderByElements); + } + + public ExpressionList getPartitionExpressionList() { + return partitionBy.getPartitionExpressionList(); + } + + public void setPartitionExpressionList(ExpressionList partitionExpressionList) { + setPartitionExpressionList(partitionExpressionList, false); + } + + public void setPartitionExpressionList(ExpressionList partitionExpressionList, + boolean brackets) { + partitionBy.setExpressions(partitionExpressionList, brackets); + } + + /** DuckDB: the window this one extends, as w in OVER (w ORDER BY b), or {@code null}. */ + public String getBaseWindowName() { + return baseWindowName; + } + + public WindowDefinition setBaseWindowName(String baseWindowName) { + this.baseWindowName = baseWindowName; + return this; + } + + /** Appends the base window name, separated from any following part. */ + public void appendBaseWindowNameTo(StringBuilder builder) { + if (baseWindowName != null) { + builder.append(baseWindowName); + boolean more = partitionBy.getPartitionExpressionList() != null + && !partitionBy.getPartitionExpressionList().isEmpty() + || orderBy.getOrderByElements() != null + && !orderBy.getOrderByElements().isEmpty() + || windowElement != null; + if (more) { + builder.append(' '); + } + } + } + + public String getWindowName() { + return windowName; + } + + public void setWindowName(String windowName) { + this.windowName = windowName; + } + + public WindowDefinition withWindowName(String windowName) { + setWindowName(windowName); + return this; + } + + /** Returns the partition, order and frame expressions for both inline and named windows. */ + public List getAllExpressions() { + List expressions = new ArrayList<>(partitionBy); + if (getOrderByElements() != null) { + for (OrderByElement element : getOrderByElements()) { + expressions.add(element.getExpression()); + } + } + if (windowElement != null) { + if (windowElement.getRange() != null) { + addOffsetExpression(expressions, windowElement.getRange().getStart()); + addOffsetExpression(expressions, windowElement.getRange().getEnd()); + } + addOffsetExpression(expressions, windowElement.getOffset()); + } + return expressions; + } + + private static void addOffsetExpression(List expressions, WindowOffset offset) { + if (offset != null && offset.getExpression() != null) { + expressions.add(offset.getExpression()); + } + } + + @Override + public String toString() { + StringBuilder b = new StringBuilder(); + if (windowName != null) { + b.append(windowName).append(" AS "); + } + b.append("("); + appendBaseWindowNameTo(b); + partitionBy.toStringPartitionBy(b); + orderBy.toStringOrderByElements(b); + + if (windowElement != null) { + if (orderBy.getOrderByElements() != null) { + b.append(' '); + } + b.append(windowElement); + } + b.append(")"); + return b.toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/WindowElement.java b/src/main/java/net/sf/jsqlparser/expression/WindowElement.java index 88cf9248dc..01f77557c6 100644 --- a/src/main/java/net/sf/jsqlparser/expression/WindowElement.java +++ b/src/main/java/net/sf/jsqlparser/expression/WindowElement.java @@ -1,37 +1,23 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2014 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; -public class WindowElement { +import java.io.Serializable; +import java.util.Locale; - public enum Type { - - ROWS, - RANGE - } +public class WindowElement implements Serializable { private Type type; private WindowOffset offset; private WindowRange range; + private Exclusion exclusion; public Type getType() { return type; @@ -57,16 +43,72 @@ public void setRange(WindowRange range) { this.range = range; } + public Exclusion getExclusion() { + return exclusion; + } + + public void setExclusion(Exclusion exclusion) { + this.exclusion = exclusion; + } + @Override public String toString() { StringBuilder buffer = new StringBuilder(type.toString()); - + if (offset != null) { buffer.append(offset.toString()); } else if (range != null) { buffer.append(range.toString()); } + if (exclusion != null) { + buffer.append(" EXCLUDE ").append(exclusion); + } + return buffer.toString(); } + + public WindowElement withType(Type type) { + this.setType(type); + return this; + } + + public WindowElement withOffset(WindowOffset offset) { + this.setOffset(offset); + return this; + } + + public WindowElement withRange(WindowRange range) { + this.setRange(range); + return this; + } + + public WindowElement withExclusion(Exclusion exclusion) { + this.setExclusion(exclusion); + return this; + } + + public enum Type { + ROWS, RANGE, GROUPS; + + public static Type from(String type) { + return Enum.valueOf(Type.class, type.toUpperCase(Locale.ROOT)); + } + } + + public enum Exclusion { + CURRENT_ROW("CURRENT ROW"), GROUP("GROUP"), TIES("TIES"), NO_OTHERS("NO OTHERS"); + + private final String keyword; + + Exclusion(String keyword) { + this.keyword = keyword; + } + + @Override + public String toString() { + return keyword; + } + } + } diff --git a/src/main/java/net/sf/jsqlparser/expression/WindowOffset.java b/src/main/java/net/sf/jsqlparser/expression/WindowOffset.java index 53eecdc76e..079ec2eba9 100644 --- a/src/main/java/net/sf/jsqlparser/expression/WindowOffset.java +++ b/src/main/java/net/sf/jsqlparser/expression/WindowOffset.java @@ -1,36 +1,19 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2014 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; -public class WindowOffset { +import java.io.Serializable; +import java.util.Locale; - public enum Type { +public class WindowOffset implements Serializable { - PRECEDING, - FOLLOWING, - CURRENT, - EXPR - } - private Expression expression; private Type type; @@ -60,20 +43,45 @@ public String toString() { buffer.append(type); } } else { - switch (type) { - case PRECEDING: - buffer.append(" UNBOUNDED PRECEDING"); - break; - case FOLLOWING: - buffer.append(" UNBOUNDED FOLLOWING"); - break; - case CURRENT: - buffer.append(" CURRENT ROW"); - break; - default: - break; + if (type != null) { + switch (type) { + case PRECEDING: + buffer.append(" UNBOUNDED PRECEDING"); + break; + case FOLLOWING: + buffer.append(" UNBOUNDED FOLLOWING"); + break; + case CURRENT: + buffer.append(" CURRENT ROW"); + break; + default: + break; + } } } return buffer.toString(); } + + public WindowOffset withExpression(Expression expression) { + this.setExpression(expression); + return this; + } + + public WindowOffset withType(Type type) { + this.setType(type); + return this; + } + + public E getExpression(Class type) { + return type.cast(getExpression()); + } + + public enum Type { + PRECEDING, FOLLOWING, CURRENT, EXPR; + + public static Type from(String type) { + return Enum.valueOf(Type.class, type.toUpperCase(Locale.ROOT)); + } + } + } diff --git a/src/main/java/net/sf/jsqlparser/expression/WindowRange.java b/src/main/java/net/sf/jsqlparser/expression/WindowRange.java index d90ace12c6..fc5f0af368 100644 --- a/src/main/java/net/sf/jsqlparser/expression/WindowRange.java +++ b/src/main/java/net/sf/jsqlparser/expression/WindowRange.java @@ -1,27 +1,17 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2014 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression; -public class WindowRange { +import java.io.Serializable; + +public class WindowRange implements Serializable { private WindowOffset start; private WindowOffset end; @@ -44,11 +34,19 @@ public void setStart(WindowOffset start) { @Override public String toString() { - StringBuilder buffer = new StringBuilder(); - buffer.append(" BETWEEN"); - buffer.append(start); - buffer.append(" AND"); - buffer.append(end); - return buffer.toString(); + return " BETWEEN" + + start + + " AND" + + end; + } + + public WindowRange withStart(WindowOffset start) { + this.setStart(start); + return this; + } + + public WindowRange withEnd(WindowOffset end) { + this.setEnd(end); + return this; } } diff --git a/src/main/java/net/sf/jsqlparser/expression/XMLSerializeExpr.java b/src/main/java/net/sf/jsqlparser/expression/XMLSerializeExpr.java new file mode 100644 index 0000000000..62a4e703aa --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/XMLSerializeExpr.java @@ -0,0 +1,204 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +import static java.util.stream.Collectors.joining; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.create.table.ColDataType; +import net.sf.jsqlparser.statement.select.OrderByElement; + +public class XMLSerializeExpr extends ASTNodeAccessImpl implements Expression { + + public enum SerializationMode { + CONTENT, DOCUMENT + } + + private Expression expression; + private List orderByElements; + private ColDataType dataType; + private SerializationMode serializationMode; + private StringValue encoding; + private StringValue version; + private Boolean indent; + private LongValue indentSize; + private Boolean showDefaults; + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + public List getOrderByElements() { + return orderByElements; + } + + public void setOrderByElements(List orderByElements) { + this.orderByElements = orderByElements; + } + + public ColDataType getDataType() { + return dataType; + } + + public void setDataType(ColDataType dataType) { + this.dataType = dataType; + } + + /** Null retains the legacy XMLAGG(XMLTEXT(...)) form and its existing expression getter. */ + public SerializationMode getSerializationMode() { + return serializationMode; + } + + public void setSerializationMode(SerializationMode serializationMode) { + this.serializationMode = serializationMode; + } + + public StringValue getEncoding() { + return encoding; + } + + public void setEncoding(StringValue encoding) { + this.encoding = encoding; + } + + public StringValue getVersion() { + return version; + } + + public void setVersion(StringValue version) { + this.version = version; + } + + /** Null preserves omission, true is INDENT, and false is NO INDENT. */ + public Boolean getIndent() { + return indent; + } + + public void setIndent(Boolean indent) { + this.indent = indent; + } + + public LongValue getIndentSize() { + return indentSize; + } + + public void setIndentSize(LongValue indentSize) { + this.indentSize = indentSize; + } + + /** Null preserves omission, true is SHOW DEFAULTS, and false is HIDE DEFAULTS. */ + public Boolean getShowDefaults() { + return showDefaults; + } + + public void setShowDefaults(Boolean showDefaults) { + this.showDefaults = showDefaults; + } + + /** Shared child discovery for expression, table-name and validation visitors. */ + public List getExpressions() { + List result = new ArrayList<>(); + if (expression != null) { + result.add(expression); + } + if (orderByElements != null) { + for (OrderByElement orderBy : orderByElements) { + result.add(orderBy.getExpression()); + } + } + if (encoding != null) { + result.add(encoding); + } + if (version != null) { + result.add(version); + } + if (indentSize != null) { + result.add(indentSize); + } + return result; + } + + /** Render both forms without bypassing custom expression or ORDER BY deparsers. */ + public StringBuilder appendTo(StringBuilder sql, Consumer expressionWriter, + Consumer> orderByWriter) { + validateOptions(); + sql.append("xmlserialize("); + if (serializationMode == null) { + sql.append("xmlagg(xmltext("); + expressionWriter.accept(expression); + sql.append(")"); + if (orderByElements != null) { + orderByWriter.accept(orderByElements); + } + sql.append(") AS ").append(dataType); + } else { + sql.append(serializationMode).append(" "); + expressionWriter.accept(expression); + if (dataType != null) { + sql.append(" AS ").append(dataType); + } + if (encoding != null) { + sql.append(" ENCODING "); + expressionWriter.accept(encoding); + } + if (version != null) { + sql.append(" VERSION "); + expressionWriter.accept(version); + } + if (indent != null) { + sql.append(indent ? " INDENT" : " NO INDENT"); + if (indent && indentSize != null) { + sql.append(" SIZE = "); + expressionWriter.accept(indentSize); + } + } + if (showDefaults != null) { + sql.append(showDefaults ? " SHOW DEFAULTS" : " HIDE DEFAULTS"); + } + } + return sql.append(")"); + } + + public void validateOptions() { + if (indentSize != null && (!Boolean.TRUE.equals(indent) || indentSize.getValue() < 0)) { + throw new IllegalArgumentException( + "An indentation size requires INDENT and must be nonnegative"); + } + if (serializationMode == null && (encoding != null || version != null || indent != null + || indentSize != null || showDefaults != null)) { + throw new IllegalArgumentException("Serialization options require CONTENT or DOCUMENT"); + } + if (serializationMode != null && orderByElements != null && !orderByElements.isEmpty()) { + throw new IllegalArgumentException( + "ORDER BY belongs inside the serialized XMLAGG expression"); + } + } + + @Override + public String toString() { + StringBuilder sql = new StringBuilder(); + return appendTo(sql, sql::append, orderBy -> sql.append(" ORDER BY ") + .append(orderBy.stream().map(OrderByElement::toString).collect(joining(", ")))) + .toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/XmlTableFunction.java b/src/main/java/net/sf/jsqlparser/expression/XmlTableFunction.java new file mode 100644 index 0000000000..9a4f4210b8 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/XmlTableFunction.java @@ -0,0 +1,231 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.create.table.ColDataType; + +/** + * Represents an {@code XMLTABLE} table function (SQL/XML standard, supported by PostgreSQL and + * Oracle), which turns an XML document into a relational row set, e.g.: + * + *

+ * XMLTABLE('//ROWS/ROW'
+ *          PASSING data
+ *          COLUMNS id int PATH '@id',
+ *                  ordinality FOR ORDINALITY,
+ *                  country_id text PATH 'COUNTRY_ID',
+ *                  size float PATH 'SIZE' DEFAULT 0)
+ * 
+ * + * It is the XML counterpart of {@link JsonTableFunction} and mirrors its structure, without the + * JSON-specific wrapper/error/plan clauses. + */ +public class XmlTableFunction extends Function { + + private Expression rowPathExpression; + private final List passingClauses = new ArrayList<>(); + private final List columnDefinitions = new ArrayList<>(); + + public static class XmlTablePassingClause extends ASTNodeAccessImpl implements Serializable { + private Expression valueExpression; + private String name; + + public Expression getValueExpression() { + return valueExpression; + } + + public XmlTablePassingClause setValueExpression(Expression valueExpression) { + this.valueExpression = valueExpression; + return this; + } + + public String getName() { + return name; + } + + public XmlTablePassingClause setName(String name) { + this.name = name; + return this; + } + + public void collectExpressions(List expressions) { + if (valueExpression != null) { + expressions.add(valueExpression); + } + } + + @Override + public String toString() { + return valueExpression + (name != null ? " AS " + name : ""); + } + } + + public static class XmlTableColumnDefinition extends ASTNodeAccessImpl implements Serializable { + private String columnName; + private boolean forOrdinality; + private ColDataType dataType; + private Expression pathExpression; + private Expression defaultExpression; + + public String getColumnName() { + return columnName; + } + + public XmlTableColumnDefinition setColumnName(String columnName) { + this.columnName = columnName; + return this; + } + + public boolean isForOrdinality() { + return forOrdinality; + } + + public XmlTableColumnDefinition setForOrdinality(boolean forOrdinality) { + this.forOrdinality = forOrdinality; + return this; + } + + public ColDataType getDataType() { + return dataType; + } + + public XmlTableColumnDefinition setDataType(ColDataType dataType) { + this.dataType = dataType; + return this; + } + + public Expression getPathExpression() { + return pathExpression; + } + + public XmlTableColumnDefinition setPathExpression(Expression pathExpression) { + this.pathExpression = pathExpression; + return this; + } + + public Expression getDefaultExpression() { + return defaultExpression; + } + + public XmlTableColumnDefinition setDefaultExpression(Expression defaultExpression) { + this.defaultExpression = defaultExpression; + return this; + } + + public void collectExpressions(List expressions) { + if (pathExpression != null) { + expressions.add(pathExpression); + } + if (defaultExpression != null) { + expressions.add(defaultExpression); + } + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(columnName); + if (forOrdinality) { + builder.append(" FOR ORDINALITY"); + return builder.toString(); + } + if (dataType != null) { + builder.append(" ").append(dataType); + } + if (pathExpression != null) { + builder.append(" PATH ").append(pathExpression); + } + if (defaultExpression != null) { + builder.append(" DEFAULT ").append(defaultExpression); + } + return builder.toString(); + } + } + + public Expression getRowPathExpression() { + return rowPathExpression; + } + + public XmlTableFunction setRowPathExpression(Expression rowPathExpression) { + this.rowPathExpression = rowPathExpression; + return this; + } + + public List getPassingClauses() { + return passingClauses; + } + + public XmlTableFunction addPassingClause(XmlTablePassingClause passingClause) { + passingClauses.add(passingClause); + return this; + } + + public List getColumnDefinitions() { + return columnDefinitions; + } + + public XmlTableFunction addColumnDefinition(XmlTableColumnDefinition columnDefinition) { + columnDefinitions.add(columnDefinition); + return this; + } + + public List getAllExpressions() { + List expressions = new ArrayList<>(); + if (rowPathExpression != null) { + expressions.add(rowPathExpression); + } + for (XmlTablePassingClause passingClause : passingClauses) { + passingClause.collectExpressions(expressions); + } + for (XmlTableColumnDefinition columnDefinition : columnDefinitions) { + columnDefinition.collectExpressions(expressions); + } + return expressions; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder("XMLTABLE("); + builder.append(rowPathExpression); + if (!passingClauses.isEmpty()) { + builder.append(" PASSING "); + boolean first = true; + for (XmlTablePassingClause passingClause : passingClauses) { + if (!first) { + builder.append(", "); + } + builder.append(passingClause); + first = false; + } + } + if (!columnDefinitions.isEmpty()) { + builder.append(" COLUMNS "); + boolean first = true; + for (XmlTableColumnDefinition columnDefinition : columnDefinitions) { + if (!first) { + builder.append(", "); + } + builder.append(columnDefinition); + first = false; + } + } + builder.append(")"); + return builder.toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Addition.java b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Addition.java index 69ae7dbfb9..fca4fd08df 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Addition.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Addition.java @@ -1,38 +1,43 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.arithmetic; import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; public class Addition extends BinaryExpression { - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public Addition() {} - @Override - public String getStringExpression() { - return "+"; - } + public Addition(Expression leftExpression, Expression rightExpression) { + super(leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "+"; + } + + @Override + public Addition withLeftExpression(Expression arg0) { + return (Addition) super.withLeftExpression(arg0); + } + + @Override + public Addition withRightExpression(Expression arg0) { + return (Addition) super.withRightExpression(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseAnd.java b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseAnd.java index cfccc2c8ec..f5eac93900 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseAnd.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseAnd.java @@ -1,38 +1,43 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.arithmetic; import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; public class BitwiseAnd extends BinaryExpression { - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public BitwiseAnd() {} - @Override - public String getStringExpression() { - return "&"; - } + public BitwiseAnd(Expression leftExpression, Expression rightExpression) { + super(leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "&"; + } + + @Override + public BitwiseAnd withLeftExpression(Expression arg0) { + return (BitwiseAnd) super.withLeftExpression(arg0); + } + + @Override + public BitwiseAnd withRightExpression(Expression arg0) { + return (BitwiseAnd) super.withRightExpression(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseLeftShift.java b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseLeftShift.java new file mode 100644 index 0000000000..0f2094ce97 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseLeftShift.java @@ -0,0 +1,43 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.arithmetic; + +import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class BitwiseLeftShift extends BinaryExpression { + + public BitwiseLeftShift() {} + + public BitwiseLeftShift(Expression leftExpression, Expression rightExpression) { + super(leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "<<"; + } + + @Override + public BitwiseLeftShift withLeftExpression(Expression arg0) { + return (BitwiseLeftShift) super.withLeftExpression(arg0); + } + + @Override + public BitwiseLeftShift withRightExpression(Expression arg0) { + return (BitwiseLeftShift) super.withRightExpression(arg0); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseOr.java b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseOr.java index b17d552dcd..2d11d9e6fb 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseOr.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseOr.java @@ -1,38 +1,43 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.arithmetic; import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; public class BitwiseOr extends BinaryExpression { - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public BitwiseOr() {} - @Override - public String getStringExpression() { - return "|"; - } + public BitwiseOr(Expression leftExpression, Expression rightExpression) { + super(leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "|"; + } + + @Override + public BitwiseOr withLeftExpression(Expression arg0) { + return (BitwiseOr) super.withLeftExpression(arg0); + } + + @Override + public BitwiseOr withRightExpression(Expression arg0) { + return (BitwiseOr) super.withRightExpression(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseRightShift.java b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseRightShift.java new file mode 100644 index 0000000000..13b5dbdd3c --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseRightShift.java @@ -0,0 +1,43 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.arithmetic; + +import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class BitwiseRightShift extends BinaryExpression { + + public BitwiseRightShift() {} + + public BitwiseRightShift(Expression leftExpression, Expression rightExpression) { + super(leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return ">>"; + } + + @Override + public BitwiseRightShift withLeftExpression(Expression arg0) { + return (BitwiseRightShift) super.withLeftExpression(arg0); + } + + @Override + public BitwiseRightShift withRightExpression(Expression arg0) { + return (BitwiseRightShift) super.withRightExpression(arg0); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseXor.java b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseXor.java index cbba102eb0..89cbcb64a0 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseXor.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/BitwiseXor.java @@ -1,38 +1,43 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.arithmetic; import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; public class BitwiseXor extends BinaryExpression { - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public BitwiseXor() {} - @Override - public String getStringExpression() { - return "^"; - } + public BitwiseXor(Expression leftExpression, Expression rightExpression) { + super(leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "^"; + } + + @Override + public BitwiseXor withLeftExpression(Expression arg0) { + return (BitwiseXor) super.withLeftExpression(arg0); + } + + @Override + public BitwiseXor withRightExpression(Expression arg0) { + return (BitwiseXor) super.withRightExpression(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Concat.java b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Concat.java index 88f09dbb05..1ad8bb119d 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Concat.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Concat.java @@ -1,38 +1,43 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.arithmetic; import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; public class Concat extends BinaryExpression { - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public Concat() {} - @Override - public String getStringExpression() { - return "||"; - } + public Concat(Expression leftExpression, Expression rightExpression) { + super(leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "||"; + } + + @Override + public Concat withLeftExpression(Expression arg0) { + return (Concat) super.withLeftExpression(arg0); + } + + @Override + public Concat withRightExpression(Expression arg0) { + return (Concat) super.withRightExpression(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Division.java b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Division.java index 0e7823da8e..a963d63f35 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Division.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Division.java @@ -1,38 +1,43 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.arithmetic; import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; public class Division extends BinaryExpression { - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public Division() {} - @Override - public String getStringExpression() { - return "/"; - } + public Division(Expression leftExpression, Expression rightExpression) { + super(leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "/"; + } + + @Override + public Division withLeftExpression(Expression arg0) { + return (Division) super.withLeftExpression(arg0); + } + + @Override + public Division withRightExpression(Expression arg0) { + return (Division) super.withRightExpression(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Exponentiation.java b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Exponentiation.java new file mode 100644 index 0000000000..321e014879 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Exponentiation.java @@ -0,0 +1,44 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.arithmetic; + +import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; + +/** DuckDB's {@code a ** b}, {@code a} raised to the power {@code b}. */ +public class Exponentiation extends BinaryExpression { + + public Exponentiation() {} + + public Exponentiation(Expression leftExpression, Expression rightExpression) { + super(leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "**"; + } + + @Override + public Exponentiation withLeftExpression(Expression arg0) { + return (Exponentiation) super.withLeftExpression(arg0); + } + + @Override + public Exponentiation withRightExpression(Expression arg0) { + return (Exponentiation) super.withRightExpression(arg0); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/IntegerDivision.java b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/IntegerDivision.java new file mode 100644 index 0000000000..73489eb8d4 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/IntegerDivision.java @@ -0,0 +1,43 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.arithmetic; + +import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class IntegerDivision extends BinaryExpression { + + public IntegerDivision() {} + + public IntegerDivision(Expression leftExpression, Expression rightExpression) { + super(leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "DIV"; + } + + @Override + public IntegerDivision withLeftExpression(Expression arg0) { + return (IntegerDivision) super.withLeftExpression(arg0); + } + + @Override + public IntegerDivision withRightExpression(Expression arg0) { + return (IntegerDivision) super.withRightExpression(arg0); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Modulo.java b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Modulo.java index e816cc30b1..63482d2a2d 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Modulo.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Modulo.java @@ -1,46 +1,46 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.arithmetic; import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; /** * Modulo expression (a % b). - * - * @author toben */ public class Modulo extends BinaryExpression { - public Modulo() { - } + public Modulo() {} - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public Modulo(Expression leftExpression, Expression rightExpression) { + super(leftExpression, rightExpression); + } - @Override - public String getStringExpression() { - return "%"; - } + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "%"; + } + + @Override + public Modulo withLeftExpression(Expression arg0) { + return (Modulo) super.withLeftExpression(arg0); + } + + @Override + public Modulo withRightExpression(Expression arg0) { + return (Modulo) super.withRightExpression(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Multiplication.java b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Multiplication.java index 2ed79c18cf..774db570b8 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Multiplication.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Multiplication.java @@ -1,38 +1,43 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.arithmetic; import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; public class Multiplication extends BinaryExpression { - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public Multiplication() {} - @Override - public String getStringExpression() { - return "*"; - } + public Multiplication(Expression leftExpression, Expression rightExpression) { + super(leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "*"; + } + + @Override + public Multiplication withLeftExpression(Expression arg0) { + return (Multiplication) super.withLeftExpression(arg0); + } + + @Override + public Multiplication withRightExpression(Expression arg0) { + return (Multiplication) super.withRightExpression(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Subtraction.java b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Subtraction.java index d3b4519570..dc2b74c7bf 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Subtraction.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/Subtraction.java @@ -1,38 +1,43 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.arithmetic; import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; public class Subtraction extends BinaryExpression { - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public Subtraction() {} - @Override - public String getStringExpression() { - return "-"; - } + public Subtraction(Expression leftExpression, Expression rightExpression) { + super(leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "-"; + } + + @Override + public Subtraction withLeftExpression(Expression arg0) { + return (Subtraction) super.withLeftExpression(arg0); + } + + @Override + public Subtraction withRightExpression(Expression arg0) { + return (Subtraction) super.withRightExpression(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/arithmetic.uod b/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/arithmetic.uod deleted file mode 100644 index 9ad39aea9c..0000000000 --- a/src/main/java/net/sf/jsqlparser/expression/operators/arithmetic/arithmetic.uod +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/conditional/AndExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/conditional/AndExpression.java index 373b68c350..0d9d36377c 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/conditional/AndExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/conditional/AndExpression.java @@ -1,22 +1,10 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.conditional; @@ -26,19 +14,47 @@ import net.sf.jsqlparser.expression.ExpressionVisitor; public class AndExpression extends BinaryExpression { + private boolean useOperator = false; - public AndExpression(Expression leftExpression, Expression rightExpression) { - setLeftExpression(leftExpression); - setRightExpression(rightExpression); - } + public AndExpression() { + // nothing + } - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public AndExpression(Expression leftExpression, Expression rightExpression) { + setLeftExpression(leftExpression); + setRightExpression(rightExpression); + } - @Override - public String getStringExpression() { - return "AND"; - } + public boolean isUseOperator() { + return useOperator; + } + + public void setUseOperator(boolean useOperator) { + this.useOperator = useOperator; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return useOperator ? "&&" : "AND"; + } + + public AndExpression withUseOperator(boolean useOperator) { + this.setUseOperator(useOperator); + return this; + } + + @Override + public AndExpression withLeftExpression(Expression arg0) { + return (AndExpression) super.withLeftExpression(arg0); + } + + @Override + public AndExpression withRightExpression(Expression arg0) { + return (AndExpression) super.withRightExpression(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/conditional/OrExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/conditional/OrExpression.java index 0ea4f72391..f08cc7de2c 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/conditional/OrExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/conditional/OrExpression.java @@ -1,22 +1,10 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.conditional; @@ -27,18 +15,33 @@ public class OrExpression extends BinaryExpression { - public OrExpression(Expression leftExpression, Expression rightExpression) { - setLeftExpression(leftExpression); - setRightExpression(rightExpression); - } + public OrExpression() { + // nothing + } - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public OrExpression(Expression leftExpression, Expression rightExpression) { + setLeftExpression(leftExpression); + setRightExpression(rightExpression); + } + + @Override + public OrExpression withLeftExpression(Expression expression) { + return (OrExpression) super.withLeftExpression(expression); + } + + @Override + public OrExpression withRightExpression(Expression expression) { + return (OrExpression) super.withRightExpression(expression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "OR"; + } - @Override - public String getStringExpression() { - return "OR"; - } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/conditional/XorExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/conditional/XorExpression.java new file mode 100644 index 0000000000..9bab8b53f8 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/conditional/XorExpression.java @@ -0,0 +1,47 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2021 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.conditional; + +import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class XorExpression extends BinaryExpression { + + public XorExpression() { + // nothing + } + + public XorExpression(Expression leftExpression, Expression rightExpression) { + setLeftExpression(leftExpression); + setRightExpression(rightExpression); + } + + @Override + public XorExpression withLeftExpression(Expression expression) { + return (XorExpression) super.withLeftExpression(expression); + } + + @Override + public XorExpression withRightExpression(Expression expression) { + return (XorExpression) super.withRightExpression(expression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "XOR"; + } + +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/Between.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/Between.java index ed7ad0ea65..ff24e0eba3 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/Between.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/Between.java @@ -1,79 +1,159 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; /** * A "BETWEEN" expr1 expr2 statement */ -public class Between implements Expression { - - private Expression leftExpression; - private boolean not = false; - private Expression betweenExpressionStart; - private Expression betweenExpressionEnd; - - public Expression getBetweenExpressionEnd() { - return betweenExpressionEnd; - } - - public Expression getBetweenExpressionStart() { - return betweenExpressionStart; - } - - public Expression getLeftExpression() { - return leftExpression; - } - - public boolean isNot() { - return not; - } - - public void setBetweenExpressionEnd(Expression expression) { - betweenExpressionEnd = expression; - } - - public void setBetweenExpressionStart(Expression expression) { - betweenExpressionStart = expression; - } - - public void setLeftExpression(Expression expression) { - leftExpression = expression; - } - - public void setNot(boolean b) { - not = b; - } - - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } - - @Override - public String toString() { - return leftExpression + " " + (not ? "NOT " : "") + "BETWEEN " + betweenExpressionStart + " AND " - + betweenExpressionEnd; - } +public class Between extends ASTNodeAccessImpl implements Expression, SupportsOldOracleJoinSyntax { + + private Expression leftExpression; + private boolean not = false; + private Expression betweenExpressionStart; + private Expression betweenExpressionEnd; + private boolean usingSymmetric = false; + private boolean usingAsymmetric = false; + + public Expression getBetweenExpressionEnd() { + return betweenExpressionEnd; + } + + public void setBetweenExpressionEnd(Expression expression) { + betweenExpressionEnd = expression; + } + + public Expression getBetweenExpressionStart() { + return betweenExpressionStart; + } + + public void setBetweenExpressionStart(Expression expression) { + betweenExpressionStart = expression; + } + + public Expression getLeftExpression() { + return leftExpression; + } + + public void setLeftExpression(Expression expression) { + leftExpression = expression; + } + + public boolean isNot() { + return not; + } + + public void setNot(boolean b) { + not = b; + } + + public boolean isUsingSymmetric() { + return usingSymmetric; + } + + public Between setUsingSymmetric(boolean usingSymmetric) { + this.usingSymmetric = usingSymmetric; + return this; + } + + public boolean isUsingAsymmetric() { + return usingAsymmetric; + } + + public Between setUsingAsymmetric(boolean usingAsymmetric) { + this.usingAsymmetric = usingAsymmetric; + return this; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + return (oraclePriorPosition == ORACLE_PRIOR_START ? "PRIOR " : "") + leftExpression + " " + + (not ? "NOT " : "") + "BETWEEN " + + (usingSymmetric ? "SYMMETRIC " : "") + (usingAsymmetric ? "ASYMMETRIC " : "") + + betweenExpressionStart + + " AND " + + betweenExpressionEnd; + } + + public Between withLeftExpression(Expression leftExpression) { + this.setLeftExpression(leftExpression); + return this; + } + + public Between withNot(boolean not) { + this.setNot(not); + return this; + } + + public Between withBetweenExpressionStart(Expression betweenExpressionStart) { + this.setBetweenExpressionStart(betweenExpressionStart); + return this; + } + + public Between withBetweenExpressionEnd(Expression betweenExpressionEnd) { + this.setBetweenExpressionEnd(betweenExpressionEnd); + return this; + } + + public E getBetweenExpressionEnd(Class type) { + return type.cast(getBetweenExpressionEnd()); + } + + public E getBetweenExpressionStart(Class type) { + return type.cast(getBetweenExpressionStart()); + } + + public E getLeftExpression(Class type) { + return type.cast(getLeftExpression()); + } + + private int oraclePriorPosition = NO_ORACLE_PRIOR; + + @Override + public int getOldOracleJoinSyntax() { + return NO_ORACLE_JOIN; + } + + @Override + public void setOldOracleJoinSyntax(int oldOracleJoinSyntax) { + throw new IllegalArgumentException( + "oracle join operator (+) is not supported on this condition"); + } + + @Override + public Between withOldOracleJoinSyntax(int oldOracleJoinSyntax) { + setOldOracleJoinSyntax(oldOracleJoinSyntax); + return this; + } + + @Override + public int getOraclePriorPosition() { + return oraclePriorPosition; + } + + @Override + public void setOraclePriorPosition(int oraclePriorPosition) { + this.oraclePriorPosition = oraclePriorPosition; + } + + public Between withOraclePriorPosition(int oraclePriorPosition) { + setOraclePriorPosition(oraclePriorPosition); + return this; + } + } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/ComparisonOperator.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/ComparisonOperator.java new file mode 100644 index 0000000000..d15081101f --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/ComparisonOperator.java @@ -0,0 +1,52 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.Expression; + +public abstract class ComparisonOperator extends OldOracleJoinBinaryExpression { + + private final String operator; + + public ComparisonOperator(String operator) { + this.operator = operator; + } + + public ComparisonOperator(String operator, Expression left, Expression right) { + this(operator); + setLeftExpression(left); + setRightExpression(right); + } + + @Override + public String getStringExpression() { + return operator; + } + + @Override + public ComparisonOperator withLeftExpression(Expression arg0) { + return (ComparisonOperator) super.withLeftExpression(arg0); + } + + @Override + public ComparisonOperator withRightExpression(Expression arg0) { + return (ComparisonOperator) super.withRightExpression(arg0); + } + + @Override + public ComparisonOperator withOldOracleJoinSyntax(int oldOracleJoinSyntax) { + return (ComparisonOperator) super.withOldOracleJoinSyntax(oldOracleJoinSyntax); + } + + @Override + public ComparisonOperator withOraclePriorPosition(int oraclePriorPosition) { + return (ComparisonOperator) super.withOraclePriorPosition(oraclePriorPosition); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/ContainedBy.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/ContainedBy.java new file mode 100644 index 0000000000..15562a4082 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/ContainedBy.java @@ -0,0 +1,25 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2023 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class ContainedBy extends ComparisonOperator { + + public ContainedBy() { + super("<&"); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} + diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/Contains.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/Contains.java new file mode 100644 index 0000000000..dbfda1027a --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/Contains.java @@ -0,0 +1,25 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2023 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class Contains extends ComparisonOperator { + + public Contains() { + super("&>"); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} + diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/CosineSimilarity.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/CosineSimilarity.java new file mode 100644 index 0000000000..00aad962de --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/CosineSimilarity.java @@ -0,0 +1,28 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2022 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class CosineSimilarity extends ComparisonOperator { + + public CosineSimilarity() { + super("<=>"); + } + + public CosineSimilarity(String operator) { + super(operator); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/DoubleAnd.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/DoubleAnd.java new file mode 100644 index 0000000000..372e123b1d --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/DoubleAnd.java @@ -0,0 +1,24 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2023 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class DoubleAnd extends ComparisonOperator { + + public DoubleAnd() { + super("&&"); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/EqualsTo.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/EqualsTo.java index 804b16b561..19f238ffbb 100755 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/EqualsTo.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/EqualsTo.java @@ -1,37 +1,56 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; -public class EqualsTo extends OldOracleJoinBinaryExpression { +public class EqualsTo extends ComparisonOperator { - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public EqualsTo() { + super("="); + } - @Override - public String getStringExpression() { - return "="; - } + /** {@code operator} is {@code =} or DuckDB's {@code ==}. */ + public EqualsTo(String operator) { + super(operator); + } + + public EqualsTo(Expression left, Expression right) { + this(); + setLeftExpression(left); + setRightExpression(right); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public EqualsTo withLeftExpression(Expression expression) { + return (EqualsTo) super.withLeftExpression(expression); + } + + @Override + public EqualsTo withRightExpression(Expression expression) { + return (EqualsTo) super.withRightExpression(expression); + } + + @Override + public EqualsTo withOldOracleJoinSyntax(int arg0) { + return (EqualsTo) super.withOldOracleJoinSyntax(arg0); + } + + @Override + public EqualsTo withOraclePriorPosition(int arg0) { + return (EqualsTo) super.withOraclePriorPosition(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/ExcludesExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/ExcludesExpression.java new file mode 100644 index 0000000000..847ff087c9 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/ExcludesExpression.java @@ -0,0 +1,78 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class ExcludesExpression extends ASTNodeAccessImpl implements Expression { + + private Expression leftExpression; + private Expression rightExpression; + + public ExcludesExpression() {} + + public ExcludesExpression(Expression leftExpression, Expression rightExpression) { + this.leftExpression = leftExpression; + this.rightExpression = rightExpression; + } + + public Expression getLeftExpression() { + return leftExpression; + } + + public final void setLeftExpression(Expression expression) { + leftExpression = expression; + } + + public ExcludesExpression withLeftExpression(Expression expression) { + this.setLeftExpression(expression); + return this; + } + + public Expression getRightExpression() { + return rightExpression; + } + + public void setRightExpression(Expression rightExpression) { + this.rightExpression = rightExpression; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + StringBuilder statementBuilder = new StringBuilder(); + statementBuilder.append(leftExpression); + + statementBuilder.append(" "); + statementBuilder.append("EXCLUDES "); + + statementBuilder.append(rightExpression); + return statementBuilder.toString(); + } + + public ExcludesExpression withRightExpression(Expression rightExpression) { + this.setRightExpression(rightExpression); + return this; + } + + public E getLeftExpression(Class type) { + return type.cast(getLeftExpression()); + } + + public E getRightExpression(Class type) { + return type.cast(getRightExpression()); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/ExistsExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/ExistsExpression.java index eb27c5333a..c8d83f1d53 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/ExistsExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/ExistsExpression.java @@ -1,61 +1,64 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; -public class ExistsExpression implements Expression { +public class ExistsExpression extends ASTNodeAccessImpl implements Expression { - private Expression rightExpression; - private boolean not = false; + protected Expression rightExpression; + protected boolean not = false; - public Expression getRightExpression() { - return rightExpression; - } + public Expression getRightExpression() { + return rightExpression; + } - public void setRightExpression(Expression expression) { - rightExpression = expression; - } + public void setRightExpression(Expression expression) { + rightExpression = expression; + } - public boolean isNot() { - return not; - } + public boolean isNot() { + return not; + } - public void setNot(boolean b) { - not = b; - } + public void setNot(boolean b) { + not = b; + } - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } - public String getStringExpression() { - return ((not) ? "NOT " : "") + "EXISTS"; - } + public String getStringExpression() { + return (not ? "NOT " : "") + "EXISTS"; + } - @Override - public String toString() { - return getStringExpression() + " " + rightExpression.toString(); - } + @Override + public String toString() { + return getStringExpression() + " " + rightExpression.toString(); + } + + public ExistsExpression withRightExpression(Expression rightExpression) { + this.setRightExpression(rightExpression); + return this; + } + + public ExistsExpression withNot(boolean not) { + this.setNot(not); + return this; + } + + public E getRightExpression(Class type) { + return type.cast(getRightExpression()); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/ExpressionList.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/ExpressionList.java index f0649a7ff6..5efb043598 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/ExpressionList.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/ExpressionList.java @@ -1,60 +1,112 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; -import java.util.List; - import net.sf.jsqlparser.expression.Expression; -import net.sf.jsqlparser.statement.select.PlainSelect; +import net.sf.jsqlparser.expression.ExpressionVisitor; +import net.sf.jsqlparser.parser.Node; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; /** * A list of expressions, as in SELECT A FROM TAB WHERE B IN (expr1,expr2,expr3) */ -public class ExpressionList implements ItemsList { +public class ExpressionList extends ArrayList + implements Expression, Serializable { + private transient Node node; + + public ExpressionList(Collection expressions) { + addAll(expressions); + } + + public ExpressionList(List expressions) { + super(expressions); + } + + public ExpressionList(T... expressions) { + this(Arrays.asList(expressions)); + } + + @Deprecated + public boolean isUsingBrackets() { + return false; + } + + @Deprecated + public List getExpressions() { + return this; + } + + @Deprecated + public void setExpressions(List expressions) { + this.clear(); + this.addAll(expressions); + } + + public ExpressionList addExpression(T expression) { + this.add(expression); + return this; + } + + public ExpressionList addExpressions(T... expressions) { + addAll(Arrays.asList(expressions)); + return this; + } + + public ExpressionList addExpressions(Collection expressions) { + addAll(expressions); + return this; + } + + public ExpressionList withExpressions(T... expressions) { + this.clear(); + return addExpressions(expressions); + } - private List expressions; + public ExpressionList withExpressions(Collection expressions) { + this.clear(); + return addExpressions(expressions); + } - public ExpressionList() { - } + public StringBuilder appendTo(StringBuilder builder) { + for (int i = 0; i < size(); i++) { + if (i > 0) { + builder.append(", "); + } + builder.append(get(i)); + } + return builder; + } - public ExpressionList(List expressions) { - this.expressions = expressions; - } + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } - public List getExpressions() { - return expressions; - } - public void setExpressions(List list) { - expressions = list; - } + @Override + public Node getASTNode() { + return node; + } - @Override - public void accept(ItemsListVisitor itemsListVisitor) { - itemsListVisitor.visit(this); - } + @Override + public void setASTNode(Node node) { + this.node = node; + } - @Override - public String toString() { - return PlainSelect.getStringList(expressions, true, true); - } + @Override + public K accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/FullTextSearch.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/FullTextSearch.java new file mode 100644 index 0000000000..8c1a8d97ef --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/FullTextSearch.java @@ -0,0 +1,121 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import java.util.Optional; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; +import net.sf.jsqlparser.expression.JdbcNamedParameter; +import net.sf.jsqlparser.expression.JdbcParameter; +import net.sf.jsqlparser.expression.StringValue; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.schema.Column; + +public class FullTextSearch extends ASTNodeAccessImpl implements Expression { + + private ExpressionList _matchColumns; + private Expression _againstValue; + private String _searchModifier; + + public FullTextSearch() { + + } + + public ExpressionList getMatchColumns() { + return this._matchColumns; + } + + public void setMatchColumns(ExpressionList columns) { + this._matchColumns = columns; + } + + public Expression getAgainstValue() { + return this._againstValue; + } + + public void setAgainstValue(Expression val) { + this._againstValue = val; + } + + public void setAgainstValue(StringValue val) { + setAgainstValue((Expression) val); + } + + public void setAgainstValue(JdbcNamedParameter val) { + setAgainstValue((Expression) val); + } + + public void setAgainstValue(JdbcParameter val) { + setAgainstValue((Expression) val); + } + + public String getSearchModifier() { + return this._searchModifier; + } + + public void setSearchModifier(String val) { + this._searchModifier = val; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + // Build a list of matched columns + StringBuilder columnsListCommaSeperated = new StringBuilder(); + Iterator iterator = this._matchColumns.iterator(); + while (iterator.hasNext()) { + Column col = iterator.next(); + columnsListCommaSeperated.append(col.getFullyQualifiedName()); + if (iterator.hasNext()) { + columnsListCommaSeperated.append(","); + } + } + + return "MATCH (" + columnsListCommaSeperated + ") AGAINST (" + this._againstValue + + (this._searchModifier != null ? " " + this._searchModifier : "") + ")"; + } + + public FullTextSearch withMatchColumns(ExpressionList matchColumns) { + this.setMatchColumns(matchColumns); + return this; + } + + public FullTextSearch withAgainstValue(StringValue againstValue) { + return withAgainstValue((Expression) againstValue); + } + + public FullTextSearch withAgainstValue(Expression againstValue) { + this.setAgainstValue(againstValue); + return this; + } + + public FullTextSearch withSearchModifier(String searchModifier) { + this.setSearchModifier(searchModifier); + return this; + } + + public FullTextSearch addMatchColumns(Column... matchColumns) { + return this.addMatchColumns(Arrays.asList(matchColumns)); + } + + public FullTextSearch addMatchColumns(Collection matchColumns) { + ExpressionList collection = + Optional.ofNullable(getMatchColumns()).orElseGet(ExpressionList::new); + collection.addAll(matchColumns); + return this.withMatchColumns(collection); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/GeometryDistance.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/GeometryDistance.java new file mode 100644 index 0000000000..9f8438ab64 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/GeometryDistance.java @@ -0,0 +1,28 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2022 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class GeometryDistance extends ComparisonOperator { + + public GeometryDistance() { + super("<->"); + } + + public GeometryDistance(String operator) { + super(operator); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/GreaterThan.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/GreaterThan.java index 66dacd6f1a..3599ba45d5 100755 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/GreaterThan.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/GreaterThan.java @@ -1,37 +1,49 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; -public class GreaterThan extends OldOracleJoinBinaryExpression { +public class GreaterThan extends ComparisonOperator { - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public GreaterThan() { + super(">"); + } - @Override - public String getStringExpression() { - return ">"; - } + public GreaterThan(Expression leftExpression, Expression rightExpression) { + super(">", leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public GreaterThan withLeftExpression(Expression arg0) { + return (GreaterThan) super.withLeftExpression(arg0); + } + + @Override + public GreaterThan withRightExpression(Expression arg0) { + return (GreaterThan) super.withRightExpression(arg0); + } + + @Override + public GreaterThan withOldOracleJoinSyntax(int arg0) { + return (GreaterThan) super.withOldOracleJoinSyntax(arg0); + } + + @Override + public GreaterThan withOraclePriorPosition(int arg0) { + return (GreaterThan) super.withOraclePriorPosition(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/GreaterThanEquals.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/GreaterThanEquals.java index 17e462d139..39d1c8c977 100755 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/GreaterThanEquals.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/GreaterThanEquals.java @@ -1,37 +1,53 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; -public class GreaterThanEquals extends OldOracleJoinBinaryExpression { +public class GreaterThanEquals extends ComparisonOperator { - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public GreaterThanEquals() { + super(">="); + } - @Override - public String getStringExpression() { - return ">="; - } + public GreaterThanEquals(String operator) { + super(operator); + } + + public GreaterThanEquals(Expression leftExpression, Expression rightExpression) { + super(">=", leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public GreaterThanEquals withLeftExpression(Expression arg0) { + return (GreaterThanEquals) super.withLeftExpression(arg0); + } + + @Override + public GreaterThanEquals withRightExpression(Expression arg0) { + return (GreaterThanEquals) super.withRightExpression(arg0); + } + + @Override + public GreaterThanEquals withOldOracleJoinSyntax(int arg0) { + return (GreaterThanEquals) super.withOldOracleJoinSyntax(arg0); + } + + @Override + public GreaterThanEquals withOraclePriorPosition(int arg0) { + return (GreaterThanEquals) super.withOraclePriorPosition(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/InExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/InExpression.java index bcc75ba6dd..c920c2b872 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/InExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/InExpression.java @@ -1,114 +1,160 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; -public class InExpression implements Expression, SupportsOldOracleJoinSyntax { - - private Expression leftExpression; - private ItemsList leftItemsList; - private ItemsList rightItemsList; - private boolean not = false; +public class InExpression extends ASTNodeAccessImpl + implements Expression, SupportsOldOracleJoinSyntax { + private Expression leftExpression; + private boolean global = false; + private boolean not = false; + private Expression rightExpression; private int oldOracleJoinSyntax = NO_ORACLE_JOIN; - public InExpression() { - } + private int oraclePriorPosition = NO_ORACLE_PRIOR; + + public InExpression() {} - public InExpression(Expression leftExpression, ItemsList itemsList) { - setLeftExpression(leftExpression); - setRightItemsList(itemsList); - } + public InExpression(Expression leftExpression, Expression rightExpression) { + this.leftExpression = leftExpression; + this.rightExpression = rightExpression; + } + + @Override + public int getOldOracleJoinSyntax() { + return oldOracleJoinSyntax; + } - @Override + @Override public void setOldOracleJoinSyntax(int oldOracleJoinSyntax) { this.oldOracleJoinSyntax = oldOracleJoinSyntax; if (oldOracleJoinSyntax < 0 || oldOracleJoinSyntax > 1) { - throw new IllegalArgumentException("unexpected join type for oracle found with IN (type=" + oldOracleJoinSyntax + ")"); + throw new IllegalArgumentException( + "unexpected join type for oracle found with IN (type=" + oldOracleJoinSyntax + + ")"); } } - @Override - public int getOldOracleJoinSyntax() { - return oldOracleJoinSyntax; + public Expression getLeftExpression() { + return leftExpression; } - public ItemsList getRightItemsList() { - return rightItemsList; - } + public final void setLeftExpression(Expression expression) { + leftExpression = expression; + } - public Expression getLeftExpression() { - return leftExpression; - } + public InExpression withLeftExpression(Expression expression) { + this.setLeftExpression(expression); + return this; + } - public final void setRightItemsList(ItemsList list) { - rightItemsList = list; - } + public boolean isGlobal() { + return global; + } - public final void setLeftExpression(Expression expression) { - leftExpression = expression; - } + public InExpression setGlobal(boolean b) { + global = b; + return this; + } - public boolean isNot() { - return not; - } + public boolean isNot() { + return not; + } - public void setNot(boolean b) { - not = b; - } + public void setNot(boolean b) { + not = b; + } - public ItemsList getLeftItemsList() { - return leftItemsList; - } + public Expression getRightExpression() { + return rightExpression; + } - public void setLeftItemsList(ItemsList leftItemsList) { - this.leftItemsList = leftItemsList; - } + public void setRightExpression(Expression rightExpression) { + this.rightExpression = rightExpression; + } - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } private String getLeftExpressionString() { return leftExpression + (oldOracleJoinSyntax == ORACLE_JOIN_RIGHT ? "(+)" : ""); } - @Override - public String toString() { - return (leftExpression == null ? leftItemsList : getLeftExpressionString()) + " " + ((not) ? "NOT " : "") + "IN " + rightItemsList + ""; - } - - @Override - public int getOraclePriorPosition() { - return SupportsOldOracleJoinSyntax.NO_ORACLE_PRIOR; - } + @Override + public String toString() { + StringBuilder statementBuilder = new StringBuilder(); + if (oraclePriorPosition == ORACLE_PRIOR_START) { + statementBuilder.append("PRIOR "); + } + statementBuilder.append(getLeftExpressionString()); - @Override - public void setOraclePriorPosition(int priorPosition) { - if (priorPosition != SupportsOldOracleJoinSyntax.NO_ORACLE_PRIOR) { - throw new IllegalArgumentException("unexpected prior for oracle found"); + statementBuilder.append(" "); + if (global) { + statementBuilder.append("GLOBAL "); } - } + if (not) { + statementBuilder.append("NOT "); + } + statementBuilder.append("IN "); + statementBuilder.append(rightExpression); + return statementBuilder.toString(); + } + + @Override + public int getOraclePriorPosition() { + return oraclePriorPosition; + } + + @Override + public void setOraclePriorPosition(int priorPosition) { + this.oraclePriorPosition = priorPosition; + } + + public InExpression withRightExpression(Expression rightExpression) { + this.setRightExpression(rightExpression); + return this; + } + + @Override + public InExpression withOldOracleJoinSyntax(int oldOracleJoinSyntax) { + this.setOldOracleJoinSyntax(oldOracleJoinSyntax); + return this; + } + + @Override + public InExpression withOraclePriorPosition(int priorPosition) { + this.setOraclePriorPosition(priorPosition); + return this; + } + + public InExpression withGlobal(boolean global) { + this.setGlobal(global); + return this; + } + + public InExpression withNot(boolean not) { + this.setNot(not); + return this; + } + + public E getLeftExpression(Class type) { + return type.cast(getLeftExpression()); + } + + public E getRightExpression(Class type) { + return type.cast(getRightExpression()); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/IncludesExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/IncludesExpression.java new file mode 100644 index 0000000000..b0b260e721 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/IncludesExpression.java @@ -0,0 +1,79 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class IncludesExpression extends ASTNodeAccessImpl + implements Expression { + + private Expression leftExpression; + private Expression rightExpression; + + public IncludesExpression() {} + + public IncludesExpression(Expression leftExpression, Expression rightExpression) { + this.leftExpression = leftExpression; + this.rightExpression = rightExpression; + } + + public Expression getLeftExpression() { + return leftExpression; + } + + public final void setLeftExpression(Expression expression) { + leftExpression = expression; + } + + public IncludesExpression withLeftExpression(Expression expression) { + this.setLeftExpression(expression); + return this; + } + + public Expression getRightExpression() { + return rightExpression; + } + + public void setRightExpression(Expression rightExpression) { + this.rightExpression = rightExpression; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + StringBuilder statementBuilder = new StringBuilder(); + statementBuilder.append(leftExpression); + + statementBuilder.append(" "); + statementBuilder.append("INCLUDES "); + + statementBuilder.append(rightExpression); + return statementBuilder.toString(); + } + + public IncludesExpression withRightExpression(Expression rightExpression) { + this.setRightExpression(rightExpression); + return this; + } + + public E getLeftExpression(Class type) { + return type.cast(getLeftExpression()); + } + + public E getRightExpression(Class type) { + return type.cast(getRightExpression()); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/Intersects.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/Intersects.java new file mode 100644 index 0000000000..0f05edcb60 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/Intersects.java @@ -0,0 +1,41 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; + +/** + * The PostgreSQL # binary operator: the geometric intersection of lseg / line / box + * (documentation Table 9.36) and the integer bitwise exclusive OR (Table 9.4). + */ +public class Intersects extends BinaryExpression { + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "#"; + } + + @Override + public Intersects withLeftExpression(Expression expression) { + return (Intersects) super.withLeftExpression(expression); + } + + @Override + public Intersects withRightExpression(Expression expression) { + return (Intersects) super.withRightExpression(expression); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsBooleanExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsBooleanExpression.java new file mode 100644 index 0000000000..6cf101bd9a --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsBooleanExpression.java @@ -0,0 +1,115 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class IsBooleanExpression extends ASTNodeAccessImpl + implements Expression, SupportsOldOracleJoinSyntax { + + private Expression leftExpression; + private boolean not = false; + private boolean isTrue = false; + + public Expression getLeftExpression() { + return leftExpression; + } + + public void setLeftExpression(Expression expression) { + leftExpression = expression; + } + + public boolean isNot() { + return not; + } + + public void setNot(boolean b) { + not = b; + } + + public boolean isTrue() { + return isTrue; + } + + public void setIsTrue(boolean isTrue) { + this.isTrue = isTrue; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + String prior = oraclePriorPosition == ORACLE_PRIOR_START ? "PRIOR " : ""; + if (isTrue()) { + return prior + leftExpression + " IS" + (not ? " NOT" : "") + " TRUE"; + } else { + return prior + leftExpression + " IS" + (not ? " NOT" : "") + " FALSE"; + } + } + + public IsBooleanExpression withIsTrue(boolean isTrue) { + this.setIsTrue(isTrue); + return this; + } + + public IsBooleanExpression withLeftExpression(Expression leftExpression) { + this.setLeftExpression(leftExpression); + return this; + } + + public IsBooleanExpression withNot(boolean not) { + this.setNot(not); + return this; + } + + public E getLeftExpression(Class type) { + return type.cast(getLeftExpression()); + } + + private int oraclePriorPosition = NO_ORACLE_PRIOR; + + @Override + public int getOldOracleJoinSyntax() { + return NO_ORACLE_JOIN; + } + + @Override + public void setOldOracleJoinSyntax(int oldOracleJoinSyntax) { + throw new IllegalArgumentException( + "oracle join operator (+) is not supported on this condition"); + } + + @Override + public IsBooleanExpression withOldOracleJoinSyntax(int oldOracleJoinSyntax) { + setOldOracleJoinSyntax(oldOracleJoinSyntax); + return this; + } + + @Override + public int getOraclePriorPosition() { + return oraclePriorPosition; + } + + @Override + public void setOraclePriorPosition(int oraclePriorPosition) { + this.oraclePriorPosition = oraclePriorPosition; + } + + public IsBooleanExpression withOraclePriorPosition(int oraclePriorPosition) { + setOraclePriorPosition(oraclePriorPosition); + return this; + } + +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsDistinctExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsDistinctExpression.java new file mode 100644 index 0000000000..12bc3027cd --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsDistinctExpression.java @@ -0,0 +1,78 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class IsDistinctExpression extends BinaryExpression implements SupportsOldOracleJoinSyntax { + + private boolean not = false; + + public boolean isNot() { + return not; + } + + public void setNot(boolean b) { + not = b; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return " IS " + (isNot() ? "NOT " : "") + "DISTINCT FROM "; + } + + @Override + public String toString() { + String retval = (oraclePriorPosition == ORACLE_PRIOR_START ? "PRIOR " : "") + + getLeftExpression() + getStringExpression() + getRightExpression(); + return retval; + } + + private int oraclePriorPosition = NO_ORACLE_PRIOR; + + @Override + public int getOldOracleJoinSyntax() { + return NO_ORACLE_JOIN; + } + + @Override + public void setOldOracleJoinSyntax(int oldOracleJoinSyntax) { + throw new IllegalArgumentException( + "oracle join operator (+) is not supported on this condition"); + } + + @Override + public IsDistinctExpression withOldOracleJoinSyntax(int oldOracleJoinSyntax) { + setOldOracleJoinSyntax(oldOracleJoinSyntax); + return this; + } + + @Override + public int getOraclePriorPosition() { + return oraclePriorPosition; + } + + @Override + public void setOraclePriorPosition(int oraclePriorPosition) { + this.oraclePriorPosition = oraclePriorPosition; + } + + public IsDistinctExpression withOraclePriorPosition(int oraclePriorPosition) { + setOraclePriorPosition(oraclePriorPosition); + return this; + } + +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsJsonExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsJsonExpression.java new file mode 100644 index 0000000000..e70b0bdd2d --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsJsonExpression.java @@ -0,0 +1,98 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import java.util.function.Consumer; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** SQL/JSON type and key uniqueness predicate; the JSON value is not evaluated by the parser. */ +public class IsJsonExpression extends ASTNodeAccessImpl implements Expression { + public enum Type { + VALUE, SCALAR, ARRAY, OBJECT + } + + public enum UniqueKeys { + WITH, WITHOUT + } + + private Expression leftExpression; + private boolean not; + private Type type; + private UniqueKeys uniqueKeys; + private boolean useKeysKeyword = true; + + public Expression getLeftExpression() { + return leftExpression; + } + + public void setLeftExpression(Expression leftExpression) { + this.leftExpression = leftExpression; + } + + public boolean isNot() { + return not; + } + + public void setNot(boolean not) { + this.not = not; + } + + public Type getType() { + return type; + } + + public void setType(Type type) { + this.type = type; + } + + public UniqueKeys getUniqueKeys() { + return uniqueKeys; + } + + public void setUniqueKeys(UniqueKeys uniqueKeys) { + this.uniqueKeys = uniqueKeys; + } + + public boolean isUseKeysKeyword() { + return useKeysKeyword; + } + + public void setUseKeysKeyword(boolean useKeysKeyword) { + this.useKeysKeyword = useKeysKeyword; + } + + public StringBuilder appendTo(StringBuilder builder, Consumer expressionRenderer) { + expressionRenderer.accept(leftExpression); + builder.append(not ? " IS NOT JSON" : " IS JSON"); + if (type != null) { + builder.append(' ').append(type); + } + if (uniqueKeys != null) { + builder.append(' ').append(uniqueKeys).append(" UNIQUE"); + if (useKeysKeyword) { + builder.append(" KEYS"); + } + } + return builder; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, builder::append).toString(); + } + + @Override + public T accept(ExpressionVisitor visitor, S context) { + return visitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsNormalizedExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsNormalizedExpression.java new file mode 100644 index 0000000000..bd4593480f --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsNormalizedExpression.java @@ -0,0 +1,112 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import java.util.function.Consumer; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** + * The Unicode normalization test {@code expression IS [NOT] [NFC | NFD | NFKC | NFKD] NORMALIZED}. + */ +public class IsNormalizedExpression extends ASTNodeAccessImpl implements Expression { + /** The Unicode normalization forms. */ + public enum NormalForm { + NFC, NFD, NFKC, NFKD; + + /** Whether the word names a normalization form, in any case. */ + public static boolean isNormalForm(String word) { + for (NormalForm form : values()) { + if (form.name().equalsIgnoreCase(word)) { + return true; + } + } + return false; + } + } + + private Expression leftExpression; + private boolean not; + private NormalForm normalForm; + + public IsNormalizedExpression() { + // empty constructor + } + + public IsNormalizedExpression(Expression leftExpression) { + this.leftExpression = leftExpression; + } + + public Expression getLeftExpression() { + return leftExpression; + } + + public void setLeftExpression(Expression leftExpression) { + this.leftExpression = leftExpression; + } + + public IsNormalizedExpression withLeftExpression(Expression leftExpression) { + this.setLeftExpression(leftExpression); + return this; + } + + public E getLeftExpression(Class type) { + return type.cast(getLeftExpression()); + } + + public boolean isNot() { + return not; + } + + public void setNot(boolean not) { + this.not = not; + } + + public IsNormalizedExpression withNot(boolean not) { + this.setNot(not); + return this; + } + + /** The normalization form as written, or null when it is omitted (the server tests NFC). */ + public NormalForm getNormalForm() { + return normalForm; + } + + public void setNormalForm(NormalForm normalForm) { + this.normalForm = normalForm; + } + + public IsNormalizedExpression withNormalForm(NormalForm normalForm) { + this.setNormalForm(normalForm); + return this; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + /** Appends the test, rendering the operand through the renderer. */ + public StringBuilder appendTo(StringBuilder builder, Consumer expressionRenderer) { + expressionRenderer.accept(leftExpression); + builder.append(not ? " IS NOT " : " IS "); + if (normalForm != null) { + builder.append(normalForm).append(' '); + } + return builder.append("NORMALIZED"); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, builder::append).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsNullExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsNullExpression.java index 15080a16cd..f044c436ae 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsNullExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsNullExpression.java @@ -1,57 +1,139 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.schema.Column; -public class IsNullExpression implements Expression { +public class IsNullExpression extends ASTNodeAccessImpl + implements Expression, SupportsOldOracleJoinSyntax { - private Expression leftExpression; - private boolean not = false; + private Expression leftExpression; + private boolean not = false; + private boolean useIsNull = false; + private boolean useNotNull = false; - public Expression getLeftExpression() { - return leftExpression; - } + public IsNullExpression() {} - public boolean isNot() { - return not; - } + public IsNullExpression(Expression leftExpression) { + this.leftExpression = leftExpression; + } - public void setLeftExpression(Expression expression) { - leftExpression = expression; - } + public IsNullExpression(String columnName, boolean not) { + this.leftExpression = new Column(columnName); + this.not = not; + } - public void setNot(boolean b) { - not = b; - } + public Expression getLeftExpression() { + return leftExpression; + } - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public void setLeftExpression(Expression expression) { + leftExpression = expression; + } + + public boolean isNot() { + return not; + } + + public void setNot(boolean b) { + not = b; + } + + public boolean isUseIsNull() { + return useIsNull; + } + + public void setUseIsNull(boolean useIsNull) { + this.useIsNull = useIsNull; + } + + public boolean isUseNotNull() { + return useNotNull; + } + + public IsNullExpression setUseNotNull(boolean useNotNull) { + this.useNotNull = useNotNull; + return this; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + String prior = oraclePriorPosition == ORACLE_PRIOR_START ? "PRIOR " : ""; + if (useNotNull) { + return prior + leftExpression + " NOTNULL"; + } else if (useIsNull) { + return prior + leftExpression + (not ? " NOT" : "") + " ISNULL"; + } else { + return prior + leftExpression + " IS " + (not ? "NOT " : "") + "NULL"; + } + } + + public IsNullExpression withUseIsNull(boolean useIsNull) { + this.setUseIsNull(useIsNull); + return this; + } + + public IsNullExpression withLeftExpression(Expression leftExpression) { + this.setLeftExpression(leftExpression); + return this; + } + + public IsNullExpression withNot(boolean not) { + this.setNot(not); + return this; + } + + public E getLeftExpression(Class type) { + return type.cast(getLeftExpression()); + } + + private int oraclePriorPosition = NO_ORACLE_PRIOR; + + @Override + public int getOldOracleJoinSyntax() { + return NO_ORACLE_JOIN; + } + + @Override + public void setOldOracleJoinSyntax(int oldOracleJoinSyntax) { + throw new IllegalArgumentException( + "oracle join operator (+) is not supported on this condition"); + } + + @Override + public IsNullExpression withOldOracleJoinSyntax(int oldOracleJoinSyntax) { + setOldOracleJoinSyntax(oldOracleJoinSyntax); + return this; + } + + @Override + public int getOraclePriorPosition() { + return oraclePriorPosition; + } + + @Override + public void setOraclePriorPosition(int oraclePriorPosition) { + this.oraclePriorPosition = oraclePriorPosition; + } + + public IsNullExpression withOraclePriorPosition(int oraclePriorPosition) { + setOraclePriorPosition(oraclePriorPosition); + return this; + } - @Override - public String toString() { - return leftExpression + " IS " + ((not) ? "NOT " : "") + "NULL"; - } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsUnknownExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsUnknownExpression.java new file mode 100644 index 0000000000..06abbbcb55 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/IsUnknownExpression.java @@ -0,0 +1,97 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2025 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class IsUnknownExpression extends ASTNodeAccessImpl + implements Expression, SupportsOldOracleJoinSyntax { + + private Expression leftExpression; + private boolean isNot = false; + + public Expression getLeftExpression() { + return leftExpression; + } + + public void setLeftExpression(Expression expression) { + leftExpression = expression; + } + + public boolean isNot() { + return isNot; + } + + public void setNot(boolean isNot) { + this.isNot = isNot; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String toString() { + return (oraclePriorPosition == ORACLE_PRIOR_START ? "PRIOR " : "") + leftExpression + " IS" + + (isNot ? " NOT" : "") + " UNKNOWN"; + } + + public IsUnknownExpression withLeftExpression(Expression leftExpression) { + this.setLeftExpression(leftExpression); + return this; + } + + public IsUnknownExpression withNot(boolean isNot) { + this.setNot(isNot); + return this; + } + + public E getLeftExpression(Class type) { + return type.cast(getLeftExpression()); + } + + private int oraclePriorPosition = NO_ORACLE_PRIOR; + + @Override + public int getOldOracleJoinSyntax() { + return NO_ORACLE_JOIN; + } + + @Override + public void setOldOracleJoinSyntax(int oldOracleJoinSyntax) { + throw new IllegalArgumentException( + "oracle join operator (+) is not supported on this condition"); + } + + @Override + public IsUnknownExpression withOldOracleJoinSyntax(int oldOracleJoinSyntax) { + setOldOracleJoinSyntax(oldOracleJoinSyntax); + return this; + } + + @Override + public int getOraclePriorPosition() { + return oraclePriorPosition; + } + + @Override + public void setOraclePriorPosition(int oraclePriorPosition) { + this.oraclePriorPosition = oraclePriorPosition; + } + + public IsUnknownExpression withOraclePriorPosition(int oraclePriorPosition) { + setOraclePriorPosition(oraclePriorPosition); + return this; + } + +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/ItemsList.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/ItemsList.java deleted file mode 100644 index 6b9d7f1973..0000000000 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/ItemsList.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * #%L - * JSQLParser library - * %% - * Copyright (C) 2004 - 2013 JSQLParser - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . - * #L% - */ -package net.sf.jsqlparser.expression.operators.relational; - -/** - * Values of an "INSERT" statement (for example a SELECT or a list of - * expressions) - */ -public interface ItemsList { - - void accept(ItemsListVisitor itemsListVisitor); -} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/ItemsListVisitor.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/ItemsListVisitor.java deleted file mode 100644 index a7e30a984e..0000000000 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/ItemsListVisitor.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * #%L - * JSQLParser library - * %% - * Copyright (C) 2004 - 2013 JSQLParser - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . - * #L% - */ -package net.sf.jsqlparser.expression.operators.relational; - -import net.sf.jsqlparser.statement.select.SubSelect; - -public interface ItemsListVisitor { - - void visit(SubSelect subSelect); - - void visit(ExpressionList expressionList); - - void visit(MultiExpressionList multiExprList); -} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/ItemsListVisitorAdapter.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/ItemsListVisitorAdapter.java deleted file mode 100644 index 19c995069f..0000000000 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/ItemsListVisitorAdapter.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * #%L - * JSQLParser library - * %% - * Copyright (C) 2004 - 2013 JSQLParser - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . - * #L% - */ -package net.sf.jsqlparser.expression.operators.relational; - -import net.sf.jsqlparser.statement.select.SubSelect; - -public class ItemsListVisitorAdapter implements ItemsListVisitor{ - @Override - public void visit(SubSelect subSelect) { - - } - - @Override - public void visit(ExpressionList expressionList) { - - } - - @Override - public void visit(MultiExpressionList multiExprList) { - for (ExpressionList list : multiExprList.getExprList()) { - visit(list); - } - } -} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/JsonOperator.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/JsonOperator.java new file mode 100644 index 0000000000..94237e8f6c --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/JsonOperator.java @@ -0,0 +1,43 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class JsonOperator extends BinaryExpression { + + private String op; // "@>" + + public JsonOperator(String op) { + this.op = op; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return op; + } + + @Override + public JsonOperator withLeftExpression(Expression arg0) { + return (JsonOperator) super.withLeftExpression(arg0); + } + + @Override + public JsonOperator withRightExpression(Expression arg0) { + return (JsonOperator) super.withRightExpression(arg0); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/LikeExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/LikeExpression.java index 2aa58d623f..125e38a825 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/LikeExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/LikeExpression.java @@ -1,68 +1,220 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; +import java.util.Locale; +import java.util.regex.Pattern; import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; -public class LikeExpression extends BinaryExpression { +public class LikeExpression extends BinaryExpression implements SupportsOldOracleJoinSyntax { + private boolean not = false; + private boolean useBinary = false; + private Expression escapeExpression = null; + private boolean useOperator = false; + private KeyWord likeKeyWord = KeyWord.LIKE; - private boolean not = false; - private String escape = null; + public boolean isNot() { + return not; + } - @Override - public boolean isNot() { - return not; - } + public void setNot(boolean b) { + not = b; + } - public void setNot(boolean b) { - not = b; - } + public boolean isUseBinary() { + return useBinary; + } - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public LikeExpression setUseBinary(boolean useBinary) { + this.useBinary = useBinary; + return this; + } - @Override - public String getStringExpression() { - return ((not) ? "NOT " : "") + "LIKE"; - } + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } - @Override - public String toString() { - String retval = super.toString(); - if (escape != null) { - retval += " ESCAPE " + "'" + escape + "'"; - } + @Deprecated + @Override + public String getStringExpression() { + return likeKeyWord.toString(); + } - return retval; - } + /** + * The operator spelling of this condition when it was written as one and has one, e.g. + * {@code !~~} for {@code NOT LIKE}; otherwise {@code null} and the keyword form is used. + */ + public String getLikeOperator() { + if (!useOperator) { + return null; + } + switch (likeKeyWord) { + case LIKE: + return not ? "!~~" : "~~"; + case ILIKE: + return not ? "!~~*" : "~~*"; + case GLOB: + return not ? null : "~~~"; + default: + return null; + } + } - public String getEscape() { - return escape; - } + /** + * Sets the keyword and {@code NOT} from DuckDB's and PostgreSQL's operator spelling: {@code ~~} + * is {@code LIKE}, {@code ~~*} {@code ILIKE}, {@code ~~~} {@code GLOB}, and a leading {@code !} + * negates the first two. The operator is printed while it matches the keyword and {@code NOT}. + */ + public LikeExpression setLikeOperator(String likeOperator) { + if (likeOperator == null) { + throw new IllegalArgumentException("The LIKE operator must not be null"); + } + switch (likeOperator) { + case "~~": + case "!~~": + likeKeyWord = KeyWord.LIKE; + break; + case "~~*": + case "!~~*": + likeKeyWord = KeyWord.ILIKE; + break; + case "~~~": + likeKeyWord = KeyWord.GLOB; + break; + default: + throw new IllegalArgumentException("Unknown LIKE operator: " + likeOperator); + } + this.not = likeOperator.startsWith("!"); + this.useOperator = true; + return this; + } + + @Override + public String toString() { + String likeOperator = getLikeOperator(); + String retval = (oraclePriorPosition == ORACLE_PRIOR_START ? "PRIOR " : "") + + getLeftExpression() + " " + + (likeOperator != null ? likeOperator + : (not ? "NOT " : "") + + (likeKeyWord == KeyWord.SIMILAR_TO ? "SIMILAR TO" : likeKeyWord)) + + " " + (useBinary ? "BINARY " : "") + getRightExpression(); + if (escapeExpression != null) { + retval += " ESCAPE " + escapeExpression; + } + return retval; + } + + public Expression getEscape() { + return escapeExpression; + } + + public void setEscape(Expression escapeExpression) { + this.escapeExpression = escapeExpression; + } + + @Deprecated + public boolean isCaseInsensitive() { + return likeKeyWord == KeyWord.ILIKE; + } + + @Deprecated + public void setCaseInsensitive(boolean caseInsensitive) { + this.likeKeyWord = KeyWord.ILIKE; + } + + public KeyWord getLikeKeyWord() { + return likeKeyWord; + } + + public LikeExpression setLikeKeyWord(KeyWord likeKeyWord) { + this.likeKeyWord = likeKeyWord; + return this; + } + + public LikeExpression setLikeKeyWord(String likeKeyWord) { + this.likeKeyWord = KeyWord.from(likeKeyWord); + return this; + } + + public LikeExpression withEscape(Expression escape) { + this.setEscape(escape); + return this; + } + + @Deprecated + public LikeExpression withCaseInsensitive(boolean caseInsensitive) { + this.setCaseInsensitive(caseInsensitive); + return this; + } + + public LikeExpression withNot(boolean not) { + this.setNot(not); + return this; + } + + @Override + public LikeExpression withLeftExpression(Expression arg0) { + return (LikeExpression) super.withLeftExpression(arg0); + } + + @Override + public LikeExpression withRightExpression(Expression arg0) { + return (LikeExpression) super.withRightExpression(arg0); + } + + public enum KeyWord { + LIKE, ILIKE, RLIKE, REGEXP_LIKE, REGEXP, GLOB, SIMILAR_TO, MATCH_ANY, MATCH_ALL, MATCH_PHRASE, MATCH_PHRASE_PREFIX, MATCH_REGEXP; + + private static final Pattern WHITESPACE = Pattern.compile("\\s+"); + + public static KeyWord from(String keyword) { + return Enum.valueOf(KeyWord.class, + WHITESPACE.matcher(keyword.toUpperCase(Locale.ROOT)).replaceAll("_")); + } + } + + private int oraclePriorPosition = NO_ORACLE_PRIOR; + + @Override + public int getOldOracleJoinSyntax() { + return NO_ORACLE_JOIN; + } + + @Override + public void setOldOracleJoinSyntax(int oldOracleJoinSyntax) { + throw new IllegalArgumentException( + "oracle join operator (+) is not supported on this condition"); + } + + @Override + public LikeExpression withOldOracleJoinSyntax(int oldOracleJoinSyntax) { + setOldOracleJoinSyntax(oldOracleJoinSyntax); + return this; + } + + @Override + public int getOraclePriorPosition() { + return oraclePriorPosition; + } + + @Override + public void setOraclePriorPosition(int oraclePriorPosition) { + this.oraclePriorPosition = oraclePriorPosition; + } + + public LikeExpression withOraclePriorPosition(int oraclePriorPosition) { + setOraclePriorPosition(oraclePriorPosition); + return this; + } - public void setEscape(String escape) { - this.escape = escape; - } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/Matches.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/Matches.java index 1dda83cb9d..1388fa51fd 100755 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/Matches.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/Matches.java @@ -1,37 +1,46 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; public class Matches extends OldOracleJoinBinaryExpression { - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } - @Override - public String getStringExpression() { - return "@@"; - } + @Override + public String getStringExpression() { + return "@@"; + } + + @Override + public Matches withLeftExpression(Expression arg0) { + return (Matches) super.withLeftExpression(arg0); + } + + @Override + public Matches withRightExpression(Expression arg0) { + return (Matches) super.withRightExpression(arg0); + } + + @Override + public Matches withOldOracleJoinSyntax(int oldOracleJoinSyntax) { + return (Matches) super.withOldOracleJoinSyntax(oldOracleJoinSyntax); + } + + @Override + public Matches withOraclePriorPosition(int oraclePriorPosition) { + return (Matches) super.withOraclePriorPosition(oraclePriorPosition); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/MemberOfExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/MemberOfExpression.java new file mode 100644 index 0000000000..87a54dd072 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/MemberOfExpression.java @@ -0,0 +1,100 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2023 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class MemberOfExpression extends ASTNodeAccessImpl + implements Expression, SupportsOldOracleJoinSyntax { + + Expression leftExpression; + Expression rightExpression; + boolean isNot; + + public MemberOfExpression(Expression leftExpression, Expression rightExpression) { + this.leftExpression = leftExpression; + this.rightExpression = rightExpression; + } + + public Expression getLeftExpression() { + return leftExpression; + } + + public MemberOfExpression setLeftExpression(Expression leftExpression) { + this.leftExpression = leftExpression; + return this; + } + + public Expression getRightExpression() { + return rightExpression; + } + + public MemberOfExpression setRightExpression(Expression rightExpression) { + this.rightExpression = rightExpression; + return this; + } + + public boolean isNot() { + return isNot; + } + + public MemberOfExpression setNot(boolean not) { + isNot = not; + return this; + } + + @Override + public String toString() { + return (oraclePriorPosition == ORACLE_PRIOR_START ? "PRIOR " : "") + leftExpression + + " MEMBER OF " + rightExpression; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + private int oraclePriorPosition = NO_ORACLE_PRIOR; + + @Override + public int getOldOracleJoinSyntax() { + return NO_ORACLE_JOIN; + } + + @Override + public void setOldOracleJoinSyntax(int oldOracleJoinSyntax) { + throw new IllegalArgumentException( + "oracle join operator (+) is not supported on this condition"); + } + + @Override + public MemberOfExpression withOldOracleJoinSyntax(int oldOracleJoinSyntax) { + setOldOracleJoinSyntax(oldOracleJoinSyntax); + return this; + } + + @Override + public int getOraclePriorPosition() { + return oraclePriorPosition; + } + + @Override + public void setOraclePriorPosition(int oraclePriorPosition) { + this.oraclePriorPosition = oraclePriorPosition; + } + + public MemberOfExpression withOraclePriorPosition(int oraclePriorPosition) { + setOraclePriorPosition(oraclePriorPosition); + return this; + } + +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/MinorThan.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/MinorThan.java index b0879b0cd4..3f6ddd2674 100755 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/MinorThan.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/MinorThan.java @@ -1,37 +1,49 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; -public class MinorThan extends OldOracleJoinBinaryExpression { +public class MinorThan extends ComparisonOperator { - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public MinorThan() { + super("<"); + } - @Override - public String getStringExpression() { - return "<"; - } + public MinorThan(Expression leftExpression, Expression rightExpression) { + super("<", leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public MinorThan withLeftExpression(Expression arg0) { + return (MinorThan) super.withLeftExpression(arg0); + } + + @Override + public MinorThan withRightExpression(Expression arg0) { + return (MinorThan) super.withRightExpression(arg0); + } + + @Override + public MinorThan withOldOracleJoinSyntax(int arg0) { + return (MinorThan) super.withOldOracleJoinSyntax(arg0); + } + + @Override + public MinorThan withOraclePriorPosition(int arg0) { + return (MinorThan) super.withOraclePriorPosition(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/MinorThanEquals.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/MinorThanEquals.java index 1703252799..5318a0d274 100755 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/MinorThanEquals.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/MinorThanEquals.java @@ -1,37 +1,53 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; -public class MinorThanEquals extends OldOracleJoinBinaryExpression { +public class MinorThanEquals extends ComparisonOperator { - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } + public MinorThanEquals() { + super("<="); + } - @Override - public String getStringExpression() { - return "<="; - } + public MinorThanEquals(String operator) { + super(operator); + } + + public MinorThanEquals(Expression leftExpression, Expression rightExpression) { + super("<=", leftExpression, rightExpression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public MinorThanEquals withLeftExpression(Expression arg0) { + return (MinorThanEquals) super.withLeftExpression(arg0); + } + + @Override + public MinorThanEquals withRightExpression(Expression arg0) { + return (MinorThanEquals) super.withRightExpression(arg0); + } + + @Override + public MinorThanEquals withOldOracleJoinSyntax(int arg0) { + return (MinorThanEquals) super.withOldOracleJoinSyntax(arg0); + } + + @Override + public MinorThanEquals withOraclePriorPosition(int arg0) { + return (MinorThanEquals) super.withOraclePriorPosition(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/MultiExpressionList.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/MultiExpressionList.java deleted file mode 100644 index 1e3d396400..0000000000 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/MultiExpressionList.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * #%L - * JSQLParser library - * %% - * Copyright (C) 2004 - 2013 JSQLParser - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . - * #L% - */ -package net.sf.jsqlparser.expression.operators.relational; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import net.sf.jsqlparser.expression.Expression; - -/** - * A list of ExpressionList items. e.g. multi values of insert statements. This - * one allows only equally sized ExpressionList. - * - * @author toben - */ -public class MultiExpressionList implements ItemsList { - - private List exprList; - - public MultiExpressionList() { - this.exprList = new ArrayList(); - } - - @Override - public void accept(ItemsListVisitor itemsListVisitor) { - itemsListVisitor.visit(this); - } - - public List getExprList() { - return exprList; - } - - public void addExpressionList(ExpressionList el) { - if (!exprList.isEmpty() - && exprList.get(0).getExpressions().size() != el.getExpressions().size()) { - throw new IllegalArgumentException("different count of parameters"); - } - exprList.add(el); - } - - public void addExpressionList(List list) { - addExpressionList(new ExpressionList(list)); - } - - public void addExpressionList(Expression expr) { - addExpressionList(new ExpressionList(Arrays.asList(expr))); - } - - @Override - public String toString() { - StringBuilder b = new StringBuilder(); - for (Iterator it = exprList.iterator(); it.hasNext();) { - b.append(it.next().toString()); - if (it.hasNext()) { - b.append(", "); - } - } - return b.toString(); - } -} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/NamedExpressionList.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/NamedExpressionList.java new file mode 100644 index 0000000000..e7473cf0dc --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/NamedExpressionList.java @@ -0,0 +1,70 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.Expression; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +/** + * A list of named expressions, as in as in select substr('xyzzy' from 2 for 3) + */ +public class NamedExpressionList extends ExpressionList { + private List names; + + public List getNames() { + return names; + } + + public void setNames(List list) { + names = list; + } + + @Override + public String toString() { + + StringBuilder ret = new StringBuilder(); + ret.append("("); + for (int i = 0; i < size(); i++) { + if (i > 0) { + ret.append(" "); + } + if (!names.get(i).equals("")) { + ret.append(names.get(i)).append(" ").append(get(i)); + } else { + ret.append(get(i)); + } + } + ret.append(")"); + + return ret.toString(); + } + + public NamedExpressionList withNames(List names) { + this.setNames(names); + return this; + } + + public NamedExpressionList addNames(String... names) { + List collection = Optional.ofNullable(getNames()).orElseGet(ArrayList::new); + Collections.addAll(collection, names); + return this.withNames(collection); + } + + public NamedExpressionList addNames(Collection names) { + List collection = Optional.ofNullable(getNames()).orElseGet(ArrayList::new); + collection.addAll(names); + return this.withNames(collection); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/NotEqualsTo.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/NotEqualsTo.java index a327b8175c..c6e1ef3cb0 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/NotEqualsTo.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/NotEqualsTo.java @@ -1,50 +1,55 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; -public class NotEqualsTo extends OldOracleJoinBinaryExpression { - - private final String operator; +public class NotEqualsTo extends ComparisonOperator { public NotEqualsTo() { - operator = "<>"; + super("<>"); } public NotEqualsTo(String operator) { - this.operator = operator; - if (!"!=".equals(operator) && !"<>".equals(operator)) { - throw new IllegalArgumentException("only <> or != allowed"); - } + super(operator); + } + + public NotEqualsTo(Expression left, Expression right) { + this(); + setLeftExpression(left); + setRightExpression(right); + } + + @Override + public NotEqualsTo withLeftExpression(Expression expression) { + return (NotEqualsTo) super.withLeftExpression(expression); + } + + @Override + public NotEqualsTo withRightExpression(Expression expression) { + return (NotEqualsTo) super.withRightExpression(expression); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); } @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); + public NotEqualsTo withOldOracleJoinSyntax(int arg0) { + return (NotEqualsTo) super.withOldOracleJoinSyntax(arg0); } @Override - public String getStringExpression() { - return operator; + public NotEqualsTo withOraclePriorPosition(int arg0) { + return (NotEqualsTo) super.withOraclePriorPosition(arg0); } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/OldOracleJoinBinaryExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/OldOracleJoinBinaryExpression.java index f600f06156..46b093b7d7 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/OldOracleJoinBinaryExpression.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/OldOracleJoinBinaryExpression.java @@ -1,67 +1,77 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; import net.sf.jsqlparser.expression.BinaryExpression; -import static net.sf.jsqlparser.expression.operators.relational.SupportsOldOracleJoinSyntax.ORACLE_PRIOR_START; +import net.sf.jsqlparser.expression.Expression; -public abstract class OldOracleJoinBinaryExpression extends BinaryExpression implements SupportsOldOracleJoinSyntax { +public abstract class OldOracleJoinBinaryExpression extends BinaryExpression + implements SupportsOldOracleJoinSyntax { private int oldOracleJoinSyntax = NO_ORACLE_JOIN; - - private int oraclePriorPosition = NO_ORACLE_PRIOR; - @Override + private int oraclePriorPosition = NO_ORACLE_PRIOR; + + @Override + public String toString() { + return // (isNot() ? "NOT " : "") + (oraclePriorPosition == ORACLE_PRIOR_START ? "PRIOR " : "") + + getLeftExpression() + + (oldOracleJoinSyntax == ORACLE_JOIN_RIGHT ? "(+)" : "") + " " + + getStringExpression() + " " + + (oraclePriorPosition == ORACLE_PRIOR_END ? "PRIOR " : "") + + getRightExpression() + + (oldOracleJoinSyntax == ORACLE_JOIN_LEFT ? "(+)" : ""); + } + + @Override + public int getOldOracleJoinSyntax() { + return oldOracleJoinSyntax; + } + + @Override public void setOldOracleJoinSyntax(int oldOracleJoinSyntax) { this.oldOracleJoinSyntax = oldOracleJoinSyntax; if (oldOracleJoinSyntax < 0 || oldOracleJoinSyntax > 2) { - throw new IllegalArgumentException("unknown join type for oracle found (type=" + oldOracleJoinSyntax + ")"); + throw new IllegalArgumentException( + "unknown join type for oracle found (type=" + oldOracleJoinSyntax + ")"); } } @Override - public String toString() { - return (isNot() ? "NOT " : "") - + (oraclePriorPosition == ORACLE_PRIOR_START ? "PRIOR " : "") - + getLeftExpression() - + (oldOracleJoinSyntax == ORACLE_JOIN_RIGHT ? "(+)" : "") + " " - + getStringExpression() + " " - + (oraclePriorPosition == ORACLE_PRIOR_END ? "PRIOR " : "") - + getRightExpression() - + (oldOracleJoinSyntax == ORACLE_JOIN_LEFT ? "(+)" : ""); + public int getOraclePriorPosition() { + return oraclePriorPosition; } - @Override - public int getOldOracleJoinSyntax() { - return oldOracleJoinSyntax; + @Override + public void setOraclePriorPosition(int oraclePriorPosition) { + this.oraclePriorPosition = oraclePriorPosition; } - @Override - public int getOraclePriorPosition() { - return oraclePriorPosition; - } + public OldOracleJoinBinaryExpression withOldOracleJoinSyntax(int oldOracleJoinSyntax) { + this.setOldOracleJoinSyntax(oldOracleJoinSyntax); + return this; + } + + public OldOracleJoinBinaryExpression withOraclePriorPosition(int oraclePriorPosition) { + this.setOraclePriorPosition(oraclePriorPosition); + return this; + } - @Override - public void setOraclePriorPosition(int oraclePriorPosition) { - this.oraclePriorPosition = oraclePriorPosition; - } + @Override + public OldOracleJoinBinaryExpression withLeftExpression(Expression arg0) { + return (OldOracleJoinBinaryExpression) super.withLeftExpression(arg0); + } + + @Override + public OldOracleJoinBinaryExpression withRightExpression(Expression arg0) { + return (OldOracleJoinBinaryExpression) super.withRightExpression(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/ParenthesedExpressionList.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/ParenthesedExpressionList.java new file mode 100644 index 0000000000..dc71ea6ad6 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/ParenthesedExpressionList.java @@ -0,0 +1,42 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2023 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.statement.select.PlainSelect; + +import java.util.Arrays; +import java.util.Collection; + +public class ParenthesedExpressionList extends ExpressionList { + public ParenthesedExpressionList() {} + + public ParenthesedExpressionList(ExpressionList expressions) { + addAll(expressions); + } + + @SafeVarargs + public ParenthesedExpressionList(T... expressions) { + addAll(Arrays.asList(expressions)); + } + + public ParenthesedExpressionList(Collection expressions) { + addAll(expressions); + } + + public static ParenthesedExpressionList from(ExpressionList expressions) { + return new ParenthesedExpressionList<>(expressions); + } + + @Override + public String toString() { + return PlainSelect.getStringList(this, true, true); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/Plus.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/Plus.java new file mode 100644 index 0000000000..e3362d950d --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/Plus.java @@ -0,0 +1,30 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class Plus extends BinaryExpression { + public Plus(Expression leftExpression, Expression rightExpression) { + super(leftExpression, rightExpression); + } + + @Override + public String getStringExpression() { + return "PLUS"; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/PriorTo.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/PriorTo.java new file mode 100644 index 0000000000..267f158fdc --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/PriorTo.java @@ -0,0 +1,30 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class PriorTo extends BinaryExpression { + public PriorTo(Expression leftExpression, Expression rightExpression) { + super(leftExpression, rightExpression); + } + + @Override + public String getStringExpression() { + return "PRIOR TO"; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/RegExpMatchOperator.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/RegExpMatchOperator.java index b2d0c42234..786f60407d 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/RegExpMatchOperator.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/RegExpMatchOperator.java @@ -1,61 +1,62 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; +import java.util.Objects; + import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.ExpressionVisitor; public class RegExpMatchOperator extends BinaryExpression { - private RegExpMatchOperatorType operatorType; - - public RegExpMatchOperator(RegExpMatchOperatorType operatorType) { - if (operatorType == null) { - throw new NullPointerException(); - } - this.operatorType = operatorType; - } - - public RegExpMatchOperatorType getOperatorType() { - return operatorType; - } - - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } - - @Override - public String getStringExpression() { - switch (operatorType) { - case MATCH_CASESENSITIVE: - return "~"; - case MATCH_CASEINSENSITIVE: - return "~*"; - case NOT_MATCH_CASESENSITIVE: - return "!~"; - case NOT_MATCH_CASEINSENSITIVE: - return "!~*"; - } - return null; - } + private RegExpMatchOperatorType operatorType; + + public RegExpMatchOperator(RegExpMatchOperatorType operatorType) { + this.operatorType = Objects.requireNonNull(operatorType, + "The provided RegExpMatchOperatorType must not be NULL."); + } + + public RegExpMatchOperatorType getOperatorType() { + return operatorType; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + switch (operatorType) { + case MATCH_CASESENSITIVE: + return "~"; + case MATCH_CASEINSENSITIVE: + return "~*"; + case NOT_MATCH_CASESENSITIVE: + return "!~"; + case NOT_MATCH_CASEINSENSITIVE: + return "!~*"; + default: + break; + } + return null; + } + + @Override + public RegExpMatchOperator withLeftExpression(Expression arg0) { + return (RegExpMatchOperator) super.withLeftExpression(arg0); + } + + @Override + public RegExpMatchOperator withRightExpression(Expression arg0) { + return (RegExpMatchOperator) super.withRightExpression(arg0); + } } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/RegExpMatchOperatorType.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/RegExpMatchOperatorType.java index 92bfeb9411..c22f05eeed 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/RegExpMatchOperatorType.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/RegExpMatchOperatorType.java @@ -1,33 +1,17 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2014 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; /** * PostgresSQL match operators. - * @author toben */ public enum RegExpMatchOperatorType { - MATCH_CASESENSITIVE, - MATCH_CASEINSENSITIVE, - NOT_MATCH_CASESENSITIVE, - NOT_MATCH_CASEINSENSITIVE + MATCH_CASESENSITIVE, MATCH_CASEINSENSITIVE, NOT_MATCH_CASESENSITIVE, NOT_MATCH_CASEINSENSITIVE } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/RegExpMySQLOperator.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/RegExpMySQLOperator.java deleted file mode 100644 index 615eb302d8..0000000000 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/RegExpMySQLOperator.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * #%L - * JSQLParser library - * %% - * Copyright (C) 2004 - 2014 JSQLParser - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . - * #L% - */ -package net.sf.jsqlparser.expression.operators.relational; - -import net.sf.jsqlparser.expression.BinaryExpression; -import net.sf.jsqlparser.expression.ExpressionVisitor; - -public class RegExpMySQLOperator extends BinaryExpression { - - private RegExpMatchOperatorType operatorType; - - public RegExpMySQLOperator(RegExpMatchOperatorType operatorType) { - if (operatorType == null) { - throw new NullPointerException(); - } - this.operatorType = operatorType; - } - - public RegExpMatchOperatorType getOperatorType() { - return operatorType; - } - - @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); - } - - @Override - public String getStringExpression() { - switch (operatorType) { - case MATCH_CASESENSITIVE: - return "REGEXP BINARY"; - case MATCH_CASEINSENSITIVE: - return "REGEXP"; - default: - } - return null; - } -} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/SimilarToExpression.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/SimilarToExpression.java new file mode 100644 index 0000000000..fbb50f25d5 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/SimilarToExpression.java @@ -0,0 +1,113 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.BinaryExpression; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class SimilarToExpression extends BinaryExpression implements SupportsOldOracleJoinSyntax { + + private boolean not = false; + private String escape = null; + + public boolean isNot() { + return not; + } + + public void setNot(boolean b) { + not = b; + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } + + @Override + public String getStringExpression() { + return "SIMILAR TO"; + } + + @Override + public String toString() { + String retval = (oraclePriorPosition == ORACLE_PRIOR_START ? "PRIOR " : "") + + getLeftExpression() + " " + (not ? "NOT " : "") + getStringExpression() + + " " + getRightExpression(); + if (escape != null) { + retval += " ESCAPE " + "'" + escape + "'"; + } + + return retval; + } + + public String getEscape() { + return escape; + } + + public void setEscape(String escape) { + this.escape = escape; + } + + public SimilarToExpression withEscape(String escape) { + this.setEscape(escape); + return this; + } + + public SimilarToExpression withNot(boolean not) { + this.setNot(not); + return this; + } + + @Override + public SimilarToExpression withLeftExpression(Expression arg0) { + return (SimilarToExpression) super.withLeftExpression(arg0); + } + + @Override + public SimilarToExpression withRightExpression(Expression arg0) { + return (SimilarToExpression) super.withRightExpression(arg0); + } + + private int oraclePriorPosition = NO_ORACLE_PRIOR; + + @Override + public int getOldOracleJoinSyntax() { + return NO_ORACLE_JOIN; + } + + @Override + public void setOldOracleJoinSyntax(int oldOracleJoinSyntax) { + throw new IllegalArgumentException( + "oracle join operator (+) is not supported on this condition"); + } + + @Override + public SimilarToExpression withOldOracleJoinSyntax(int oldOracleJoinSyntax) { + setOldOracleJoinSyntax(oldOracleJoinSyntax); + return this; + } + + @Override + public int getOraclePriorPosition() { + return oraclePriorPosition; + } + + @Override + public void setOraclePriorPosition(int oraclePriorPosition) { + this.oraclePriorPosition = oraclePriorPosition; + } + + public SimilarToExpression withOraclePriorPosition(int oraclePriorPosition) { + setOraclePriorPosition(oraclePriorPosition); + return this; + } + +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/SupportsOldOracleJoinSyntax.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/SupportsOldOracleJoinSyntax.java index 26144e99e2..9b8777dcc4 100644 --- a/src/main/java/net/sf/jsqlparser/expression/operators/relational/SupportsOldOracleJoinSyntax.java +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/SupportsOldOracleJoinSyntax.java @@ -1,41 +1,32 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.expression.operators.relational; public interface SupportsOldOracleJoinSyntax { - int NO_ORACLE_JOIN = 0; - int ORACLE_JOIN_RIGHT = 1; - int ORACLE_JOIN_LEFT = 2; + int NO_ORACLE_JOIN = 0; + int ORACLE_JOIN_RIGHT = 1; + int ORACLE_JOIN_LEFT = 2; + int NO_ORACLE_PRIOR = 0; + int ORACLE_PRIOR_START = 1; + int ORACLE_PRIOR_END = 2; - int getOldOracleJoinSyntax(); + int getOldOracleJoinSyntax(); - void setOldOracleJoinSyntax(int oldOracleJoinSyntax); + void setOldOracleJoinSyntax(int oldOracleJoinSyntax); - int NO_ORACLE_PRIOR = 0; - int ORACLE_PRIOR_START = 1; - int ORACLE_PRIOR_END = 2; + SupportsOldOracleJoinSyntax withOldOracleJoinSyntax(int oldOracleJoinSyntax); - int getOraclePriorPosition(); + int getOraclePriorPosition(); - void setOraclePriorPosition(int priorPosition); + void setOraclePriorPosition(int priorPosition); + + SupportsOldOracleJoinSyntax withOraclePriorPosition(int priorPosition); } diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/TSQLLeftJoin.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/TSQLLeftJoin.java new file mode 100644 index 0000000000..aa1b90e167 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/TSQLLeftJoin.java @@ -0,0 +1,24 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class TSQLLeftJoin extends ComparisonOperator { + + public TSQLLeftJoin() { + super("*="); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/expression/operators/relational/TSQLRightJoin.java b/src/main/java/net/sf/jsqlparser/expression/operators/relational/TSQLRightJoin.java new file mode 100644 index 0000000000..fcb3e9dc44 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/expression/operators/relational/TSQLRightJoin.java @@ -0,0 +1,24 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.expression.operators.relational; + +import net.sf.jsqlparser.expression.ExpressionVisitor; + +public class TSQLRightJoin extends ComparisonOperator { + + public TSQLRightJoin() { + super("=*"); + } + + @Override + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/parser/ASTNodeAccess.java b/src/main/java/net/sf/jsqlparser/parser/ASTNodeAccess.java new file mode 100644 index 0000000000..53eb89bb75 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/parser/ASTNodeAccess.java @@ -0,0 +1,19 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.parser; + +import java.io.Serializable; + +public interface ASTNodeAccess extends Serializable { + + Node getASTNode(); + + void setASTNode(Node node); +} diff --git a/src/main/java/net/sf/jsqlparser/parser/ASTNodeAccessImpl.java b/src/main/java/net/sf/jsqlparser/parser/ASTNodeAccessImpl.java new file mode 100644 index 0000000000..3a1ad53294 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/parser/ASTNodeAccessImpl.java @@ -0,0 +1,94 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.parser; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +public class ASTNodeAccessImpl implements ASTNodeAccess { + + private transient Node node; + + @Override + public Node getASTNode() { + return node; + } + + @Override + public void setASTNode(Node node) { + this.node = node; + } + + /** + * The comments preceding this node's first token, in source order, with the original token + * images. Line comments do not include their line terminator; callers must add a line break + * when prepending them to SQL. Empty for nodes built programmatically, which carry no AST. + */ + public List getLeadingComments() { + Node node = getASTNode(); + if (node == null) { + return new ArrayList<>(); + } + List comments = new ArrayList<>(); + for (Token specialToken = + node.jjtGetFirstToken().specialToken; specialToken != null; specialToken = + specialToken.specialToken) { + comments.add(specialToken.image); + } + Collections.reverse(comments); + return comments; + } + + public StringBuilder appendTo(StringBuilder builder) { + // don't add spaces around the following punctuation + final Set punctuation = new TreeSet<>(Set.of(".", "[", "]")); + + Node Node = getASTNode(); + if (Node != null) { + Token token = Node.jjtGetFirstToken(); + Token lastToken = Node.jjtGetLastToken(); + Token prevToken = null; + while (token.next != null && token.absoluteEnd <= lastToken.absoluteEnd) { + if (!punctuation.contains(token.image) + && (prevToken == null || !punctuation.contains(prevToken.image))) { + builder.append(" "); + } + builder.append(token.image); + prevToken = token; + token = token.next; + } + } + return builder; + } + + /** + * The nearest enclosing object in the tree, or null when there is none. A node that carries + * only a token range, for an object no grammar rule opens a tree node for, has no parent. + */ + public ASTNodeAccess getParent() { + return getParent(ASTNodeAccess.class); + } + + public T getParent(Class clazz) { + Node parent = node == null ? null : (Node) node.jjtGetParent(); + while (parent != null && !clazz.isInstance(parent.jjtGetValue())) { + parent = (Node) parent.jjtGetParent(); + } + return parent == null ? null : clazz.cast(parent.jjtGetValue()); + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/parser/AbstractJSqlParser.java b/src/main/java/net/sf/jsqlparser/parser/AbstractJSqlParser.java new file mode 100644 index 0000000000..28d969ed16 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/parser/AbstractJSqlParser.java @@ -0,0 +1,321 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2020 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.parser; + +import net.sf.jsqlparser.parser.feature.Feature; +import net.sf.jsqlparser.parser.feature.FeatureConfiguration; +import net.sf.jsqlparser.statement.update.UpdateConflictAlgorithm; +import net.sf.jsqlparser.statement.upsert.UpsertType; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Arrays; +import java.util.EnumSet; +import java.util.List; +import java.util.Set; + +public abstract class AbstractJSqlParser

{ + + protected int jdbcParameterIndex = 0; + protected boolean errorRecovery = false; + protected List parseErrors = new ArrayList<>(); + + public enum AdjacentStringLiterals { + OFF, NEWLINE, WHITESPACE + } + + public enum Dialect { + ANSI_SQL(AdjacentStringLiterals.NEWLINE), ORACLE, MYSQL(AdjacentStringLiterals.OFF, + Feature.allowBackslashEscapeCharacter, + Feature.allowHashLineComments, + Feature.allowDoubleQuotedStrings), MARIADB(AdjacentStringLiterals.OFF, + Feature.allowBackslashEscapeCharacter, + Feature.allowHashLineComments, + Feature.allowDoubleQuotedStrings), SQLSERVER(AdjacentStringLiterals.OFF, + Feature.allowSquareBracketQuotation), POSTGRESQL( + AdjacentStringLiterals.NEWLINE, + Feature.allowDollarQuotedStringTags, + Feature.allowDigitSeparators), H2, EXASOL, BIGQUERY( + AdjacentStringLiterals.WHITESPACE, + Feature.allowDoubleQuotedStrings, + Feature.allowHashLineComments, + Feature.allowBackslashEscapeCharacter), DATABRICKS( + AdjacentStringLiterals.WHITESPACE, + Feature.allowDoubleQuotedStrings, + Feature.allowBackslashEscapeCharacter), SNOWFLAKE( + Feature.allowBackslashEscapeCharacter), INFORMIX, SPANNER, DORIS, COCKROACHDB, TERADATA, SQLITE; + + private final Set lexerFeatures; + private final AdjacentStringLiterals adjacentStringLiterals; + + Dialect(AdjacentStringLiterals adjacentStringLiterals, Feature... lexerFeatures) { + this.adjacentStringLiterals = adjacentStringLiterals; + this.lexerFeatures = lexerFeatures.length == 0 ? EnumSet.noneOf(Feature.class) + : EnumSet.copyOf(Arrays.asList(lexerFeatures)); + } + + Dialect(Feature... lexerFeatures) { + this(AdjacentStringLiterals.OFF, lexerFeatures); + } + + /** Returns the immutable lexer defaults shared by this dialect preset. */ + public Set getLexerFeatures() { + return Collections.unmodifiableSet(lexerFeatures); + } + + public AdjacentStringLiterals getAdjacentStringLiterals() { + return adjacentStringLiterals; + } + } + + public P withSquareBracketQuotation() { + return withFeature(Feature.allowSquareBracketQuotation, true); + } + + public P withSquareBracketQuotation(boolean allowSquareBracketQuotation) { + return withFeature(Feature.allowSquareBracketQuotation, allowSquareBracketQuotation); + } + + public P withAllowComplexParsing() { + return withFeature(Feature.allowComplexParsing, true); + } + + public P withAllowComplexParsing(boolean allowComplexParsing) { + return withFeature(Feature.allowComplexParsing, allowComplexParsing); + } + + public P withComplexParsing() { + return withFeature(Feature.allowComplexParsing, true); + } + + public P withComplexParsing(boolean allowComplexParsing) { + return withFeature(Feature.allowComplexParsing, allowComplexParsing); + } + + public P withUnsupportedStatements() { + return withFeature(Feature.allowUnsupportedStatements, true); + } + + public P withUnsupportedStatements(boolean allowUnsupportedStatements) { + return withFeature(Feature.allowUnsupportedStatements, allowUnsupportedStatements); + } + + /** Enables GROUP BY ASC/DESC for MySQL versions before 8.0.13. Requires MYSQL dialect. */ + public P withLegacyMySqlGroupBy(boolean enabled) { + return withFeature(Feature.allowLegacyMySqlGroupBy, enabled); + } + + /** + * Resolves MySQL executable comments against this server version (for example 90702 for 9.7.2). + * Requires the MYSQL dialect. Rendered SQL reflects this version, without conditional wrappers. + * Without an explicit version, conditional executable comments raise a lexical error. + * + * @param version major * 10000 + minor * 100 + patch, from 0 through 999999 + * @return this parser + */ + public P withMySqlServerVersion(int version) { + if (version < 0 || version > 999999) { + throw new IllegalArgumentException("MySQL server version must be between 0 and 999999"); + } + return withFeature(Feature.mySqlServerVersion, (long) version); + } + + public P withTimeOut(long timeOutMillSeconds) { + return withFeature(Feature.timeOut, timeOutMillSeconds); + } + + /** + * Applies this dialect's enabled lexer defaults to the current configuration. Existing options + * remain set; apply explicit overrides after this call, or use a new parser for a fresh preset. + */ + public P withDialect(Dialect dialect) { + withFeature(Feature.dialect, dialect.name()); + if (dialect.getAdjacentStringLiterals() != AdjacentStringLiterals.OFF) { + withAdjacentStringLiterals(dialect.getAdjacentStringLiterals()); + } + for (Feature lexerFeature : dialect.getLexerFeatures()) { + withFeature(lexerFeature, true); + } + return me(); + } + + public P withAdjacentStringLiterals() { + return withAdjacentStringLiterals(AdjacentStringLiterals.NEWLINE); + } + + public P withAdjacentStringLiterals(boolean adjacentStringLiterals) { + return withAdjacentStringLiterals( + adjacentStringLiterals ? AdjacentStringLiterals.NEWLINE + : AdjacentStringLiterals.OFF); + } + + public P withAdjacentStringLiterals(AdjacentStringLiterals adjacentStringLiterals) { + getConfiguration().setValue(Feature.adjacentStringLiterals, adjacentStringLiterals); + return me(); + } + + public P withAllowedNestingDepth(int allowedNestingDepth) { + return withFeature(Feature.allowedNestingDepth, allowedNestingDepth); + } + + public P withBackslashEscapeCharacter() { + return withFeature(Feature.allowBackslashEscapeCharacter, true); + } + + public P withBackslashEscapeCharacter(boolean allowBackslashEscapeCharacter) { + return withFeature(Feature.allowBackslashEscapeCharacter, allowBackslashEscapeCharacter); + } + + /** + * Controls tagged dollar quotes; disabled by default, enabled by the PostgreSQL dialect preset. + * False preserves dollar-containing identifier spellings. + */ + public P withDollarQuotedStringTags(boolean allowDollarQuotedStringTags) { + return withFeature(Feature.allowDollarQuotedStringTags, allowDollarQuotedStringTags); + } + + public P withDoubleQuotedStrings() { + return withFeature(Feature.allowDoubleQuotedStrings, true); + } + + public P withDoubleQuotedStrings(boolean allowDoubleQuotedStrings) { + return withFeature(Feature.allowDoubleQuotedStrings, allowDoubleQuotedStrings); + } + + public P withHashLineComments() { + return withFeature(Feature.allowHashLineComments, true); + } + + public P withHashLineComments(boolean allowHashLineComments) { + return withFeature(Feature.allowHashLineComments, allowHashLineComments); + } + + public P withBlankLinesAsSeparator(boolean allowBlankLinesAsStatementSeparator) { + return withFeature(Feature.allowBlankLinesAsStatementSeparator, + allowBlankLinesAsStatementSeparator); + } + + public P withDigitSeparators() { + return withFeature(Feature.allowDigitSeparators, true); + } + + public P withDigitSeparators(boolean allowDigitSeparators) { + return withFeature(Feature.allowDigitSeparators, allowDigitSeparators); + } + + public P withUnparenthesizedSubSelects() { + return withFeature(Feature.allowUnparenthesizedSubSelects, true); + } + + public P withUnparenthesizedSubSelects(boolean allowUnparenthesizedSubSelects) { + return withFeature(Feature.allowUnparenthesizedSubSelects, allowUnparenthesizedSubSelects); + } + + public P withFeature(Feature f, boolean enabled) { + getConfiguration().setValue(f, enabled); + return me(); + } + + public P withFeature(Feature f, long value) { + getConfiguration().setValue(f, value); + return me(); + } + + public P withFeature(Feature f, String value) { + getConfiguration().setValue(f, value); + return me(); + } + + public abstract FeatureConfiguration getConfiguration(); + + public FeatureConfiguration setValue(Feature feature, Object value) { + return getConfiguration().setValue(feature, value); + } + + public Object getValue(Feature feature) { + return getConfiguration().getValue(feature); + } + + public abstract P me(); + + public boolean getAsBoolean(Feature f) { + return getConfiguration().getAsBoolean(f); + } + + public Long getAsLong(Feature f) { + return getConfiguration().getAsLong(f); + } + + public int getAsInt(Feature f) { + return getConfiguration().getAsInt(f); + } + + public Integer getAsInteger(Feature f) { + return getConfiguration().getAsInteger(f); + } + + /** + * The INSERT OR conflict algorithms other than REPLACE are SQLite syntax. + */ + protected UpsertType insertOrType(String algorithm) throws ParseException { + if ("REPLACE".equalsIgnoreCase(algorithm)) { + return UpsertType.INSERT_OR_REPLACE; + } + if (!Dialect.SQLITE.name().equals(getAsString(Feature.dialect))) { + throw new ParseException("INSERT OR " + algorithm + " needs Dialect.SQLITE"); + } + switch (algorithm.toUpperCase()) { + case "IGNORE": + return UpsertType.INSERT_OR_IGNORE; + case "ROLLBACK": + return UpsertType.INSERT_OR_ROLLBACK; + case "ABORT": + return UpsertType.INSERT_OR_ABORT; + case "FAIL": + return UpsertType.INSERT_OR_FAIL; + default: + throw new ParseException("Expected ABORT, FAIL, IGNORE, REPLACE or ROLLBACK"); + } + } + + protected UpdateConflictAlgorithm updateOrAlgorithm(String algorithm) throws ParseException { + if (!Dialect.SQLITE.name().equals(getAsString(Feature.dialect))) { + throw new ParseException("UPDATE OR " + algorithm + " needs Dialect.SQLITE"); + } + for (UpdateConflictAlgorithm conflictAlgorithm : UpdateConflictAlgorithm.values()) { + if (conflictAlgorithm.name().equalsIgnoreCase(algorithm)) { + return conflictAlgorithm; + } + } + throw new ParseException("Expected ABORT, FAIL, IGNORE, REPLACE or ROLLBACK"); + } + + public String getAsString(Feature f) { + return getConfiguration().getAsString(f); + } + + public void setErrorRecovery(boolean errorRecovery) { + this.errorRecovery = errorRecovery; + } + + public P withErrorRecovery() { + this.errorRecovery = true; + return me(); + } + + public P withErrorRecovery(boolean errorRecovery) { + this.errorRecovery = errorRecovery; + return me(); + } + + public List getParseErrors() { + return parseErrors; + } +} diff --git a/src/main/java/net/sf/jsqlparser/parser/BaseToken.java b/src/main/java/net/sf/jsqlparser/parser/BaseToken.java new file mode 100644 index 0000000000..6972f0a5c7 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/parser/BaseToken.java @@ -0,0 +1,16 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.parser; + +public class BaseToken { + + public int absoluteBegin = 0; + public int absoluteEnd = 0; +} diff --git a/src/main/java/net/sf/jsqlparser/parser/CCJSqlParserManager.java b/src/main/java/net/sf/jsqlparser/parser/CCJSqlParserManager.java index fc998fbd7e..fb0bf2115a 100644 --- a/src/main/java/net/sf/jsqlparser/parser/CCJSqlParserManager.java +++ b/src/main/java/net/sf/jsqlparser/parser/CCJSqlParserManager.java @@ -1,22 +1,10 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.parser; @@ -26,18 +14,15 @@ import net.sf.jsqlparser.JSQLParserException; import net.sf.jsqlparser.statement.Statement; -/** - * A JSqlParser implementation that uses a parser generated by JavaCC - */ public class CCJSqlParserManager implements JSqlParser { - @Override - public Statement parse(Reader statementReader) throws JSQLParserException { - CCJSqlParser parser = new CCJSqlParser(statementReader); - try { - return parser.Statement(); - } catch (Exception ex) { - throw new JSQLParserException(ex); - } - } -} \ No newline at end of file + @Override + public Statement parse(Reader statementReader) throws JSQLParserException { + CCJSqlParser parser = new CCJSqlParser(new StreamProvider(statementReader)); + try { + return parser.Statement(); + } catch (Exception ex) { + throw new JSQLParserException(ex); + } + } +} diff --git a/src/main/java/net/sf/jsqlparser/parser/CCJSqlParserUtil.java b/src/main/java/net/sf/jsqlparser/parser/CCJSqlParserUtil.java index ccc3dbb810..f3bbdc7ac0 100644 --- a/src/main/java/net/sf/jsqlparser/parser/CCJSqlParserUtil.java +++ b/src/main/java/net/sf/jsqlparser/parser/CCJSqlParserUtil.java @@ -1,117 +1,566 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.parser; +import java.io.IOException; import java.io.InputStream; import java.io.Reader; -import java.io.StringReader; +import java.util.Stack; +import java.util.concurrent.Callable; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.function.Consumer; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import net.sf.jsqlparser.JSQLParserException; import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.parser.feature.Feature; import net.sf.jsqlparser.statement.Statement; import net.sf.jsqlparser.statement.Statements; +import net.sf.jsqlparser.statement.create.table.ColDataType; /** * Toolfunctions to start and use JSqlParser. + * * @author toben */ + +@SuppressWarnings("PMD.CyclomaticComplexity") public final class CCJSqlParserUtil { - public static Statement parse(Reader statementReader) throws JSQLParserException { - CCJSqlParser parser = new CCJSqlParser(statementReader); - try { - return parser.Statement(); - } catch (Exception ex) { - throw new JSQLParserException(ex); - } - } - - public static Statement parse(String sql) throws JSQLParserException { - CCJSqlParser parser = new CCJSqlParser(new StringReader(sql)); - try { - return parser.Statement(); - } catch (Exception ex) { - throw new JSQLParserException(ex); - } - } - - public static Statement parse(InputStream is) throws JSQLParserException { - CCJSqlParser parser = new CCJSqlParser(is); - try { - return parser.Statement(); - } catch (Exception ex) { - throw new JSQLParserException(ex); - } - } - - public static Statement parse(InputStream is, String encoding) throws JSQLParserException { - CCJSqlParser parser = new CCJSqlParser(is,encoding); - try { - return parser.Statement(); - } catch (Exception ex) { - throw new JSQLParserException(ex); - } - } - - /** - * Parse an expression. - * @param expression - * @return - * @throws JSQLParserException - */ - public static Expression parseExpression(String expression) throws JSQLParserException { - CCJSqlParser parser = new CCJSqlParser(new StringReader(expression)); - try { - return parser.SimpleExpression(); - } catch (Exception ex) { - throw new JSQLParserException(ex); - } - } - + public final static Logger LOGGER = Logger.getLogger(CCJSqlParserUtil.class.getName()); + + static { + LOGGER.setLevel(Level.OFF); + } + + private CCJSqlParserUtil() {} + + public static Statement parse(Reader statementReader) throws JSQLParserException { + ExecutorService executorService = Executors.newSingleThreadExecutor(); + Statement statement; + CCJSqlParser parser = new CCJSqlParser(new StreamProvider(statementReader)); + try { + statement = parseStatement(parser, executorService); + } finally { + executorService.shutdown(); + } + return statement; + } + + /** + * Parses a single SQL statement. + * + * @param sql the SQL statement to parse + * @return the parsed statement + * @throws JSQLParserException if the input is null, empty, or cannot be parsed + */ + public static Statement parse(String sql) throws JSQLParserException { + return parse(sql, null); + } + + /** + * Parses an sql statement while allowing via consumer to configure the used parser before. + *

+ * For instance to activate SQLServer bracket quotation on could use: + *

+ * {@code + * CCJSqlParserUtil.parse("select * from [mytable]", parser -> parser.withSquareBracketQuotation(true)); + * } + * + * @param sql the SQL statement to parse + * @param consumer parser configuration callback, or {@code null} + * @return the parsed statement + * @throws JSQLParserException if the input is null, empty, or cannot be parsed + */ + public static Statement parse(String sql, Consumer consumer) + throws JSQLParserException { + + requireStatementInput(sql); + + ExecutorService executorService = Executors.newSingleThreadExecutor(); + Statement statement; + try { + statement = parse(sql, executorService, consumer); + } catch (JSQLParserException ex) { + throw new JSQLParserException(sql, ex); + } finally { + executorService.shutdown(); + } + return statement; + } + + /** + * Parses a single SQL statement using the caller's executor, which is left open. + * + * @param sql the SQL statement to parse + * @param executorService executor to use for parsing + * @param consumer parser configuration callback, or {@code null} + * @return the parsed statement + * @throws JSQLParserException if the input is null, empty, or cannot be parsed + */ + public static Statement parse(String sql, ExecutorService executorService, + Consumer consumer) + throws JSQLParserException { + requireStatementInput(sql); + + Statement statement; + // first, try to parse fast and simple + CCJSqlParser parser = newParser(sql); + if (consumer != null) { + consumer.accept(parser); + } + boolean allowComplex = parser.getAsBoolean(Feature.allowComplexParsing); + int allowedNestingDepth = parser.getAsInt(Feature.allowedNestingDepth); + LOGGER.info("Allowed Complex Parsing: " + allowComplex); + try { + LOGGER.info("Trying SIMPLE parsing " + (allowComplex ? "first" : "only")); + statement = parseStatement(parser.withAllowComplexParsing(false), executorService); + } catch (JSQLParserException ex) { + if (wasExecutionStopped(ex)) { + throw ex; + } + LOGGER.info("Nesting Depth" + getNestingDepth(sql)); + if (allowComplex + && (allowedNestingDepth < 0 || getNestingDepth(sql) <= allowedNestingDepth)) { + LOGGER.info("Trying COMPLEX parsing when SIMPLE parsing failed"); + // beware: the parser must not be reused, but needs to be re-initiated + parser = newParser(sql); + if (consumer != null) { + consumer.accept(parser); + } + statement = parseStatement(parser.withAllowComplexParsing(true), executorService); + } else { + throw ex; + } + } + return statement; + } + + private static void requireStatementInput(String sql) throws JSQLParserException { + if (sql == null || sql.isEmpty()) { + throw new JSQLParserException("SQL statement must not be null or empty."); + } + } + + public static CCJSqlParser newParser(String sql) { + if (sql == null || sql.isEmpty()) { + return null; + } + + return new CCJSqlParser(new StringProvider(sql)); + } + + public static CCJSqlParser newParser(InputStream is) throws IOException { + return new CCJSqlParser(new StreamProvider(is)); + } + + public static CCJSqlParser newParser(InputStream is, String encoding) throws IOException { + return new CCJSqlParser(new StreamProvider(is, encoding)); + } + + public static Node parseAST(String sql) throws JSQLParserException { + if (sql == null || sql.isEmpty()) { + return null; + } + + CCJSqlParser parser = newParser(sql); + try { + parser.Statement(); + return parser.jjtree.rootNode(); + } catch (Exception ex) { + throw new JSQLParserException(ex); + } + } + + public static Statement parse(InputStream is) throws JSQLParserException { + try { + CCJSqlParser parser = newParser(is); + return parser.Statement(); + } catch (Exception ex) { + throw new JSQLParserException(ex); + } + } + + public static Statement parse(InputStream is, String encoding) throws JSQLParserException { + try { + CCJSqlParser parser = newParser(is, encoding); + return parser.Statement(); + } catch (Exception ex) { + throw new JSQLParserException(ex); + } + } + + public static Expression parseExpression(String expression) throws JSQLParserException { + if (expression == null || expression.isEmpty()) { + return null; + } + + return parseExpression(expression, true); + } + + public static Expression parseExpression(String expression, boolean allowPartialParse) + throws JSQLParserException { + if (expression == null || expression.isEmpty()) { + return null; + } + + return parseExpression(expression, allowPartialParse, p -> { + }); + } + + /** + * Parses a column data type fragment. The complete input must represent the data type; trailing + * tokens are rejected. + * + * @param columnDataType the column data type fragment to parse + * @return the parsed column data type, or {@code null} for a null or empty input + * @throws JSQLParserException when the input cannot be parsed completely + * @see #parseColDataType(String, Consumer) + */ + public static ColDataType parseColDataType(String columnDataType) throws JSQLParserException { + return parseColDataType(columnDataType, null); + } + + /** + * Parses a column data type fragment while allowing the parser to be configured. The complete + * input must represent the data type; trailing tokens are rejected. + * + * @param columnDataType the column data type fragment to parse + * @param consumer parser configuration callback, or {@code null} + * @return the parsed column data type, or {@code null} for a null or empty input + * @throws JSQLParserException when the input cannot be parsed completely + */ + public static ColDataType parseColDataType(String columnDataType, + Consumer consumer) throws JSQLParserException { + if (columnDataType == null || columnDataType.isEmpty()) { + return null; + } + + try { + return parseColDataType(columnDataType, false, consumer); + } catch (JSQLParserException ex) { + return parseColDataType(columnDataType, true, consumer); + } + } + + private static ColDataType parseColDataType(String columnDataType, boolean allowComplexParsing, + Consumer consumer) throws JSQLParserException { + CCJSqlParser parser = newParser(columnDataType) + .withAllowComplexParsing(allowComplexParsing); + if (consumer != null) { + consumer.accept(parser); + } + + try { + ColDataType result = parser.ColDataType(); + if (parser.getNextToken().kind != CCJSqlParserTokenManager.EOF) { + throw new JSQLParserException( + "could only parse partial column data type " + result); + } + return result; + } catch (ParseException ex) { + throw new JSQLParserException(columnDataType, ex); + } + } + + public static Expression parseExpression(String expressionStr, boolean allowPartialParse, + Consumer consumer) throws JSQLParserException { + if (expressionStr == null || expressionStr.isEmpty()) { + return null; + } + + // First require a complete simple parse, even when the caller allows a partial result. + try { + return parseExpression(expressionStr, false, false, consumer); + } catch (JSQLParserException ex) { + return parseExpression(expressionStr, true, allowPartialParse, consumer); + } + } + + private static Expression parseExpression(String expressionStr, boolean allowComplexParsing, + boolean allowPartialParse, Consumer consumer) throws JSQLParserException { + CCJSqlParser parser = newParser(expressionStr).withAllowComplexParsing(allowComplexParsing); + if (consumer != null) { + consumer.accept(parser); + } + + try { + Expression expression = parser.Expression(); + if (!allowPartialParse && parser.getNextToken().kind != CCJSqlParserTokenManager.EOF) { + throw new JSQLParserException( + "could only parse partial expression " + expression.toString()); + } + return expression; + } catch (ParseException ex) { + throw new JSQLParserException(ex); + } + } + + /** + * Parse an conditional expression. This is the expression after a where clause. Partial parsing + * is enabled. + * + * @param condExpr + * @return the expression parsed + * @see #parseCondExpression(String, boolean) + */ + public static Expression parseCondExpression(String condExpr) throws JSQLParserException { + if (condExpr == null || condExpr.isEmpty()) { + return null; + } + return parseCondExpression(condExpr, true); + } + + /** + * Parse an conditional expression. This is the expression after a where clause. + * + * @param condExpr + * @param allowPartialParse false: needs the whole string to be processed. + * @return the expression parsed + * @see #parseCondExpression(String) + */ + public static Expression parseCondExpression(String condExpr, boolean allowPartialParse) + throws JSQLParserException { + if (condExpr == null || condExpr.isEmpty()) { + return null; + } + return parseCondExpression(condExpr, allowPartialParse, p -> { + }); + } + + public static Expression parseCondExpression(String conditionalExpressionStr, + boolean allowPartialParse, Consumer consumer) throws JSQLParserException { + return parseExpression(conditionalExpressionStr, allowPartialParse, consumer); + } + /** - * Parse an conditional expression. This is the expression after a where clause. - * @param condExpr - * @return - * @throws JSQLParserException - */ - public static Expression parseCondExpression(String condExpr) throws JSQLParserException { - CCJSqlParser parser = new CCJSqlParser(new StringReader(condExpr)); - try { - return parser.Expression(); - } catch (Exception ex) { - throw new JSQLParserException(ex); - } - } - + * @param parser the Parser armed with a Statement text + * @param executorService the Executor Service for parsing within a Thread + * @return the parsed Statement + * @throws JSQLParserException when either the Statement can't be parsed or the configured + * timeout is reached + */ + + public static Statement parseStatement(CCJSqlParser parser, ExecutorService executorService) + throws JSQLParserException { + return executeParser(parser, executorService, parser::Statement); + } + /** * Parse a statement list. + * + * @return the statements parsed, or a new empty list for null or empty input */ public static Statements parseStatements(String sqls) throws JSQLParserException { - CCJSqlParser parser = new CCJSqlParser(new StringReader(sqls)); - try { - return parser.Statements(); - } catch (Exception ex) { - throw new JSQLParserException(ex); - } - } - - private CCJSqlParserUtil() { - } + return parseStatements(sqls, null); + } + + /** + * Parses a statement list with optional parser configuration. + * + * @return the statements parsed, or a new empty list for null or empty input + */ + public static Statements parseStatements(String sqls, Consumer consumer) + throws JSQLParserException { + if (sqls == null || sqls.isEmpty()) { + return new Statements(); + } + + ExecutorService executorService = Executors.newSingleThreadExecutor(); + try { + return parseStatements(sqls, executorService, consumer); + } finally { + executorService.shutdown(); + } + } + + /** + * Parses a statement list using the caller's executor, which is left open. + * + * @return the statements parsed, or a new empty list for null or empty input + */ + public static Statements parseStatements(String sqls, ExecutorService executorService, + Consumer consumer) + throws JSQLParserException { + if (sqls == null || sqls.isEmpty()) { + return new Statements(); + } + + CCJSqlParser parser = newParser(sqls); + if (consumer != null) { + consumer.accept(parser); + } + boolean allowComplex = parser.getAsBoolean(Feature.allowComplexParsing); + int allowedNestingDepth = parser.getAsInt(Feature.allowedNestingDepth); + + // first, try to parse fast and simple + try { + return parseStatements(parser.withAllowComplexParsing(false), executorService); + } catch (JSQLParserException ex) { + if (wasExecutionStopped(ex)) { + throw ex; + } + // when fast simple parsing fails, try complex parsing but only if it has a chance to + // succeed + if (allowComplex + && (allowedNestingDepth < 0 || getNestingDepth(sqls) <= allowedNestingDepth)) { + // beware: parser must not be re-used but needs to be re-initiated + parser = newParser(sqls); + if (consumer != null) { + consumer.accept(parser); + } + return parseStatements(parser.withAllowComplexParsing(true), executorService); + } + throw ex; + } + } + + /** + * @param parser the Parser armed with a Statement text + * @param executorService the Executor Service for parsing within a Thread + * @return the Statements (representing a List of single statements) + * @throws JSQLParserException when either the Statement can't be parsed or the configured + * timeout is reached + */ + public static Statements parseStatements(CCJSqlParser parser, ExecutorService executorService) + throws JSQLParserException { + return executeParser(parser, executorService, parser::Statements); + } + + private static T executeParser(CCJSqlParser parser, ExecutorService executorService, + Callable operation) throws JSQLParserException { + Future future = executorService.submit(operation); + try { + return future.get(parser.getAsLong(Feature.timeOut), TimeUnit.MILLISECONDS); + } catch (InterruptedException ex) { + parser.interrupted = true; + future.cancel(true); + Thread.currentThread().interrupt(); + throw new JSQLParserException(ex); + } catch (TimeoutException ex) { + parser.interrupted = true; + future.cancel(true); + throw new JSQLParserException("Time out occurred.", ex); + } catch (CancellationException ex) { + parser.interrupted = true; + throw new JSQLParserException(ex); + } catch (ExecutionException ex) { + throw new JSQLParserException(ex); + } + } + + private static boolean wasExecutionStopped(JSQLParserException exception) { + Throwable cause = exception.getCause(); + return cause instanceof InterruptedException || cause instanceof TimeoutException + || cause instanceof CancellationException; + } + + public static void streamStatements(StatementListener listener, InputStream is, String encoding) + throws JSQLParserException { + try { + CCJSqlParser parser = newParser(is, encoding); + do { + Statement stmt = parser.SingleStatement(); + listener.accept(stmt); + if (parser.getToken(1).kind == CCJSqlParserTokenManager.ST_SEMICOLON) { + parser.getNextToken(); + } + + } while (parser.getToken(1).kind != CCJSqlParserTokenManager.EOF); + } catch (Exception ex) { + throw new JSQLParserException(ex); + } + } + + public static int getNestingDepth(String sql) { + int maxlevel = 0; + int level = 0; + + char[] chars = sql.toCharArray(); + for (char c : chars) { + switch (c) { + case '(': + level++; + break; + case ')': + if (maxlevel < level) { + maxlevel = level; + } + level--; + break; + default: + // Codazy/PMD insists in a Default statement + } + } + return maxlevel; + } + + public static int getUnbalancedPosition(String text) { + Stack stack = new Stack<>(); + boolean insideQuote = false; + + for (int i = 0; i < text.length(); i++) { + char c = text.charAt(i); + if (c == '"' || c == '\'') { + if (!insideQuote) { + stack.push(c); // Add quote to stack + } else if (stack.peek() == c) { + stack.pop(); // Matching quote found, remove from stack + } + insideQuote = !insideQuote; // Toggle insideQuote flag + } else if (!insideQuote && (c == '(' || c == '[' || c == '{')) { + stack.push(c); // Add opening bracket to stack + } else if (!insideQuote && (c == ')' || c == ']' || c == '}')) { + if (stack.isEmpty()) { + return i; // Return position of unbalanced closing bracket + } + char top = stack.pop(); + if (c == ')' && top != '(' || c == ']' && top != '[' || c == '}' && top != '{') { + return i; // Return position of unbalanced closing bracket + } + } + } + + if (!stack.isEmpty()) { + char unbalanced = stack.peek(); + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == unbalanced) { + return i; // Return position of unbalanced opening bracket or quote + } + } + } + + return -1; // Return -1 if all brackets and quotes are balanced + } + + public static String sanitizeSingleSql(String sqlStr) { + final Pattern SQL_DELIMITER_SPLIT = + Pattern.compile("((?:'[^']*+'|[^\\n])*+)"); + final StringBuilder builder = new StringBuilder(); + final Matcher matcher = SQL_DELIMITER_SPLIT.matcher(sqlStr); + while (matcher.find()) { + for (int i = 1; i <= matcher.groupCount(); i++) { + if (!matcher.group(i).isEmpty()) { + builder.append("\n").append(matcher.group(i)); + } + } + } + return builder.toString(); + } + } diff --git a/src/main/java/net/sf/jsqlparser/parser/JSqlParser.java b/src/main/java/net/sf/jsqlparser/parser/JSqlParser.java index 758cd5ae98..8a2aa9538e 100644 --- a/src/main/java/net/sf/jsqlparser/parser/JSqlParser.java +++ b/src/main/java/net/sf/jsqlparser/parser/JSqlParser.java @@ -1,22 +1,10 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.parser; @@ -26,10 +14,7 @@ import net.sf.jsqlparser.JSQLParserException; import net.sf.jsqlparser.statement.Statement; -/** - * Every parser must implements this interface - */ public interface JSqlParser { - Statement parse(Reader statementReader) throws JSQLParserException; + Statement parse(Reader statementReader) throws JSQLParserException; } diff --git a/src/main/java/net/sf/jsqlparser/parser/ParserKeywordsUtils.java b/src/main/java/net/sf/jsqlparser/parser/ParserKeywordsUtils.java new file mode 100644 index 0000000000..5bdb938302 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/parser/ParserKeywordsUtils.java @@ -0,0 +1,224 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2021 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.parser; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.charset.CharsetEncoder; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.TreeSet; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Utilities for querying the parser's reserved and non-reserved keyword sets. + * + *

+ * Non-reserved keywords are derived from the generated {@link CCJSqlParserConstants} token + * table using the {@code MIN_NON_RESERVED_WORD} / {@code MAX_NON_RESERVED_WORD} sentinels. + * + *

+ * Reserved keywords are determined by scanning the Grammar file for all simple string token + * definitions ({@code }) and subtracting the non-reserved set. + */ +public class ParserKeywordsUtils { + + private static final CharsetEncoder ASCII_ENCODER = StandardCharsets.US_ASCII.newEncoder(); + + /** Matches a pure keyword image: word characters, at least two characters, pure US-ASCII. */ + private static final Pattern KEYWORD_PATTERN = Pattern.compile("[A-Za-z_][A-Za-z_0-9]+"); + + /** + * Matches simple token definitions in the grammar: {@code }. Group 1 captures + * the string value. Only matches definitions where the value is a plain quoted string — + * compound regex tokens like {@code } won't match. + */ + private static final Pattern SIMPLE_TOKEN_PATTERN = + Pattern.compile("", Pattern.MULTILINE); + + private ParserKeywordsUtils() { + // utility class + } + + /** + * Returns the set of non-reserved keywords, i.e. tokens whose kind lies between + * {@code MIN_NON_RESERVED_WORD} and {@code MAX_NON_RESERVED_WORD}. These keywords can be used + * as unquoted identifiers. + */ + public static TreeSet getNonReservedKeywords() { + TreeSet keywords = new TreeSet<>(); + String[] images = CCJSqlParserConstants.tokenImage; + + for (int kind = CCJSqlParserConstants.MIN_NON_RESERVED_WORD + + 1; kind < CCJSqlParserConstants.MAX_NON_RESERVED_WORD; kind++) { + String image = extractKeyword(images[kind]); + if (image != null && isKeywordImage(image)) { + keywords.add(image); + } + } + return keywords; + } + + /** + * Returns the set of reserved keywords by scanning the Grammar file for all simple + * string token definitions and subtracting the non-reserved keywords. + * + * @param grammarFile the {@code .jjt} grammar file + * @return reserved keyword strings + * @throws IOException if reading the grammar file fails + */ + public static TreeSet getReservedKeywords(File grammarFile) throws IOException { + TreeSet allSimple = getAllSimpleKeywords(grammarFile); + allSimple.removeAll(getNonReservedKeywords()); + return allSimple; + } + + /** + * Returns all simple string keywords defined in the grammar file. Scans for + * {@code } patterns and collects the string values. + * + * @param grammarFile the {@code .jjt} grammar file + * @return all simple keyword strings + * @throws IOException if reading the grammar file fails + */ + public static TreeSet getAllSimpleKeywords(File grammarFile) throws IOException { + TreeSet keywords = new TreeSet<>(); + String content = Files.readString(grammarFile.toPath(), StandardCharsets.UTF_8); + + Matcher matcher = SIMPLE_TOKEN_PATTERN.matcher(content); + while (matcher.find()) { + String value = matcher.group(1); + if (isKeywordImage(value) && ASCII_ENCODER.canEncode(value)) { + keywords.add(value); + } + } + return keywords; + } + + /** + * Checks whether the given token kind is a non-reserved keyword that can be used as an unquoted + * identifier. + */ + public static boolean isNonReservedKeyword(int tokenKind) { + return tokenKind > CCJSqlParserConstants.MIN_NON_RESERVED_WORD + && tokenKind < CCJSqlParserConstants.MAX_NON_RESERVED_WORD; + } + + /** + * Writes a reStructuredText documentation file listing all reserved keywords. + * + * @param grammarFile the {@code .jjt} grammar file + * @param rstFile the output {@code .rst} file to write + * @throws IOException if reading or writing fails + */ + public static void writeKeywordsDocumentationFile(File grammarFile, File rstFile) + throws IOException { + TreeSet reserved = getReservedKeywords(grammarFile); + + StringBuilder builder = new StringBuilder(); + builder.append("***********************\n"); + builder.append("Reserved Keywords\n"); + builder.append("***********************\n"); + builder.append("\n"); + + builder.append( + "The following Keywords are **reserved** in JSQLParser-|JSQLPARSER_VERSION| and must not be used for **Naming Objects**: \n"); + builder.append("\n"); + + builder.append("+---------------------------+\n"); + builder.append("| **Keyword** |\n"); + builder.append("+---------------------------+\n"); + + for (String keyword : reserved) { + builder.append("| ").append(rightPadding(keyword, ' ', 25)).append(" |\n"); + builder.append("+---------------------------+\n"); + } + + try (FileWriter fileWriter = new FileWriter(rstFile)) { + fileWriter.append(builder); + fileWriter.flush(); + } + } + + public static String rightPadding(String input, char ch, int length) { + return String.format("%" + (-length) + "s", input).replace(' ', ch); + } + + /** + * Entry point for the {@code updateKeywords} Gradle/Maven task. + * + *

+ * Usage: {@code java net.sf.jsqlparser.parser.ParserKeywordsUtils } + * + * @param args {@code args[0]}: path to the grammar file, {@code args[1]}: path to the output + * RST file + * @throws Exception if reading or writing fails + */ + public static void main(String[] args) throws Exception { + if (args.length < 2) { + throw new IllegalArgumentException( + "Usage: ParserKeywordsUtils "); + } + + File grammarFile = new File(args[0]); + if (!grammarFile.canRead()) { + throw new IOException("Cannot read grammar file: " + grammarFile); + } + + File rstFile = new File(args[1]); + rstFile.getParentFile().mkdirs(); + writeKeywordsDocumentationFile(grammarFile, rstFile); + + System.out.println("Reserved keywords: " + getReservedKeywords(grammarFile).size()); + System.out.println("Non-reserved keywords: " + getNonReservedKeywords().size()); + System.out.println("Written to: " + rstFile.getAbsolutePath()); + } + + /** + * Extracts the keyword string from a {@code tokenImage} entry. + * + *

+ * JavaCC renders inline BNF token declarations as {@code } in {@code tokenImage}. + * Stripping the {@code K_} prefix and angle brackets yields the keyword string. + * + * @return the keyword string, or {@code null} if the entry is not a {@code K_} token + */ + private static String extractKeyword(String tokenImage) { + if (tokenImage == null || tokenImage.length() < 5) { + return null; + } + + // Format: → ACTION + if (tokenImage.charAt(0) == '<' + && tokenImage.charAt(tokenImage.length() - 1) == '>' + && tokenImage.startsWith(" blocks = new ArrayDeque<>(); + private int parentheses; + private int previousKind = -1; + private int statementKind = -1; + private boolean hasParameters; + private boolean standardReturns; + private boolean returnTypeName; + private boolean afterDot; + private boolean declarations; + private boolean bodyStarted; + private boolean compoundBody; + private boolean quotedBody; + private boolean completed; + private boolean handlerAction; + private boolean statementStart = true; + + /** + * Tracks a compound statement without a routine header, such as a MySQL trigger body. Its + * tokens belong to the body from the start, as after a routine's parameter list. + */ + static RoutineBodyBoundary forCompoundStatement() { + RoutineBodyBoundary boundary = new RoutineBodyBoundary(); + boundary.hasParameters = true; + return boundary; + } + + boolean endsAt(Token token) throws ParseException { + if (token.kind == EOF) { + if (!blocks.isEmpty()) { + throw new ParseException("Unterminated routine block"); + } + return true; + } + return token.kind == ST_SEMICOLON && parentheses == 0 && blocks.isEmpty() + && !declarations && (hasParameters || quotedBody || completed); + } + + /** + * Whether the routine header, including a return type, is complete and the body has not + * started, which is where MySQL routine characteristics appear. + */ + boolean isBeforeBody() { + return hasParameters && parentheses == 0 && !bodyStarted && !returnTypeName + && !declarations && !quotedBody && !completed; + } + + boolean startsQuotedBody(Token token, Token next) { + return parentheses == 0 && !compoundBody && !quotedBody && token.kind == K_AS + && next.kind == S_CHAR_LITERAL + && (!bodyStarted || statementKind == K_RETURN || statementKind == K_SET); + } + + void quotedBody() { + quotedBody = true; + bodyStarted = true; + declarations = false; + } + + void accept(Token token, Token next) { + int kind = token.kind; + if (kind == OPENING_BRACKET) { + parentheses++; + } else if (kind == CLOSING_BRACKET) { + if (--parentheses == 0 && !bodyStarted) { + hasParameters = true; + } + } else if (parentheses == 0 && !quotedBody && !completed) { + acceptTopLevel(token, next); + } + previousKind = kind; + afterDot = ".".equals(token.image); + } + + private void acceptTopLevel(Token token, Token next) { + if (afterDot) { + return; // Qualified type/column names may use otherwise significant keywords. + } + // END IF/CASE/LOOP/WHILE/REPEAT is one terminator, not another opener. + if (previousKind == K_END && isEndQualifier(token)) { + return; + } + if (!acceptRoutineHeader(token)) { + acceptBodyToken(token, next); + } + } + + private boolean acceptRoutineHeader(Token token) { + int kind = token.kind; + if (kind == K_RETURNS && !bodyStarted) { + standardReturns = true; + returnTypeName = true; + return true; + } + if (returnTypeName) { + returnTypeName = keyword(token, "SETOF"); + return true; + } + if (!compoundBody && (kind == K_AS || kind == K_IS) + && (!bodyStarted || statementKind == K_RETURN && !standardReturns + || statementKind == K_SET)) { + declarations = true; + bodyStarted = false; + return true; + } + return false; + } + + private void acceptBodyToken(Token token, Token next) { + int kind = token.kind; + if (acceptStatementBoundary(kind)) { + return; + } + if (!(hasParameters || declarations || bodyStarted)) { + return; + } + if (handlerAction && isSimpleStatementStart(kind)) { + startStatement(); + } + if (acceptBeginOrCase(kind) || declarations || acceptControlFlow(token)) { + return; + } + acceptStatementToken(token, next); + } + + private boolean acceptStatementBoundary(int kind) { + if (kind == ST_SEMICOLON) { + startStatement(); + return true; + } + if (kind == K_END) { + if (!blocks.isEmpty()) { + Block closed = blocks.pop(); + completed = blocks.isEmpty() && closed != Block.CASE_EXPRESSION; + } else { + // Retain legacy opaque declarations without a parameter list or BEGIN. + completed = true; + } + statementStart = false; + return true; + } + return false; + } + + private boolean acceptBeginOrCase(int kind) { + if (kind == K_BEGIN + && (!bodyStarted || statementStart || statementKind == K_DECLARE)) { + blocks.push(Block.BEGIN); + declarations = false; + compoundBody = true; + bodyStarted = true; + startStatement(); + return true; + } + if (kind == K_CASE) { + boolean statementCase = !declarations && (statementStart || handlerAction); + blocks.push(statementCase ? Block.CASE_STATEMENT : Block.CASE_EXPRESSION); + if (statementCase) { + bodyStarted = true; + compoundBody = true; + handlerAction = false; + } + statementStart = false; + return true; + } + return false; + } + + private boolean acceptControlFlow(Token token) { + int kind = token.kind; + Block block = controlBlock(token); + if ((statementStart || handlerAction) && block != null) { + blocks.push(block); + bodyStarted = true; + compoundBody = true; + handlerAction = false; + statementKind = kind; + statementStart = block == Block.LOOP || block == Block.REPEAT; + return true; + } + if (acceptOracleLoop(kind)) { + return true; + } + if (isStatementBranch(kind)) { + startStatement(); + return true; + } + return false; + } + + private boolean acceptOracleLoop(int kind) { + if (kind == K_LOOP && (statementKind == K_FOR || blocks.peek() == Block.WHILE)) { + // Oracle FOR/WHILE ... LOOP shares the same END LOOP boundary. + if (blocks.peek() != Block.WHILE) { + blocks.push(Block.LOOP); + } + startStatement(); + return true; + } + return false; + } + + private boolean isStatementBranch(int kind) { + return (kind == K_THEN || kind == K_ELSE) && !blocks.isEmpty() + && blocks.peek() != Block.CASE_EXPRESSION + || kind == K_DO && blocks.peek() == Block.WHILE; + } + + private void acceptStatementToken(Token token, Token next) { + int kind = token.kind; + if (isStatementPrefix(token, next)) { + return; + } + if (!bodyStarted) { + // SET may also be a PostgreSQL header option; AS remains recognizable above. + // CHARACTER SET and CHAR SET belong to a MySQL return type. + boolean characterSet = + kind == K_SET && (previousKind == K_CHARACTER || previousKind == K_CHAR); + if (!isSimpleStatementStart(kind) || characterSet) { + return; + } + bodyStarted = true; + } + if (statementStart) { + statementKind = kind; + } + if (statementKind == K_DECLARE && token.kind == K_HANDLER) { + handlerAction = true; + } + statementStart = false; + } + + private boolean isStatementPrefix(Token token, Token next) { + // ATOMIC and a label precede the statement they qualify. + return previousKind == K_BEGIN && keyword(token, "ATOMIC") + || statementStart && (":".equals(next.image) || ":".equals(token.image)); + } + + private static boolean isEndQualifier(Token token) { + return token.kind == K_CASE || controlBlock(token) != null; + } + + private static Block controlBlock(Token token) { + if (token.kind == K_IF) { + return Block.IF; + } + if (token.kind == K_LOOP) { + return Block.LOOP; + } + if (keyword(token, "WHILE")) { + return Block.WHILE; + } + return keyword(token, "REPEAT") ? Block.REPEAT : null; + } + + private void startStatement() { + statementStart = true; + statementKind = -1; + handlerAction = false; + } + + private static boolean keyword(Token token, String keyword) { + return token.kind == S_IDENTIFIER && keyword.equalsIgnoreCase(token.image); + } + + private static boolean isSimpleStatementStart(int kind) { + return kind == K_RETURN || kind == K_SELECT || kind == K_INSERT || kind == K_UPDATE + || kind == K_DELETE || kind == K_REPLACE || kind == K_SET || kind == K_CALL + || kind == K_WITH || kind == K_DO; + } +} diff --git a/src/main/java/net/sf/jsqlparser/parser/RowPatternTokenContext.java b/src/main/java/net/sf/jsqlparser/parser/RowPatternTokenContext.java new file mode 100644 index 0000000000..f10b7c12b4 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/parser/RowPatternTokenContext.java @@ -0,0 +1,83 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.parser; + +import java.util.ArrayDeque; +import java.util.Deque; + +/** + * Recognizes the BigQuery PATTERN lexical region even during JavaCC lookahead. The required initial + * ORDER BY (or optional PARTITION BY) distinguishes a clause from an ordinary function named + * MATCH_RECOGNIZE. Quoted tokens never change this state. + */ +final class RowPatternTokenContext implements CCJSqlParserConstants { + private final Deque frames = new ArrayDeque<>(); + private int depth; + private boolean pendingClause; + + private static final class Frame { + private final int depth; + private int phase; + private int patternDepth = -1; + private boolean pendingPattern; + private boolean patternComplete; + + private Frame(int depth) { + this.depth = depth; + } + } + + boolean isIdle() { + return frames.isEmpty() && !pendingClause; + } + + boolean isInPattern() { + return !frames.isEmpty() && frames.peek().patternDepth >= 0; + } + + void accept(Token token) { + if (token.kind == OPENING_BRACKET) { + depth++; + if (pendingClause) { + frames.push(new Frame(depth)); + pendingClause = false; + return; + } + if (!frames.isEmpty() && frames.peek().pendingPattern) { + frames.peek().patternDepth = depth; + frames.peek().pendingPattern = false; + } + } else if (token.kind == CLOSING_BRACKET) { + if (!frames.isEmpty()) { + Frame frame = frames.peek(); + if (frame.patternDepth == depth) { + frame.patternDepth = -1; + frame.patternComplete = true; + } + if (frame.depth == depth) { + frames.pop(); + } + } + depth--; + } else if (!frames.isEmpty() && depth == frames.peek().depth) { + Frame frame = frames.peek(); + if (frame.phase == 0) { + frame.phase = token.kind == K_ORDER || token.kind == K_PARTITION ? 1 : -1; + } else if (frame.phase == 1) { + frame.phase = token.kind == K_BY ? 2 : -1; + } else if (frame.phase == 2 && !frame.patternComplete) { + frame.pendingPattern = token.kind == S_IDENTIFIER + && "PATTERN".equalsIgnoreCase(token.image); + } + } + pendingClause = token.kind == S_IDENTIFIER + && "MATCH_RECOGNIZE".equalsIgnoreCase(token.image); + } +} diff --git a/src/main/java/net/sf/jsqlparser/parser/SimpleCharStream.java b/src/main/java/net/sf/jsqlparser/parser/SimpleCharStream.java new file mode 100644 index 0000000000..5b6c5e8259 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/parser/SimpleCharStream.java @@ -0,0 +1,623 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2025 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +/* Generated By:JavaCC: Do not edit this line by hand. SimpleCharStream.java Version 8.0.0 */ +/* + * Warning: this file is maintained by hand on top of the JavaCC template. Among other manual + * adjustments it carries the in-buffer '#' and blank line rewrites in BeginToken(), which + * Feature.allowHashLineComments and Feature.allowBlankLinesAsStatementSeparator depend on. Never + * overwrite it with a freshly generated SimpleCharStream, that would silently drop the rewrites and + * break both features. + */ +package net.sf.jsqlparser.parser; + +import net.sf.jsqlparser.parser.feature.Feature; +import net.sf.jsqlparser.parser.feature.FeatureConfiguration; + +/** + * An implementation of interface CharStream, where the stream is assumed to contain only ASCII + * characters (without unicode processing). + */ + +public class SimpleCharStream { + + /** + * Whether parser is static. + */ + public static final boolean staticFlag = false; + /** + * Position in buffer. + */ + public int bufpos = -1; + protected long[] buflinecolumn; + protected int column = 0; + protected int line = 1; + protected boolean prevCharIsCR = false; + protected boolean prevCharIsLF = false; + protected Provider inputStream; + protected char[] buffer; + protected int maxNextCharInd = 0; + protected int inBuf = 0; + protected int tabSize = 1; + protected boolean trackLineColumn = true; + protected int totalCharsRead = 0; + protected int absoluteTokenBegin = 0; + // line, column and absolute position of each match begun since the last positionSpecialTokens() + private int[] matchBegins = new int[24]; + private int matchBeginCount = 0; + int bufsize; + int available; + int tokenBegin; + + // MySQL `#` line comments (#2499): under the flag a token-start `#` is + // rewritten in the buffer to HASH_SUBSTITUTION, a character no other + // lexical rule starts with, so the dedicated HASH_LINE_COMMENT production + // wins the match for every `#` form (`# c`, `#c`, `#>`, ...). Rewriting + // the buffer itself (instead of synthesizing reads) keeps the matcher's + // backup / re-read arithmetic intact; the production's action restores + // the `#` in the token image. Wired (with the token manager's + // configuration) before parsing, null keeps this inert. + static final char HASH_SUBSTITUTION = '\u0001'; + static final char MYSQL_MINUS_SUBSTITUTION = '\u0002'; + static final char MYSQL_COMMENT_ERROR = '\u0003'; + FeatureConfiguration featureConfiguration; + private boolean mySqlExecutableComment; + String mySqlCommentError; + boolean mySqlMinusSubstitution; + + /** + * Constructor. + */ + public SimpleCharStream(Provider dstream, int startline, int startcolumn, int buffersize) { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + available = bufsize = buffersize; + buffer = new char[buffersize]; + buflinecolumn = new long[buffersize]; + } + + /** + * Constructor. + */ + public SimpleCharStream(Provider dstream, int startline, int startcolumn) { + this(dstream, startline, startcolumn, 4096); + } + + /** + * Constructor. + */ + public SimpleCharStream(Provider dstream) { + this(dstream, 1, 1, 4096); + } + + public int getTabSize() { + return tabSize; + } + + public void setTabSize(int i) { + tabSize = i; + } + + public final int getAbsoluteTokenBegin() { + return absoluteTokenBegin; + } + + /** + * Gives the comments in front of {@code token} the positions where their matches began, from + * the begins recorded since the last call, and forgets those. Comments come through no token + * action, so this is how they get a position. The comments chain backwards from the token while + * the begins are recorded forwards, so one backwards pass pairs them. + */ + public final void positionSpecialTokens(Token token) { + int i = matchBeginCount - 3; + for (Token comment = token.specialToken; comment != null; comment = comment.specialToken) { + while (i >= 0 && (matchBegins[i] != comment.beginLine + || matchBegins[i + 1] != comment.beginColumn)) { + i -= 3; + } + if (i < 0) { + break; + } + comment.absoluteBegin = matchBegins[i + 2]; + comment.absoluteEnd = comment.absoluteBegin + comment.image.length(); + i -= 3; + } + matchBeginCount = 0; + } + + private void recordMatchBegin() { + if (matchBeginCount + 3 > matchBegins.length) { + matchBegins = java.util.Arrays.copyOf(matchBegins, matchBegins.length * 2); + } + matchBegins[matchBeginCount++] = getBeginLine(); + matchBegins[matchBeginCount++] = getBeginColumn(); + matchBegins[matchBeginCount++] = absoluteTokenBegin; + } + + protected void ExpandBuff(boolean wrapAround) { + final int newSize = bufsize * 2; + char[] newbuffer = new char[newSize]; + long[] newbuflinecolumn = new long[newSize]; + + if (wrapAround) { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); + buffer = newbuffer; + + System.arraycopy(buflinecolumn, tokenBegin, newbuflinecolumn, 0, bufsize - tokenBegin); + System.arraycopy(buflinecolumn, 0, newbuflinecolumn, bufsize - tokenBegin, bufpos); + buflinecolumn = newbuflinecolumn; + + maxNextCharInd = bufpos += bufsize - tokenBegin; + } else { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + buffer = newbuffer; + + System.arraycopy(buflinecolumn, tokenBegin, newbuflinecolumn, 0, bufsize - tokenBegin); + buflinecolumn = newbuflinecolumn; + + maxNextCharInd = bufpos -= tokenBegin; + } + + bufsize = newSize; + available = bufsize; + tokenBegin = 0; + } + + protected void FillBuff() throws java.io.IOException { + if (maxNextCharInd == available) { + if (available == bufsize) { + if (tokenBegin > 2048) { + bufpos = maxNextCharInd = 0; + available = tokenBegin; + } else if (tokenBegin < 0) { + bufpos = maxNextCharInd = 0; + } else { + ExpandBuff(false); + } + } else if (available > tokenBegin) { + available = bufsize; + } else if ((tokenBegin - available) < 2048) { + ExpandBuff(true); + } else { + available = tokenBegin; + } + } + + int i; + try { + if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) { + inputStream.close(); + throw new java.io.IOException(); + } else { + maxNextCharInd += i; + } + } catch (java.io.IOException e) { + --bufpos; + backup(0); + if (tokenBegin == -1) { + tokenBegin = bufpos; + } + throw e; + } + } + + /** + * Start. + */ + public final char BeginToken() throws java.io.IOException { + mySqlMinusSubstitution = false; + if (mySqlCommentError != null) { + // Parser lookahead may catch lexical errors. Keep this failure sticky until ReInit + // rather than allowing a later token request to continue after the rejected marker. + return MYSQL_COMMENT_ERROR; + } + tokenBegin = -1; + char c; + try { + c = readChar(); + } catch (java.io.IOException e) { + if (!mySqlExecutableComment) { + throw e; + } + // JavaCC treats exceptions from BeginToken as EOF. Emit a real token whose lexical + // action reports the error, so an unclosed executable comment cannot succeed as SQL. + c = mySqlCommentError("Unterminated MySQL executable comment"); + } + tokenBegin = bufpos; + + absoluteTokenBegin = totalCharsRead; + recordMatchBegin(); + + if (c == '#' && featureConfiguration != null + && featureConfiguration.getAsBoolean(Feature.allowHashLineComments)) { + buffer[bufpos] = HASH_SUBSTITUTION; + c = HASH_SUBSTITUTION; + } else if ((c == '-' || c == '/' || c == '*') && featureConfiguration != null + && AbstractJSqlParser.Dialect.MYSQL.name() + .equals(featureConfiguration.getValue(Feature.dialect))) { + c = mySqlCommentBoundary(c); + } else if (c == '\n' && featureConfiguration != null + && !featureConfiguration + .getAsBoolean(Feature.allowBlankLinesAsStatementSeparator) + && peekCharacters(2).equals("\n\n")) { + // Blanking the first newline of the run stops ST_SEMICOLON matching "\n\n\n"; + // line and column tracking was already updated when the newline was read. + buffer[bufpos] = ' '; + c = ' '; + } + return c; + } + + /** Changes only token boundaries, never characters being scanned inside strings or names. */ + private char mySqlCommentBoundary(char c) throws java.io.IOException { + if (c == '-') { + String following = peekCharacters(2); + if (following.length() == 2 && following.charAt(0) == '-' + && !isMySqlCommentSpace(following.charAt(1))) { + mySqlMinusSubstitution = true; + buffer[bufpos] = MYSQL_MINUS_SUBSTITUTION; + return MYSQL_MINUS_SUBSTITUTION; + } + } else if (c == '*' && mySqlExecutableComment && peekCharacters(1).equals("/")) { + eraseCommentMarker(2); + mySqlExecutableComment = false; + return ' '; + } else if (c == '/') { + String following = peekCharacters(9); + if (following.startsWith("*!")) { + if (mySqlExecutableComment) { + return mySqlCommentError("Nested MySQL executable comments are not supported"); + } + int digits = mySqlCommentVersionLength(following); + if (digits > 0) { + long target = featureConfiguration.getAsLong(Feature.mySqlServerVersion); + if (target < 0 || target > 999999) { + return mySqlCommentError("MySQL conditional executable comments require " + + "withMySqlServerVersion(major * 10000 + minor * 100 + patch)"); + } + int minimum = Integer.parseInt(following.substring(2, 2 + digits)); + if (minimum > target) { + return c; + } + } + eraseCommentMarker(3 + digits); + mySqlExecutableComment = true; + return ' '; + } + } + return c; + } + + private static boolean isMySqlCommentSpace(char c) { + return c <= ' ' || c == '\u007f'; + } + + private static int mySqlCommentVersionLength(String following) { + if (following.length() < 7) { + return 0; + } + for (int i = 2; i < 7; i++) { + if (following.charAt(i) < '0' || following.charAt(i) > '9') { + return 0; + } + } + // MySQL recognizes a sixth digit only when followed by whitespace. Otherwise the + // five-digit prefix is the version and the remaining characters belong to the SQL body. + return following.length() >= 9 && following.charAt(7) >= '0' + && following.charAt(7) <= '9' && (following.charAt(8) == ' ' + || following.charAt(8) >= '\t' && following.charAt(8) <= '\r') + ? 6 + : 5; + } + + private String peekCharacters(int length) { + StringBuilder result = new StringBuilder(length); + try { + for (int i = 0; i < length; i++) { + result.append(readChar()); + } + } catch (java.io.IOException ignored) { + // Only the successfully read characters need to be rewound, including at EOF. + } + backup(result.length()); + return result.toString(); + } + + private void eraseCommentMarker(int length) throws java.io.IOException { + buffer[bufpos] = ' '; + for (int i = 1; i < length; i++) { + readChar(); + buffer[bufpos] = ' '; + } + backup(length - 1); + } + + private char mySqlCommentError(String message) { + mySqlCommentError = message; + return MYSQL_COMMENT_ERROR; + } + + protected final void UpdateLineColumn(char c) { + column++; + + if (c >= ' ' && !prevCharIsLF && !prevCharIsCR) { + // Fast path: printable ASCII, no pending newline + buflinecolumn[bufpos] = ((long) line << 32) | (column & 0xFFFFFFFFL); + return; + } + + // Slow path: newlines, carriage returns, tabs, control chars + if (prevCharIsLF) { + prevCharIsLF = false; + line += column = 1; + } else if (prevCharIsCR) { + prevCharIsCR = false; + if (c == '\n') { + prevCharIsLF = true; + } else { + line += column = 1; + } + } + + switch (c) { + case '\r': + prevCharIsCR = true; + break; + case '\n': + prevCharIsLF = true; + break; + case '\t': + column--; + column += tabSize - (column % tabSize); + break; + default: + break; + } + + buflinecolumn[bufpos] = ((long) line << 32) | (column & 0xFFFFFFFFL); + } + + /** + * Read a character. + */ + public final char readChar() throws java.io.IOException { + if (inBuf > 0) { + --inBuf; + + if (++bufpos == bufsize) { + bufpos = 0; + } + + totalCharsRead++; + + return buffer[bufpos]; + } + + if (++bufpos >= maxNextCharInd) { + FillBuff(); + } + + totalCharsRead++; + + char c = buffer[bufpos]; + + UpdateLineColumn(c); + return c; + } + + @Deprecated + /** + * @deprecated + * @see #getEndColumn + */ + + public int getColumn() { + return (int) buflinecolumn[bufpos]; + } + + @Deprecated + /** + * @deprecated + * @see #getEndLine + */ + + public int getLine() { + return (int) (buflinecolumn[bufpos] >>> 32); + } + + /** + * Get token end column number. + */ + public int getEndColumn() { + return (int) buflinecolumn[bufpos]; + } + + /** + * Get token end line number. + */ + public int getEndLine() { + return (int) (buflinecolumn[bufpos] >>> 32); + } + + /** + * Get token beginning column number. + */ + public int getBeginColumn() { + return (int) buflinecolumn[tokenBegin]; + } + + /** + * Get token beginning line number. + */ + public int getBeginLine() { + return (int) (buflinecolumn[tokenBegin] >>> 32); + } + + /** + * Backup a number of characters. + */ + public final void backup(int amount) { + inBuf += amount; + totalCharsRead -= amount; + if ((bufpos -= amount) < 0) { + bufpos += bufsize; + } + } + + /** + * Reinitialise. + */ + public void ReInit(Provider dstream, int startline, int startcolumn, int buffersize) { + matchBeginCount = 0; + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + if (buffer == null || buffersize != buffer.length) { + available = bufsize = buffersize; + buffer = new char[buffersize]; + buflinecolumn = new long[buffersize]; + } + prevCharIsLF = prevCharIsCR = false; + tokenBegin = inBuf = maxNextCharInd = 0; + bufpos = -1; + mySqlExecutableComment = false; + mySqlCommentError = null; + } + + /** + * Reinitialise. + */ + public void ReInit(Provider dstream, int startline, int startcolumn) { + ReInit(dstream, startline, startcolumn, 4096); + } + + /** + * Reinitialise. + */ + public void ReInit(Provider dstream) { + ReInit(dstream, 1, 1, 4096); + } + + /** + * Get token literal value. + */ + public String GetImage() { + // restore the `#` rewritten to HASH_SUBSTITUTION: only the comment + // token's own window starts with the sentinel (token-start rewrites + // only), so this is exact and covers every consumer of GetImage. + // The wiring check keeps parses that never opted in on the original + // cost (the stream is only wired through the feature consumers / + // withConfiguration) + if (featureConfiguration == null) { + return doGetImage(); + } + String image = doGetImage(); + if (!image.isEmpty() && image.charAt(0) == HASH_SUBSTITUTION) { + image = "#" + image.substring(1); + } else if (!image.isEmpty() && image.charAt(0) == MYSQL_MINUS_SUBSTITUTION) { + image = "-" + image.substring(1); + } + return image; + } + + private String doGetImage() { + if (bufpos >= tokenBegin) { + return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); + } else { + return new String(buffer, tokenBegin, bufsize - tokenBegin) + + new String(buffer, 0, bufpos + 1); + } + } + + /** + * Get the suffix. + */ + public char[] GetSuffix(int len) { + char[] ret = new char[len]; + + if ((bufpos + 1) >= len) { + System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); + } else { + System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); + System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); + } + + return ret; + } + + /** + * Reset buffer when finished. + */ + public void Done() { + buffer = null; + buflinecolumn = null; + } + + /** + * Method to adjust line and column numbers for the start of a token. + */ + public void adjustBeginLineColumn(int newLine, int newCol) { + int start = tokenBegin; + int len; + + if (bufpos >= tokenBegin) { + len = bufpos - tokenBegin + inBuf + 1; + } else { + len = bufsize - tokenBegin + bufpos + 1 + inBuf; + } + + int i = 0; + int j = 0; + int k; + int nextColDiff; + int columnDiff = 0; + + while (i < len && + (int) (buflinecolumn[j = start % bufsize] >>> 32) == (int) (buflinecolumn[k = + ++start % bufsize] >>> 32)) { + int colJ = (int) buflinecolumn[j]; + int colK = (int) buflinecolumn[k]; + nextColDiff = columnDiff + colK - colJ; + buflinecolumn[j] = ((long) newLine << 32) | ((newCol + columnDiff) & 0xFFFFFFFFL); + columnDiff = nextColDiff; + i++; + } + + if (i < len) { + buflinecolumn[j] = ((long) (newLine++) << 32) | ((newCol + columnDiff) & 0xFFFFFFFFL); + + while (i++ < len) { + int lineJ = (int) (buflinecolumn[j = start % bufsize] >>> 32); + int lineNext = (int) (buflinecolumn[++start % bufsize] >>> 32); + if (lineJ != lineNext) { + buflinecolumn[j] = + ((long) (newLine++) << 32) | (buflinecolumn[j] & 0xFFFFFFFFL); + } else { + buflinecolumn[j] = ((long) newLine << 32) | (buflinecolumn[j] & 0xFFFFFFFFL); + } + } + } + + line = (int) (buflinecolumn[j] >>> 32); + column = (int) buflinecolumn[j]; + } + + boolean getTrackLineColumn() { + return trackLineColumn; + } + + void setTrackLineColumn(boolean tlc) { + trackLineColumn = tlc; + } +} +/* JavaCC - OriginalChecksum=0cd74e5ad7a4ccb9188541ab8f8b35eb (do not edit this line) */ diff --git a/src/main/java/net/sf/jsqlparser/parser/StatementListener.java b/src/main/java/net/sf/jsqlparser/parser/StatementListener.java new file mode 100644 index 0000000000..3e26a00184 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/parser/StatementListener.java @@ -0,0 +1,20 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.parser; + +import net.sf.jsqlparser.statement.Statement; + +/** + * @author Tobias Warneke (t.warneke@gmx.net) + */ +public interface StatementListener { + + void accept(Statement statement); +} diff --git a/src/main/java/net/sf/jsqlparser/parser/feature/Feature.java b/src/main/java/net/sf/jsqlparser/parser/feature/Feature.java new file mode 100644 index 0000000000..60f8850dc7 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/parser/feature/Feature.java @@ -0,0 +1,1537 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2020 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.parser.feature; + +import net.sf.jsqlparser.expression.Function; +import net.sf.jsqlparser.expression.JdbcNamedParameter; +import net.sf.jsqlparser.expression.JdbcParameter; +import net.sf.jsqlparser.expression.OracleHierarchicalExpression; +import net.sf.jsqlparser.expression.OracleHint; +import net.sf.jsqlparser.expression.operators.relational.SupportsOldOracleJoinSyntax; +import net.sf.jsqlparser.parser.AbstractJSqlParser; +import net.sf.jsqlparser.statement.Block; +import net.sf.jsqlparser.statement.Commit; +import net.sf.jsqlparser.statement.CreateFunctionalStatement; +import net.sf.jsqlparser.statement.DeclareStatement; +import net.sf.jsqlparser.statement.DescribeStatement; +import net.sf.jsqlparser.statement.ExplainStatement; +import net.sf.jsqlparser.statement.PluginStatement; +import net.sf.jsqlparser.statement.PrepareTransactionStatement; +import net.sf.jsqlparser.statement.ResetStatement; +import net.sf.jsqlparser.statement.SetConstraintsStatement; +import net.sf.jsqlparser.statement.SetStatement; +import net.sf.jsqlparser.statement.SetTransactionStatement; +import net.sf.jsqlparser.statement.ShowColumnsStatement; +import net.sf.jsqlparser.statement.ShowStatement; +import net.sf.jsqlparser.statement.TableMaintenanceStatement; +import net.sf.jsqlparser.statement.UseStatement; +import net.sf.jsqlparser.statement.XaStatement; +import net.sf.jsqlparser.statement.admin.FlushStatement; +import net.sf.jsqlparser.statement.admin.KillStatement; +import net.sf.jsqlparser.statement.alter.Alter; +import net.sf.jsqlparser.statement.alter.AlterEventTrigger; +import net.sf.jsqlparser.statement.alter.sequence.AlterSequence; +import net.sf.jsqlparser.statement.analyze.Analyze; +import net.sf.jsqlparser.statement.maintenance.CheckpointStatement; +import net.sf.jsqlparser.statement.maintenance.ClusterStatement; +import net.sf.jsqlparser.statement.maintenance.VacuumStatement; +import net.sf.jsqlparser.statement.comment.Comment; +import net.sf.jsqlparser.statement.create.database.CreateDatabase; +import net.sf.jsqlparser.statement.create.function.CreateFunction; +import net.sf.jsqlparser.statement.create.index.CreateIndex; +import net.sf.jsqlparser.statement.create.procedure.CreateProcedure; +import net.sf.jsqlparser.statement.create.schema.CreateSchema; +import net.sf.jsqlparser.statement.create.sequence.CreateSequence; +import net.sf.jsqlparser.statement.create.synonym.CreateSynonym; +import net.sf.jsqlparser.statement.create.table.CreateTable; +import net.sf.jsqlparser.statement.create.trigger.CreateEventTrigger; +import net.sf.jsqlparser.statement.create.view.AlterView; +import net.sf.jsqlparser.statement.create.view.CreateView; +import net.sf.jsqlparser.statement.cursor.CloseCursorStatement; +import net.sf.jsqlparser.statement.cursor.DeclareCursorStatement; +import net.sf.jsqlparser.statement.cursor.FetchCursorStatement; +import net.sf.jsqlparser.statement.delete.Delete; +import net.sf.jsqlparser.statement.drop.Drop; +import net.sf.jsqlparser.statement.execute.Execute; +import net.sf.jsqlparser.statement.grant.Grant; +import net.sf.jsqlparser.statement.handler.HandlerStatement; +import net.sf.jsqlparser.statement.lock.BackupLockStatement; +import net.sf.jsqlparser.statement.lock.UnlockStatement; +import net.sf.jsqlparser.statement.merge.Merge; +import net.sf.jsqlparser.statement.refresh.RefreshMaterializedViewStatement; +import net.sf.jsqlparser.statement.reindex.Reindex; +import net.sf.jsqlparser.statement.resourcegroup.AlterResourceGroup; +import net.sf.jsqlparser.statement.resourcegroup.CreateResourceGroup; +import net.sf.jsqlparser.statement.resourcegroup.SetResourceGroup; +import net.sf.jsqlparser.statement.role.ReassignOwned; +import net.sf.jsqlparser.statement.select.Fetch; +import net.sf.jsqlparser.statement.select.First; +import net.sf.jsqlparser.statement.select.KSQLWindow; +import net.sf.jsqlparser.statement.select.Limit; +import net.sf.jsqlparser.statement.select.Offset; +import net.sf.jsqlparser.statement.select.OptimizeFor; +import net.sf.jsqlparser.statement.select.Pivot; +import net.sf.jsqlparser.statement.select.PivotXml; +import net.sf.jsqlparser.statement.select.Skip; +import net.sf.jsqlparser.statement.select.TableFunction; +import net.sf.jsqlparser.statement.select.Top; +import net.sf.jsqlparser.statement.select.UnPivot; +import net.sf.jsqlparser.statement.securitylabel.SecurityLabel; +import net.sf.jsqlparser.statement.show.*; +import net.sf.jsqlparser.statement.truncate.Truncate; +import net.sf.jsqlparser.statement.update.Update; +import net.sf.jsqlparser.statement.upsert.Upsert; + +public enum Feature { + + // SQL KEYWORD FEATURES + /** + * "SELECT" + */ + select, + /** Structured FROM row pattern recognition. */ + matchRecognize, + /** BigQuery longest-match option. */ + matchRecognizeOptions, + /** + * "GROUP BY" + */ + selectGroupBy, + /** Explicit ASC/DESC on GROUP BY items in legacy MySQL. */ + selectGroupByOrdering, + /** + * "GROUPING SETS" + */ + selectGroupByGroupingSets, + /** + * "HAVING" + */ + selectHaving, + /** + * "INTO table(, table)*" + */ + selectInto, + + /** + * @see Limit + */ + limit, + /** + * "LIMIT NULL" + * + * @see Limit#isLimitNull() + */ + limitNull, + /** + * "LIMIT ALL" + * + * @see Limit#isLimitAll() + */ + limitAll, + /** + * "LIMIT offset, limit" + * + * @see Limit#getOffset() + */ + limitOffset, + /** + * "OFFSET offset" + * + * @see Offset + */ + offset, + /** + * "OFFSET offset param" where param is ROW | ROWS + * + * @see Offset#getOffsetParam() + */ + offsetParam, + + /** + * @see Fetch + */ + fetch, + /** + * "FETCH FIRST row_count (ROW | ROWS) ONLY" + * + * @see Fetch#isFetchParamFirst() + */ + fetchFirst, + /** + * "FETCH NEXT row_count (ROW | ROWS) ONLY" if not {@link #fetchFirst} + * + * @see Fetch#isFetchParamFirst() + */ + fetchNext, + + /** + * "JOIN" + */ + join, + /** + * join tables by ", OUTER" placing the join specification in WHERE-clause + */ + joinOuterSimple, + /** + * join tables by "," placing the join specification in WHERE-clause + */ + joinSimple, + /** + * "RIGHT" join + */ + joinRight, + /** + * "NATURAL" join + */ + joinNatural, + /** + * "FULL" join + */ + joinFull, + /** + * "LEFT" join + */ + joinLeft, + /** + * "CROSS" join + */ + joinCross, + /** + * "OUTER" join + */ + joinOuter, + /** + * "SEMI" join + */ + joinSemi, + /** + * @see net.sf.jsqlparser.statement.select.Join#isAnti() + */ + joinAnti, + /** + * "INNER" join + */ + joinInner, + /** + * "STRAIGHT_JOIN" join + */ + joinStraight, + /** + * "APPLY" join + */ + joinApply, + + /** Nearest-match ASOF join. */ + joinAsOf, + + joinWindow, joinUsingColumns, + + /** + * "SKIP variable" | "SKIP ?" | "SKIP rowCount" + * + * @see Skip + */ + skip, + /** + * "FIRST" \?|[0-9]+|variable or "LIMIT" \?|[0-9]+|variable + * + * @see First + */ + first, + /** + * "TOP" ? "PERCENT" + * + * @see Top + */ + top, + /** + * "OPTIMIZE FOR rowCount ROWS" + * + * @see OptimizeFor + */ + optimizeFor, + + /** + * "UNIQUE" keyword + */ + selectUnique, + /** + * "DISTINCT" keyword + */ + distinct, + /** + * "DISTINCT ON (col1, ...)" + */ + distinctOn, + + /** + * "ORDER BY" + */ + orderBy, + /** + * "ORDER BY expression [ NULLS { FIRST | LAST } ]" + */ + orderByNullOrdering, + + /** + * "FOR UPDATE" + */ + selectForUpdate, + + /** + * "FOR SHARE" + */ + selectForShare, + + /** + * "FOR KEY SHARE" + */ + selectForKeyShare, + + /** + * "NO KEY UPDATE" + */ + selectForNoKeyUpdate, + + /** + * "FOR UPDATE OF table" + */ + selectForUpdateOfTable, + /** + * "FOR UPDATE WAIT timeout" + */ + selectForUpdateWait, + /** + * "FOR UPDATE NOWAIT" + */ + selectForUpdateNoWait, + /** + * "FOR UPDATE SKIP LOCKED" + */ + selectForUpdateSkipLocked, + + + /** + * SQL "INSERT" statement is allowed + */ + insert, + /** + * "INSERT .. SELECT" + */ + insertFromSelect, + /** + * "LOW_PRIORITY | DELAYED | HIGH_PRIORITY | IGNORE" + */ + insertModifierPriority, + /** + * "IGNORE" + */ + insertModifierIgnore, + /** + * "INSERT .. SET" + */ + insertUseSet, + /** + * "ON DUPLICATE KEY UPDATE" + */ + insertUseDuplicateKeyUpdate, + /** + * "RETURNING *" + */ + insertReturningAll, + /** + * "RETURNING expr(, expr)*" + * + * @see net.sf.jsqlparser.expression.operators.relational.ExpressionList + */ + insertReturningExpressionList, + + /** + * "VALUES" + */ + insertValues, + /** + * @see net.sf.jsqlparser.statement.select.Values + */ + values, + + /** + * SQL "TABLE table_name [ORDER BY column_name] [LIMIT number [OFFSET number]]“ + */ + tableStatement, + + /** + * SQL "UPDATE" statement is allowed + * + * @see Update + */ + update, + + /** Application-time FOR PORTION OF in UPDATE and DELETE. */ + forPortion, + /** + * "UPDATE table1 SET ... FROM table2 + */ + updateFrom, + /** + * "UPDATE table1, table2 ..." + */ + updateJoins, + /** + * UPDATE table SET (col, ...) = (SELECT col, ... )" + */ + updateUseSelect, updateOrderBy, updateLimit, + /** + * "RETURNING expr(, expr)*" + * + * @see net.sf.jsqlparser.statement.select.SelectItem + */ + updateReturning, + /** + * SQL "DELETE" statement is allowed + * + * @see Delete + */ + delete, + /** + * "DELETE FROM table1, table1 ..." + */ + deleteJoin, + /** + * "DELETE table1, table1 FROM table ..." + */ + deleteTables, + /** + * "LIMIT row_count" + */ + deleteLimit, + /** + * "ORDER BY ..." + */ + deleteOrderBy, + /** + * "RETURNING expr(, expr)*" + * + * @see net.sf.jsqlparser.statement.select.SelectItem + */ + deleteReturningExpressionList, + + /** + * SQL "UPSERT" statement is allowed + * + * @see Upsert + * @see https://wiki.postgresql.org/wiki/UPSERT + */ + upsert, + /** + * SQL "MERGE" statement is allowed + * + * @see Merge + */ + merge, + + /** + * SQL "ALTER" statement is allowed + * + * @see Alter + */ + alterTable, + /** + * SQL "ALTER SEQUENCE" statement is allowed + * + * @see AlterSequence + */ + alterSequence, + /** + * SQL "ALTER VIEW" statement is allowed + * + * @see AlterView + */ + alterView, + + /** + * SQL "REFRESH MATERIALIZED VIEW" statement is allowed + * + * @see RefreshMaterializedViewStatement + */ + refreshMaterializedView, refreshMaterializedWithDataView, refreshMaterializedWithNoDataView, + + /** + * SQL "REPLACE VIEW" statement is allowed + * + * @see AlterView + */ + alterViewReplace, + /** + * SQL "ALTER INDEX" statement is allowed + */ + alterIndex, + + /** + * MySQL and PostgreSQL "CREATE TABLESPACE" statement is allowed + * + * @see net.sf.jsqlparser.statement.create.tablespace.CreateTablespace + */ + createTablespace, + /** + * MySQL and PostgreSQL "ALTER TABLESPACE" statement is allowed + * + * @see net.sf.jsqlparser.statement.alter.AlterTablespace + */ + alterTablespace, + /** + * MySQL "CREATE SPATIAL REFERENCE SYSTEM" statement is allowed + * + * @see net.sf.jsqlparser.statement.create.spatial.CreateSpatialReferenceSystem + */ + createSpatialReferenceSystem, + /** + * MySQL "ALTER INSTANCE" statement is allowed + * + * @see net.sf.jsqlparser.statement.alter.AlterInstance + */ + alterInstance, + + + /** + * SQL "ANALYZE" statement is allowed + * + * @see Analyze + */ + analyze, + + /** + * MySQL/MariaDB "CHECK TABLE", "CHECKSUM TABLE", "OPTIMIZE TABLE" and "REPAIR TABLE" statements + * are allowed + * + * @see TableMaintenanceStatement + */ + tableMaintenance, + + /** + * MySQL "FLUSH" statement is allowed + * + * @see FlushStatement + */ + flush, + + /** + * MySQL "KILL" statement is allowed + * + * @see KillStatement + */ + kill, + + /** + * MySQL "HANDLER ... OPEN", "HANDLER ... READ" and "HANDLER ... CLOSE" statements are allowed + * + * @see HandlerStatement + */ + handler, + + /** + * PostgreSQL "VACUUM" statement is allowed + * + * @see VacuumStatement + */ + vacuum, + + /** + * PostgreSQL "CLUSTER" statement is allowed + * + * @see ClusterStatement + */ + cluster, + + /** + * PostgreSQL "CHECKPOINT" statement is allowed + * + * @see CheckpointStatement + */ + checkpoint, + + /** + * SQL "TRUNCATE" statement is allowed + * + * @see Truncate + */ + truncate, + /** + * SQL "CALL|EXEC|EXECUTE" stored procedure is allowed + * + * @see Execute + */ + oracleBlock, + + execute, executeExec, executeCall, executeExecute, doStatement, insertBulk, + + /** + * SQL "EXECUTE" statement is allowed + */ + executeStatement, + /** + * SQL "EXECUTE IMMEDIATE" statement is allowed + */ + executeStatementImmediate, + + /** + * MySQL "EXECUTE name USING @variable, ..." of a prepared statement is allowed + * + * @see Execute#getUsingVariables() + */ + executeUsing, + /** + * "PREPARE" and "DEALLOCATE" of a prepared statement are allowed + * + * @see net.sf.jsqlparser.statement.PrepareStatement + * @see net.sf.jsqlparser.statement.DeallocateStatement + */ + prepare, deallocate, + /** + * SQL "REPLACE" statement is allowed + */ + @Deprecated + replace, + /** + * SQL "DROP" statement is allowed + * + * @see Drop + */ + drop, dropTable, dropIndex, dropView, dropSchema, dropSequence, dropTableIfExists, dropIndexIfExists, dropViewIfExists, dropSchemaIfExists, dropSequenceIfExists, + /** + * Oracle "PURGE" statement is allowed + * + * @see net.sf.jsqlparser.statement.PurgeStatement + */ + purge, + /** + * MySQL/MariaDB "PURGE BINARY LOGS" and MariaDB "PURGE MASTER LOGS" statements are allowed + * + * @see net.sf.jsqlparser.statement.PurgeStatement + */ + purgeBinaryLogs, + /** + * PostgreSQL "REASSIGN OWNED BY ... TO ..." statement is allowed + * + * @see ReassignOwned + */ + reassignOwned, + + /** + * SQL "CREATE DATABASE" statement is allowed + * + * @see CreateDatabase + */ + createDatabase, + /** + * SQL "ALTER DATABASE" statement is allowed + * + * @see net.sf.jsqlparser.statement.alter.database.AlterDatabase + */ + alterDatabase, + /** + * "ALTER SESSION" and "ALTER SYSTEM" statements are allowed + * + * @see net.sf.jsqlparser.statement.alter.AlterSession + * @see net.sf.jsqlparser.statement.alter.AlterSystemStatement + */ + alterSession, alterSystem, + /** + * SQL "CREATE SCHEMA" statement is allowed + * + * @see CreateSchema + */ + createSchema, + /** SQL ALTER SCHEMA rename and owner changes. */ + alterSchema, + /** + * SQL "CREATE VIEW" statement is allowed + * + * @see CreateView + */ + createView, + /** + * "CREATE FORCE VIEW" + */ + createViewForce, + /** + * "CREATE TEMPORARAY VIEW" + */ + createViewTemporary, + /** + * "CREATE OR REPLACE VIEW" + */ + createOrReplaceView, + /** + * SQL "CREATE MATERIALIZED VIEW" statement is allowed + */ + createViewMaterialized, + + /** + * SQL "CREATE VIEW(x comment 'x', y comment 'y') comment 'view'" statement is allowed + */ + createViewWithComment, + + /** + * SQL "CREATE TABLE" statement is allowed + * + * @see CreateTable + */ + createTable, + /** + * "CREATE GLOBAL UNLOGGED" + */ + createTableUnlogged, + /** + * i.e. "CREATE GLOBAL TEMPORARY TABLE", "CREATE SHARDED TABLE" + */ + createTableCreateOptionStrings, + /** + * i.e. "ENGINE = InnoDB AUTO_INCREMENT = 8761 DEFAULT CHARSET = utf8" + */ + createTableTableOptionStrings, + /** + * "CREATE TABLE IF NOT EXISTS table" + */ + createTableIfNotExists, + /** + * " ROW MOVEMENT" + */ + createTableRowMovement, + /** + * "CREATE TABLE (colspec) SELECT ... + */ + createTableFromSelect, + /** + * SQL "CREATE INDEX" statement is allowed + * + * @see CreateIndex + */ + createIndex, + /** + * SQL "CREATE SEQUENCE" statement is allowed + * + * @see CreateSequence + */ + createSequence, createAccessMethod, createAccessMethodTable, + /** Publication and subscription definitions. */ + createForeignDataWrapper, alterForeignDataWrapper, createServer, alterServer, createUserMapping, alterUserMapping, + /** + * PostgreSQL "IMPORT FOREIGN SCHEMA" statement is allowed + * + * @see net.sf.jsqlparser.statement.foreign.ImportForeignSchema + */ + importForeignSchema, + + createRule, notifyStatement, createTextSearchConfiguration, alterTextSearchConfiguration, createCollation, alterCollation, + + createPublication, alterPublication, createSubscription, alterSubscription, + /** + * Structured type, domain and extension statements. + */ + createType, alterType, createDomain, alterDomain, createExtension, alterExtension, + /** + * PostgreSQL "CREATE POLICY", "ALTER POLICY", "CREATE STATISTICS" and "ALTER STATISTICS" + * statements are allowed + */ + createPolicy, alterPolicy, createStatistics, alterStatistics, + /** + * SQL "CREATE SYNONYM" statement is allowed + * + * @see CreateSynonym + */ + createSynonym, + /** + * SQL "CREATE TRIGGER" statement is allowed + */ + createTrigger, + /** + * MySQL/MariaDB "CREATE EVENT" and "ALTER EVENT" statements are allowed + * + * @see net.sf.jsqlparser.statement.create.event.CreateEvent + * @see net.sf.jsqlparser.statement.create.event.AlterEvent + */ + createEvent, alterEvent, + /** + * PostgreSQL "CREATE EVENT TRIGGER" and "ALTER EVENT TRIGGER" statements are allowed + * + * @see CreateEventTrigger + * @see AlterEventTrigger + */ + createEventTrigger, alterEventTrigger, + /** + * PostgreSQL "REINDEX" statement is allowed; "REINDEX … CONCURRENTLY" additionally requires + * {@link #reindexConcurrently} + * + * @see Reindex + */ + reindex, reindexConcurrently, + /** + * PostgreSQL "SECURITY LABEL" statement is allowed + * + * @see SecurityLabel + */ + securityLabel, + /** + * SQL "COMMIT" statement is allowed + * + * @see Commit + */ + commit, + /** SQL "ROLLBACK" statement is allowed */ + rollback, + /** START TRANSACTION and dialect-specific BEGIN transaction statements. */ + startTransaction, + /** SAVEPOINT statements. */ + savepoint, + /** RELEASE [SAVEPOINT] statements. */ + releaseSavepoint, + /** Explicit AND [NO] CHAIN transaction completion. */ + transactionChain, + /** Isolation level specified directly on BEGIN or START TRANSACTION. */ + transactionIsolationLevel, + /** PostgreSQL [NOT] DEFERRABLE transaction characteristic. */ + transactionDeferrable, + /** MySQL WITH CONSISTENT SNAPSHOT transaction characteristic. */ + transactionConsistentSnapshot, + /** MySQL [NO] RELEASE after COMMIT or ROLLBACK. */ + transactionRelease, + /** PostgreSQL END and ABORT, the alternative spellings of COMMIT and ROLLBACK. */ + transactionEndAbort, + /** + * SET TRANSACTION characteristics + * + * @see SetTransactionStatement + */ + setTransaction, + /** MySQL SET GLOBAL TRANSACTION. */ + setTransactionGlobal, + /** MySQL SET PERSIST TRANSACTION and SET PERSIST_ONLY TRANSACTION. */ + setTransactionPersist, + /** PostgreSQL SET SESSION CHARACTERISTICS AS TRANSACTION. */ + setTransactionSessionCharacteristics, + /** PostgreSQL SET TRANSACTION SNAPSHOT. */ + setTransactionSnapshot, + /** + * SET CONSTRAINTS {ALL | names} {DEFERRED | IMMEDIATE} + * + * @see SetConstraintsStatement + */ + setConstraints, + /** + * PostgreSQL two-phase commit: PREPARE TRANSACTION, COMMIT PREPARED and ROLLBACK PREPARED + * + * @see PrepareTransactionStatement + */ + twoPhaseCommit, + /** + * MySQL and MariaDB XA statements: XA START, END, PREPARE, COMMIT, ROLLBACK and RECOVER + * + * @see XaStatement + */ + xa, + /** + * MySQL and MariaDB INSTALL PLUGIN and UNINSTALL PLUGIN + * + * @see PluginStatement + */ + installPlugin, + /** + * MySQL INSTALL COMPONENT and UNINSTALL COMPONENT + * + * @see PluginStatement + */ + installComponent, + /** + * SQL "LOCK TABLE" statement is allowed + * + * @see net.sf.jsqlparser.statement.lock.LockStatement + */ + lock, + /** + * MySQL/MariaDB "UNLOCK TABLES" statement is allowed + * + * @see UnlockStatement + */ + unlockTables, + /** + * MySQL "LOCK INSTANCE FOR BACKUP" and "UNLOCK INSTANCE" statements are allowed + * + * @see BackupLockStatement + */ + backupLock, + /** + * MySQL "CREATE RESOURCE GROUP" statement is allowed + * + * @see CreateResourceGroup + */ + createResourceGroup, + /** + * MySQL "ALTER RESOURCE GROUP" statement is allowed + * + * @see AlterResourceGroup + */ + alterResourceGroup, + /** + * MySQL "SET RESOURCE GROUP" statement is allowed + * + * @see SetResourceGroup + */ + setResourceGroup, + /** + * MySQL "CHANGE REPLICATION SOURCE TO" statement is allowed + * + * @see net.sf.jsqlparser.statement.replication.ChangeReplicationSourceStatement + */ + changeReplicationSource, + /** + * MySQL "CHANGE REPLICATION FILTER" statement is allowed + * + * @see net.sf.jsqlparser.statement.replication.ChangeReplicationFilterStatement + */ + changeReplicationFilter, + /** + * MySQL "START REPLICA" statement is allowed + * + * @see net.sf.jsqlparser.statement.replication.StartReplicaStatement + */ + startReplica, + /** + * MySQL "STOP REPLICA" statement is allowed + * + * @see net.sf.jsqlparser.statement.replication.StopReplicaStatement + */ + stopReplica, + /** + * MySQL "RESET BINARY LOGS AND GTIDS" and "RESET REPLICA" statements are allowed + * + * @see net.sf.jsqlparser.statement.replication.ResetReplicationStatement + */ + resetReplication, + /** + * SQL "COMMENT ON" statement is allowed + * + * @see Comment + */ + comment, + /** + * "COMMENT ON table" + */ + commentOnTable, + /** + * "COMMENT ON column" + */ + commentOnColumn, + /** + * "COMMENT ON view" + */ + commentOnView, + + /** Additional structured catalog targets of COMMENT ON. */ + commentOnIndex, commentOnSchema, commentOnSequence, commentOnDomain, commentOnType, commentOnMaterializedView, commentOnFunction, commentOnConstraint, + + /** COMMENT ON TRIGGER, POLICY or RULE within a table. */ + commentOnTrigger, commentOnPolicy, commentOnRule, + + /** COMMENT ON PROCEDURE, ROUTINE, AGGREGATE or CAST. */ + commentOnProcedure, commentOnRoutine, commentOnAggregate, commentOnCast, + + /** COMMENT ON COLLATION, FOREIGN TABLE or STATISTICS. */ + commentOnCollation, commentOnForeignTable, commentOnStatistics, + + /** COMMENT ON DATABASE, ROLE or TABLESPACE. */ + commentOnDatabase, commentOnRole, commentOnTablespace, + + /** COMMENT ON ACCESS METHOD, EXTENSION, FOREIGN DATA WRAPPER, LANGUAGE or SERVER. */ + commentOnAccessMethod, commentOnExtension, commentOnForeignDataWrapper, commentOnLanguage, commentOnServer, + + /** COMMENT ON EVENT TRIGGER, PUBLICATION or SUBSCRIPTION. */ + commentOnEventTrigger, commentOnPublication, commentOnSubscription, + + /** COMMENT ON OPERATOR, OPERATOR CLASS or OPERATOR FAMILY. */ + commentOnOperator, commentOnOperatorClass, commentOnOperatorFamily, + + /** COMMENT ON CONVERSION, LARGE OBJECT or TRANSFORM. */ + commentOnConversion, commentOnLargeObject, commentOnTransform, + + /** COMMENT ON TEXT SEARCH CONFIGURATION, DICTIONARY, PARSER or TEMPLATE. */ + commentOnTextSearchConfiguration, commentOnTextSearchDictionary, commentOnTextSearchParser, commentOnTextSearchTemplate, + + /** + * SQL "DESCRIBE" statement is allowed + * + * @see DescribeStatement + */ + describe, + + /** + * SQL "DESC" statement is allowed + * + * @see DescribeStatement + */ + desc, + + /** + * SQL "EXPLAIN" statement is allowed + * + * @see ExplainStatement + */ + explain, + /** + * @see ShowStatement + */ + show, + /** + * @see ShowTablesStatement + */ + showTables, + /** + * @see ShowColumnsStatement + */ + showColumns, + /** + * @see ShowIndexStatement + */ + showIndex, + /** + * MySQL/MariaDB "SHOW TABLE STATUS" statement is allowed + * + * @see ShowTableStatusStatement + */ + showTableStatus, + /** + * MySQL/MariaDB "SHOW CREATE" statement is allowed + * + * @see ShowCreateStatement + */ + showCreate, + /** + * The MySQL/MariaDB "SHOW" statements of server settings, state and object lists, such as "SHOW + * VARIABLES", "SHOW GRANTS" or "SHOW BINLOG EVENTS" + * + * @see MySqlShowStatement + */ + mySqlShow, + /** + * @see UseStatement + */ + use, + /** SQL Server session permission to insert explicit identity values into a table. */ + setIdentityInsert, + /** + * @see Grant + */ + grant, revoke, createRole, alterRole, alterDefaultPrivileges, + /** + * MySQL/MariaDB account management: "CREATE USER", "ALTER USER", "RENAME USER", "SET ROLE", + * "SET DEFAULT ROLE" and "SET PASSWORD" + * + * @see net.sf.jsqlparser.statement.create.user.CreateUser + * @see net.sf.jsqlparser.statement.alter.AlterUser + * @see net.sf.jsqlparser.statement.alter.RenameUser + * @see net.sf.jsqlparser.statement.SetRoleStatement + * @see net.sf.jsqlparser.statement.SetDefaultRoleStatement + * @see net.sf.jsqlparser.statement.SetPasswordStatement + */ + createUser, alterUser, renameUser, setRole, setDefaultRole, setPassword, + /** + * @see Function + */ + function, + /** + * @see CreateFunction + */ + createFunction, + /** + * @see CreateProcedure + */ + createProcedure, + /** + * @see CreateFunctionalStatement + */ + functionalStatement, + + alterFunction, alterProcedure, createOrAlterRoutine, + /** + * PostgreSQL "ALTER ROUTINE" statement is allowed + * + * @see net.sf.jsqlparser.statement.alter.AlterRoutine + */ + alterRoutine, + /** + * PostgreSQL "ALTER TRIGGER" statement is allowed + * + * @see net.sf.jsqlparser.statement.alter.AlterTrigger + */ + alterTrigger, + /** + * PostgreSQL "ALTER RULE" statement is allowed + * + * @see net.sf.jsqlparser.statement.alter.AlterRule + */ + alterRule, + /** + * PostgreSQL "CREATE CAST" statement is allowed + * + * @see net.sf.jsqlparser.statement.create.cast.CreateCast + */ + createCast, + /** + * PostgreSQL "CREATE TRANSFORM" statement is allowed + * + * @see net.sf.jsqlparser.statement.create.transform.CreateTransform + */ + createTransform, + /** + * PostgreSQL "CREATE CONVERSION" statement is allowed + * + * @see net.sf.jsqlparser.statement.create.conversion.CreateConversion + */ + createConversion, + /** + * PostgreSQL "ALTER CONVERSION" statement is allowed + * + * @see net.sf.jsqlparser.statement.alter.AlterConversion + */ + alterConversion, + /** + * PostgreSQL CREATE metadata statement is allowed. + * + * @see net.sf.jsqlparser.statement.create.language.CreateLanguage + */ + createLanguage, + /** + * PostgreSQL ALTER metadata statement is allowed. + * + * @see net.sf.jsqlparser.statement.alter.AlterLanguage + */ + alterLanguage, + /** + * PostgreSQL ALTER metadata statement is allowed. + * + * @see net.sf.jsqlparser.statement.alter.AlterLargeObject + */ + alterLargeObject, + /** + * PostgreSQL CREATE metadata statement is allowed. + * + * @see net.sf.jsqlparser.statement.create.textsearch.CreateTextSearchDictionary + */ + createTextSearchDictionary, + /** + * PostgreSQL ALTER metadata statement is allowed. + * + * @see net.sf.jsqlparser.statement.alter.AlterTextSearchDictionary + */ + alterTextSearchDictionary, + /** + * PostgreSQL CREATE metadata statement is allowed. + * + * @see net.sf.jsqlparser.statement.create.textsearch.CreateTextSearchParser + */ + createTextSearchParser, + /** + * PostgreSQL ALTER metadata statement is allowed. + * + * @see net.sf.jsqlparser.statement.alter.AlterTextSearchParser + */ + alterTextSearchParser, + /** + * PostgreSQL CREATE metadata statement is allowed. + * + * @see net.sf.jsqlparser.statement.create.textsearch.CreateTextSearchTemplate + */ + createTextSearchTemplate, + /** + * PostgreSQL ALTER metadata statement is allowed. + * + * @see net.sf.jsqlparser.statement.alter.AlterTextSearchTemplate + */ + alterTextSearchTemplate, + /** + * PostgreSQL "CREATE OPERATOR" statement is allowed + * + * @see net.sf.jsqlparser.statement.create.operator.CreateOperator + */ + createOperator, + /** + * PostgreSQL "CREATE OPERATOR CLASS" statement is allowed + * + * @see net.sf.jsqlparser.statement.create.operator.CreateOperatorClass + */ + createOperatorClass, + /** + * PostgreSQL "CREATE OPERATOR FAMILY" statement is allowed + * + * @see net.sf.jsqlparser.statement.create.operator.CreateOperatorFamily + */ + createOperatorFamily, + /** + * PostgreSQL "CREATE AGGREGATE" statement is allowed + * + * @see net.sf.jsqlparser.statement.create.aggregate.CreateAggregate + */ + createAggregate, + /** + * PostgreSQL "ALTER OPERATOR" statement is allowed + * + * @see net.sf.jsqlparser.statement.alter.AlterOperator + */ + alterOperator, + /** + * PostgreSQL "ALTER OPERATOR CLASS" statement is allowed + * + * @see net.sf.jsqlparser.statement.alter.AlterOperatorClass + */ + alterOperatorClass, + /** + * PostgreSQL "ALTER OPERATOR FAMILY" statement is allowed + * + * @see net.sf.jsqlparser.statement.alter.AlterOperatorFamily + */ + alterOperatorFamily, + /** + * PostgreSQL "ALTER AGGREGATE" statement is allowed + * + * @see net.sf.jsqlparser.statement.alter.AlterAggregate + */ + alterAggregate, + /** + * SQL block starting with "BEGIN" and ends with "END" statement is allowed + * + * @see Block + */ + block, + /** + * @see DeclareStatement + */ + declare, + /** + * PostgreSQL "DECLARE name CURSOR FOR query" statement is allowed + * + * @see DeclareCursorStatement + */ + declareCursor, + /** + * PostgreSQL "FETCH" and "MOVE" statements of a cursor are allowed + * + * @see FetchCursorStatement + */ + fetchCursor, + /** + * PostgreSQL "CLOSE" statement of a cursor is allowed + * + * @see CloseCursorStatement + */ + closeCursor, + + /** SQL Server local table variables in queries and DML targets. */ + tableVariable, + /** + * @see SetStatement + */ + set, + /** PostgreSQL SET configuration_parameter TO value. */ + setAssignmentTo, + /** SQL Server SET option [, option] ON | OFF. */ + sqlServerSetOptions, + /** + * @see ResetStatement + */ + reset, + /** + * PostgreSQL "DISCARD" statement is allowed + * + * @see net.sf.jsqlparser.statement.DiscardStatement + */ + discard, + /** + * PostgreSQL "LISTEN" and "UNLISTEN" statements are allowed + * + * @see net.sf.jsqlparser.statement.notify.ListenStatement + */ + listen, + /** + * MySQL "RESET PERSIST" statement is allowed + * + * @see ResetStatement#isPersist() + */ + resetPersist, + /** + * @see Pivot + */ + pivot, + /** + * @see UnPivot + */ + unpivot, + /** + * @see PivotXml + */ + pivotXml, + + setOperation, setOperationUnion, setOperationIntersect, setOperationExcept, setOperationMinus, + + /** + * "WITH name query" + */ + withItem, withItemRecursive, + + lateralSubSelect, + /** + * @see net.sf.jsqlparser.statement.select.Values + */ + valuesList, + /** + * @see TableFunction + */ + tableFunction, + + // JDBC + /** + * @see JdbcParameter + */ + jdbcParameter, + /** + * @see JdbcNamedParameter + */ + jdbcNamedParameter, + + // EXPRESSIONS + /** + * "LIKE" + */ + exprLike, + /** + * "SIMILAR TO" + */ + exprSimilarTo, + + // VENDOR SPECIFIC SYNTAX FEATURES + + /** + * @see KSQLWindow + */ + kSqlWindow, + + // ORACLE + + /** + * allows old oracle join syntax (+) + * + * @see SupportsOldOracleJoinSyntax + */ + oracleOldJoinSyntax, + /** + * allows oracle prior position + * + * @see SupportsOldOracleJoinSyntax + */ + oraclePriorPosition, + /** + * @see OracleHint + */ + oracleHint, + /** + * oracle SQL "CONNECT BY" + * + * @see OracleHierarchicalExpression + */ + oracleHierarchicalExpression, oracleOrderBySiblings, + + // MYSQL + + mySqlHintStraightJoin, mysqlSqlCacheFlag, mysqlCalcFoundRows, mysqlSelectModifiers, + + // SQLSERVER + + /** + * "FOR XML PATH(...)" + */ + selectForXmlPath, + + /** + * allows square brackets for names, disabled by default + */ + allowSquareBracketQuotation(false), + + /** + * allow parsing of RDBMS specific syntax by switching off SQL Standard Compliant Syntax + */ + allowPostgresSpecificSyntax(false), + + /** Enables legacy GROUP BY ordering with the MYSQL dialect; disabled by default. */ + allowLegacyMySqlGroupBy(false), + + /** + * Target MySQL version for executable comments, encoded as major * 10000 + minor * 100 + patch. + * A negative value leaves the version unspecified: conditional comments then fail instead of + * silently discarding SQL. Only used with the MYSQL dialect; unversioned comments need no + * value. + */ + mySqlServerVersion(-1), + + // PERFORMANCE + + /** + * allows complex expression parameters or named parameters for functions will be switched off, + * when deep nesting of functions is detected + */ + allowComplexParsing(true), + + /** + * allows passing through Unsupported Statements as a plain List of Tokens needs to be switched + * off, when VALIDATING statements or parsing blocks + */ + allowUnsupportedStatements(false), + + timeOut(8000), + + /** + * allows Backslash '\' as Escape Character + */ + allowBackslashEscapeCharacter(false), + + /** + * allows double quoted String Literals (BigQuery, Spark/Databricks, MySQL default sql_mode); + * disabled by default, where double quotes stay quoted identifiers (ANSI SQL) + */ + allowDoubleQuotedStrings(false), + + /** + * Recognizes PostgreSQL $tag$...$tag$ literals; disabled by default to preserve unquoted + * identifiers, enabled by the PostgreSQL dialect preset. Untagged $$ literals are unaffected. + */ + allowDollarQuotedStringTags(false), + + /** + * concatenates adjacent String Literals: NEWLINE when separated by whitespace with at least one + * newline (the SQL standard and PostgreSQL), WHITESPACE across any whitespace (GoogleSQL, + * Spark/Databricks); OFF by default, where the second literal stays an alias (MySQL, SQL + * Server) or fails (everywhere else) + */ + adjacentStringLiterals(AbstractJSqlParser.AdjacentStringLiterals.OFF), + + /** + * allows MySQL `#` line comments; disabled by default, where a lone `#` stays the binary + * operator (#2507: PostgreSQL bitwise XOR / geometric intersection) + */ + allowHashLineComments(false), + + /** + * treats three consecutive newlines as a statement separator (enabled by default). When + * disabled, blank lines are plain whitespace, so a statement containing them is parsed whole + * instead of ending, or failing to parse, at the first run of blank lines + */ + allowBlankLinesAsStatementSeparator(true), + + /** + * allows digit separators in numeric literals, e.g. {@code 1_000_000} (DuckDB, PostgreSQL 16); + * disabled by default, where MySQL reads {@code 2024_01} as an identifier + */ + allowDigitSeparators(false), + + /** + * allows sub selects without parentheses, e.g. `select * from dual where 1 = select 1` + */ + allowUnparenthesizedSubSelects(false), + + /** + * maximum nesting depth for trying complex parsing, can bet set to -1 to ignore + */ + allowedNestingDepth(10), + + dialect(null), + + /** + * "IMPORT" + */ + imprt, + + /** + * "EXPORT" and BigQuery "EXPORT DATA" + */ + export, + + /** + * PostgreSQL and DuckDB "COPY", BigQuery and MySQL "LOAD DATA" and MySQL "LOAD XML" statements + * are allowed + * + * @see net.sf.jsqlparser.statement.CopyStatement + * @see net.sf.jsqlparser.statement.load.LoadDataStatement + * @see net.sf.jsqlparser.statement.load.MySqlLoadDataStatement + */ + copy, loadData, + + /** + * DuckDB "ATTACH", "DETACH", "CONNECT", "DISCONNECT", "PRAGMA", "INSTALL", "LOAD", "CREATE + * MACRO" and "CREATE EXTENSION REPOSITORY" statements are allowed + */ + attach, detach, connect, disconnect, pragma, installExtension, loadExtension, createMacro, createExtensionRepository, + + /** + * BigQuery "ASSERT" statement is allowed + * + * @see net.sf.jsqlparser.statement.AssertStatement + */ + assertStatement, + + /** + * "SESSION" statement is allowed + * + * @see net.sf.jsqlparser.statement.SessionStatement + */ + session, + + /** + * MySQL allows a ',' as a separator between key and value entries. We allow that by default, + * but it can be disabled here + */ + allowCommaAsKeyValueSeparator(true), + + /** + * DB2 and Oracle allow Expressions as JSON_OBJECT key values. This clashes with Informix and + * Snowflake Json-Extraction syntax + */ + allowExpressionAsJsonObjectKey(false) + + ; + + private final Object value; + private final boolean configurable; + + /** + * a feature which can't configured within the parser + */ + Feature() { + this.value = null; + this.configurable = false; + } + + /** + * a feature which can be configured by {@link FeatureConfiguration} + * + * @param value The Value Object of the Parameter. + */ + Feature(Object value) { + this.value = value; + this.configurable = true; + } + + public Object getDefaultValue() { + return value; + } + + public boolean isConfigurable() { + return configurable; + } + +} diff --git a/src/main/java/net/sf/jsqlparser/parser/feature/FeatureConfiguration.java b/src/main/java/net/sf/jsqlparser/parser/feature/FeatureConfiguration.java new file mode 100644 index 0000000000..0106431cc3 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/parser/feature/FeatureConfiguration.java @@ -0,0 +1,80 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2020 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.parser.feature; + +import java.util.EnumMap; +import java.util.EnumSet; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class FeatureConfiguration { + + private static final Logger LOG = Logger.getLogger(FeatureConfiguration.class.getName()); + + private final Map featureEnabled = new EnumMap<>(Feature.class); + + public FeatureConfiguration() { + // set default-value for all switchable features + EnumSet.allOf(Feature.class).stream().filter(Feature::isConfigurable) + .forEach(f -> setValue(f, f.getDefaultValue())); + } + + /** + * @param feature + * @param value + * @return this + */ + public FeatureConfiguration setValue(Feature feature, Object value) { + if (feature.isConfigurable()) { + featureEnabled.put(feature, value); + } else { + if (LOG.isLoggable(Level.WARNING)) { + LOG.warning(feature.name() + " is not switchable - cannot set enabled = " + value); + } + } + return this; + } + + /** + * @param feature + * @return the configured feature value - can be null + * @throws IllegalStateException - if given {@link Feature#isConfigurable()} == false + */ + public Object getValue(Feature feature) { + if (feature.isConfigurable()) { + return featureEnabled.get(feature); + } else { + throw new IllegalStateException("The feature " + feature + " is not configurable!"); + } + } + + public boolean getAsBoolean(Feature f) { + return Boolean.parseBoolean(String.valueOf(getValue(f))); + } + + public Long getAsLong(Feature f) { + return Long.valueOf(String.valueOf(getValue(f))); + } + + public int getAsInt(Feature f) { + return Integer.parseInt(String.valueOf(getValue(f))); + } + + public Integer getAsInteger(Feature f) { + return Integer.parseInt(String.valueOf(getValue(f))); + } + + public String getAsString(Feature f) { + Object value = getValue(f); + return value == null ? null : String.valueOf(value); + } + +} diff --git a/src/main/java/net/sf/jsqlparser/parser/feature/FeatureSet.java b/src/main/java/net/sf/jsqlparser/parser/feature/FeatureSet.java new file mode 100644 index 0000000000..551e0c5754 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/parser/feature/FeatureSet.java @@ -0,0 +1,60 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2020 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.parser.feature; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import net.sf.jsqlparser.util.validation.feature.FeaturesAllowed; + +public interface FeatureSet { + + Set getFeatures(); + + /** + * @return true if the feature is identical to one of the features contained in + * this set, false otherwise + */ + default boolean contains(Feature feature) { + return getFeatures().contains(feature); + } + + /** + * @return a new {@link HashSet} with a copy of supported features + */ + default Set getFeaturesClone() { + return new HashSet<>(getFeatures()); + } + + /** + * @param features + * @return all features within this feature set which are not contained in given set + */ + default Set getNotContained(Collection features) { + Set f = getFeaturesClone(); + f.removeAll(features); + return f; + } + + /** + * @param features + * @return all features within this feature set which are contained in given set too. + */ + default Set retainAll(Collection features) { + Set f = getFeaturesClone(); + f.retainAll(features); + return f; + } + + default ModifyableFeatureSet copy() { + return new FeaturesAllowed().add(this.getFeatures()); + } +} diff --git a/src/main/java/net/sf/jsqlparser/parser/feature/ModifyableFeatureSet.java b/src/main/java/net/sf/jsqlparser/parser/feature/ModifyableFeatureSet.java new file mode 100644 index 0000000000..7c1954f0d2 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/parser/feature/ModifyableFeatureSet.java @@ -0,0 +1,60 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2020 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.parser.feature; + +import java.util.Collection; + +public interface ModifyableFeatureSet extends FeatureSet { + + /** + * @param featureSets + * @return this + */ + ModifyableFeatureSet add(FeatureSet... featureSets); + + /** + * @param features + * @return this + */ + ModifyableFeatureSet add(Feature... features); + + /** + * @param features + * @return this + */ + ModifyableFeatureSet add(Collection features); + + /** + * @param featureSets + * @return this + */ + ModifyableFeatureSet remove(FeatureSet... featureSets); + + /** + * @param features + * @return this + */ + ModifyableFeatureSet remove(Feature... features); + + /** + * @param features + * @return this + */ + ModifyableFeatureSet remove(Collection features); + + /** + * makes the inner {@link Feature}-set unmodifiable + * + * @return this + * @see #copy() + */ + FeatureSet unmodifyable(); + +} diff --git a/src/main/java/net/sf/jsqlparser/schema/Column.java b/src/main/java/net/sf/jsqlparser/schema/Column.java index 3e48c751ed..3bb06de241 100644 --- a/src/main/java/net/sf/jsqlparser/schema/Column.java +++ b/src/main/java/net/sf/jsqlparser/schema/Column.java @@ -1,52 +1,133 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.schema; -import net.sf.jsqlparser.expression.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import net.sf.jsqlparser.expression.ArrayConstructor; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.ExpressionVisitor; +import net.sf.jsqlparser.expression.operators.relational.SupportsOldOracleJoinSyntax; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.ReturningReferenceType; /** * A column. It can have the table name it belongs to. */ -public final class Column implements Expression, MultiPartName { +public class Column extends ASTNodeAccessImpl implements Expression, MultiPartName { private Table table; private String columnName; + private String commentText; + private ArrayConstructor arrayConstructor; + private String tableDelimiter = "."; + private int oldOracleJoinSyntax = SupportsOldOracleJoinSyntax.NO_ORACLE_JOIN; + private ReturningReferenceType returningReferenceType = null; + private String returningQualifier = null; - public Column() { - } + // holds the physical table when resolved against an actual schema information + private Table resolvedTable = null; + + public Column() {} public Column(Table table, String columnName) { setTable(table); setColumnName(columnName); } + public Column(List nameParts) { + this(nameParts, nameParts.size() > 1 ? Collections.nCopies(nameParts.size() - 1, ".") + : new ArrayList<>()); + } + + public Column(List nameParts, List delimiters) { + if (nameParts.size() > 1) { + setTable(new Table(nameParts.subList(0, nameParts.size() - 1), + delimiters.subList(0, delimiters.size() - 1))); + // The final component is already separated from the table name. + setName(nameParts.get(nameParts.size() - 1), false); + } else { + setColumnName(nameParts.get(0)); + } + setTableDelimiter(delimiters.isEmpty() ? "." : delimiters.get(delimiters.size() - 1)); + } + public Column(String columnName) { - this(null, columnName); + this(); + setColumnName(columnName); } + public ArrayConstructor getArrayConstructor() { + return arrayConstructor; + } + + public Column setArrayConstructor(ArrayConstructor arrayConstructor) { + this.arrayConstructor = arrayConstructor; + return this; + } + + /** + * Retrieve the information regarding the {@code Table} this {@code Column} does belong to, if + * any can be inferred. + *

+ * The inference is based only on local information, and not on the whole SQL command. For + * example, consider the following query:

+ * + *
+     *  SELECT x FROM Foo
+     * 
+ * + *
Given the {@code Column} called {@code x}, this method would return + * {@code null}, and not the info about the table {@code Foo}. On the other hand, consider: + *
+ * + *
+     *  SELECT t.x FROM Foo t
+     * 
+ * + *
Here, we will get a {@code Table} object for a table called {@code t}. But + * because the inference is local, such object will not know that {@code t} is just an alias for + * {@code Foo}. + * + * @return an instance of {@link net.sf.jsqlparser.schema.Table} representing the table this + * column does belong to, if it can be inferred. Can be {@code null}. + */ public Table getTable() { return table; } + public String getTableName() { + return table != null ? table.getName() : null; + } + + public String getUnquotedTableName() { + return table != null ? table.getUnquotedName() : null; + } + + public String getSchemaName() { + return table != null ? table.getSchemaName() : null; + } + + public String getUnquotedSchemaName() { + return table != null ? table.getUnquotedSchemaName() : null; + } + + public String getCatalogName() { + return table != null ? table.getCatalogName() : null; + } + + public String getUnquotedCatalogName() { + return table != null ? table.getUnquotedCatalogName() : null; + } + public void setTable(Table table) { this.table = table; } @@ -55,33 +136,231 @@ public String getColumnName() { return columnName; } - public void setColumnName(String string) { - columnName = string; + public String getUnquotedColumnName() { + return MultiPartName.unquote(columnName); + } + + public void setColumnName(String name) { + // BigQuery seems to allow things like: `catalogName.schemaName.tableName` in only one pair + // of quotes + // however, some people believe that Dots in Names are a good idea, so provide a switch-off + boolean splitNamesOnDelimiter = System.getProperty("SPLIT_NAMES_ON_DELIMITER") == null || + !List + .of("0", "N", "n", "FALSE", "false", "OFF", "off") + .contains(System.getProperty("SPLIT_NAMES_ON_DELIMITER")); + + setName(name, splitNamesOnDelimiter); + } + + public void setName(String name, boolean splitNamesOnDelimiter) { + if (name.contains(".") && splitNamesOnDelimiter) { + List parts = splitName(name); + if (parts.size() == 1 && MultiPartName.isQuoted(name)) { + parts.clear(); + for (String identifier : MultiPartName.unquote(name).split("\\.")) { + parts.add("\"" + identifier + "\""); + } + } + switch (parts.size()) { + case 3: + this.table = new Table(parts.subList(0, 2)); + this.columnName = parts.get(2); + break; + case 2: + this.table = new Table(parts.get(0), false); + this.columnName = parts.get(1); + break; + case 1: + this.columnName = parts.get(0); + break; + default: + throw new RuntimeException("Invalid column name: " + name); + } + } else { + this.columnName = name; + } + } + + private static List splitName(String name) { + List parts = new ArrayList<>(); + int start = 0; + char quote = 0; + for (int i = 0; i < name.length(); i++) { + char ch = name.charAt(i); + if (quote != 0) { + if (ch == quote) { + if (i + 1 < name.length() && name.charAt(i + 1) == quote) { + i++; + } else { + quote = 0; + } + } + } else if (ch == '"' || ch == '`' || ch == '[') { + quote = ch == '[' ? ']' : ch; + } else if (ch == '.') { + parts.add(name.substring(start, i)); + start = i + 1; + } + } + parts.add(name.substring(start)); + while (!parts.isEmpty() && parts.get(parts.size() - 1).isEmpty()) { + parts.remove(parts.size() - 1); + } + return parts; + } + + public String getTableDelimiter() { + return tableDelimiter; + } + + public void setTableDelimiter(String tableDelimiter) { + this.tableDelimiter = tableDelimiter; + } + + public int getOldOracleJoinSyntax() { + return oldOracleJoinSyntax; + } + + public void setOldOracleJoinSyntax(int oldOracleJoinSyntax) { + this.oldOracleJoinSyntax = oldOracleJoinSyntax; } @Override public String getFullyQualifiedName() { + return getFullyQualifiedName(false); + } + + @Override + public String getUnquotedName() { + return MultiPartName.unquote(columnName); + } + + public String getFullyQualifiedName(boolean aliases) { StringBuilder fqn = new StringBuilder(); - if (table != null) { - fqn.append(table.getFullyQualifiedName()); + if (returningQualifier != null) { + fqn.append(returningQualifier); + } else if (table != null) { + if (table.getAlias() != null && aliases) { + fqn.append(table.getAlias().getName()); + } else { + fqn.append(table.getFullyQualifiedName()); + } } - if (fqn.length()>0) { - fqn.append('.'); + if (fqn.length() > 0) { + fqn.append(tableDelimiter); } if (columnName != null) { fqn.append(columnName); } + + if (commentText != null) { + fqn.append(" COMMENT "); + fqn.append(commentText); + } + + if (arrayConstructor != null) { + fqn.append(arrayConstructor); + } + return fqn.toString(); } + // old and confusing, don't use it! + @Deprecated + public String getName(boolean aliases) { + return columnName; + } + @Override - public void accept(ExpressionVisitor expressionVisitor) { - expressionVisitor.visit(this); + public T accept(ExpressionVisitor expressionVisitor, S context) { + return expressionVisitor.visit(this, context); } @Override public String toString() { - return getFullyQualifiedName(); + return getFullyQualifiedName(true) + + (oldOracleJoinSyntax != SupportsOldOracleJoinSyntax.NO_ORACLE_JOIN ? "(+)" : "") + + (commentText != null ? " /* " + commentText + "*/ " : ""); + } + + public Column withTable(Table table) { + this.setTable(table); + return this; + } + + public Column withColumnName(String columnName) { + this.setColumnName(columnName); + return this; + } + + public Column withCommentText(String commentText) { + this.setCommentText(commentText); + return this; + } + + public Column withTableDelimiter(String delimiter) { + this.setTableDelimiter(delimiter); + return this; + } + + public Column withOldOracleJoinSyntax(int oldOracleJoinSyntax) { + this.setOldOracleJoinSyntax(oldOracleJoinSyntax); + return this; + } + + public ReturningReferenceType getReturningReferenceType() { + return returningReferenceType; + } + + public Column setReturningReferenceType(ReturningReferenceType returningReferenceType) { + this.returningReferenceType = returningReferenceType; + return this; + } + + public String getReturningQualifier() { + return returningQualifier; + } + + public Column setReturningQualifier(String returningQualifier) { + this.returningQualifier = returningQualifier; + return this; + } + + public Column withReturningReference(ReturningReferenceType returningReferenceType, + String returningQualifier) { + this.returningReferenceType = returningReferenceType; + this.returningQualifier = returningQualifier; + return this; + } + + public String getCommentText() { + return commentText; + } + + public void setCommentText(String commentText) { + this.commentText = commentText; + } + + /** + * Gets the actual table when resolved against a physical schema information. + * + * @return the actual table when resolved against a physical schema information + */ + public Table getResolvedTable() { + return resolvedTable; + } + + /** + * Sets resolved table. + * + * @param resolvedTable the resolved table + * @return this column + */ + public Column setResolvedTable(Table resolvedTable) { + // clone, not reference + this.resolvedTable = + resolvedTable != null ? new Table(resolvedTable.getFullyQualifiedName()) : null; + return this; } -} \ No newline at end of file +} diff --git a/src/main/java/net/sf/jsqlparser/schema/Database.java b/src/main/java/net/sf/jsqlparser/schema/Database.java index 6ab5fe4f93..c566b744f3 100644 --- a/src/main/java/net/sf/jsqlparser/schema/Database.java +++ b/src/main/java/net/sf/jsqlparser/schema/Database.java @@ -1,27 +1,16 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.schema; public final class Database implements MultiPartName { + private Server server; private String databaseName; @@ -68,8 +57,23 @@ public String getFullyQualifiedName() { return fqn; } + @Override + public String getUnquotedName() { + return MultiPartName.unquote(databaseName); + } + @Override public String toString() { return getFullyQualifiedName(); } + + public Database withServer(Server server) { + this.setServer(server); + return this; + } + + public Database withDatabaseName(String databaseName) { + this.setDatabaseName(databaseName); + return this; + } } diff --git a/src/main/java/net/sf/jsqlparser/schema/MultiPartName.java b/src/main/java/net/sf/jsqlparser/schema/MultiPartName.java index 38679769f2..b49e58384e 100644 --- a/src/main/java/net/sf/jsqlparser/schema/MultiPartName.java +++ b/src/main/java/net/sf/jsqlparser/schema/MultiPartName.java @@ -1,26 +1,81 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.schema; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public interface MultiPartName { + Pattern LEADING_TRAILING_QUOTES_PATTERN = Pattern.compile("^[\"\\[`]+|[\"\\]`]+$"); + Pattern BACKTICK_PATTERN = Pattern.compile("`([^`]*)`"); + + /** + * Removes leading and trailing quotes from a SQL quoted identifier + * + * @param quotedIdentifier the quoted identifier + * @return the pure identifier without quotes + */ + static String unquote(String quotedIdentifier) { + if (quotedIdentifier == null) { + return null; + } + // same result as LEADING_TRAILING_QUOTES_PATTERN.matcher(..).replaceAll(""), but linear: + // the regex retries its trailing alternative at every offset of a run of quotes + int start = 0; + int end = quotedIdentifier.length(); + while (start < end && isLeadingQuote(quotedIdentifier.charAt(start))) { + start++; + } + while (end > start && isTrailingQuote(quotedIdentifier.charAt(end - 1))) { + end--; + } + return quotedIdentifier.substring(start, end); + } + + static boolean isQuoted(String identifier) { + return identifier != null && !identifier.isEmpty() + && (isLeadingQuote(identifier.charAt(0)) + || isTrailingQuote(identifier.charAt(identifier.length() - 1))); + } + + private static boolean isLeadingQuote(char c) { + return c == '"' || c == '[' || c == '`'; + } + + private static boolean isTrailingQuote(char c) { + return c == '"' || c == ']' || c == '`'; + } + String getFullyQualifiedName(); + + String getUnquotedName(); + + + static String replaceBackticksWithDoubleQuotes(String input) { + if (input == null || input.isEmpty()) { + return input; + } + + Matcher matcher = BACKTICK_PATTERN.matcher(input); + StringBuilder sb = new StringBuilder(); + int lastEnd = 0; + + while (matcher.find()) { + sb.append(input, lastEnd, matcher.start()); // text before match + sb.append('"').append(matcher.group(1)).append('"'); // replace with double quotes + lastEnd = matcher.end(); + } + + sb.append(input.substring(lastEnd)); // append remaining text + return sb.toString(); + } + + } diff --git a/src/main/java/net/sf/jsqlparser/schema/Partition.java b/src/main/java/net/sf/jsqlparser/schema/Partition.java new file mode 100644 index 0000000000..2666a6e812 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/schema/Partition.java @@ -0,0 +1,66 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2025 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.schema; + +import net.sf.jsqlparser.expression.Expression; + +import java.util.Collection; +import java.util.Objects; + +public class Partition { + protected Column column; + protected Expression value; + + public Partition() { + + } + + public Partition(Column column, Expression value) { + this.column = column; + this.value = value; + } + + public static void appendPartitionsTo(StringBuilder builder, + Collection partitions) { + int j = 0; + for (Partition partition : partitions) { + partition.appendTo(builder, j); + j++; + } + } + + public Column getColumn() { + return column; + } + + public void setColumn(Column column) { + this.column = Objects.requireNonNull(column); + } + + public Expression getValue() { + return value; + } + + public void setValue(Expression value) { + this.value = Objects.requireNonNull(value); + } + + + @SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPath"}) + void appendTo(StringBuilder builder, int j) { + if (j > 0) { + builder.append(", "); + } + builder.append(column.getColumnName()); + if (value != null) { + builder.append(" = ").append(value); + } + } +} diff --git a/src/main/java/net/sf/jsqlparser/schema/Sequence.java b/src/main/java/net/sf/jsqlparser/schema/Sequence.java new file mode 100644 index 0000000000..ff7cd66a55 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/schema/Sequence.java @@ -0,0 +1,282 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.schema; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.Optional; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** + * Represents the database type for a {@code SEQUENCE} + */ +public class Sequence extends ASTNodeAccessImpl implements MultiPartName { + + private static final int NAME_IDX = 0; + private static final int SCHEMA_IDX = 1; + private static final int DATABASE_IDX = 2; + private static final int SERVER_IDX = 3; + private List partItems = new ArrayList<>(); + + private List parameters; + private String dataType; + private SequenceOwnership ownership; + + public SequenceOwnership getOwnership() { + return ownership; + } + + public void setOwnership(SequenceOwnership ownership) { + this.ownership = ownership; + } + + public Sequence() {} + + public Sequence(List partItems) { + this.partItems = new ArrayList<>(partItems); + Collections.reverse(this.partItems); + } + + public List getParameters() { + return parameters; + } + + public void setParameters(List parameters) { + this.parameters = parameters; + } + + public String getDataType() { + return dataType; + } + + public void setDataType(String dataType) { + this.dataType = dataType; + } + + public Sequence withDataType(String dataType) { + this.setDataType(dataType); + return this; + } + + public Database getDatabase() { + return new Database(getIndex(DATABASE_IDX)); + } + + public void setDatabase(Database database) { + setIndex(DATABASE_IDX, database.getDatabaseName()); + if (database.getServer() != null) { + setIndex(SERVER_IDX, database.getServer().getFullyQualifiedName()); + } + } + + public Sequence withDatabase(Database database) { + setDatabase(database); + return this; + } + + public String getSchemaName() { + return getIndex(SCHEMA_IDX); + } + + public void setSchemaName(String string) { + setIndex(SCHEMA_IDX, string); + } + + public Sequence withSchemaName(String string) { + setSchemaName(string); + return this; + } + + public String getName() { + return getIndex(NAME_IDX); + } + + public void setName(String string) { + setIndex(NAME_IDX, string); + } + + public Sequence withName(String string) { + setName(string); + return this; + } + + private void setIndex(int idx, String value) { + int size = partItems.size(); + for (int i = 0; i < idx - size + 1; i++) { + partItems.add(null); + } + partItems.set(idx, value); + } + + private String getIndex(int idx) { + if (idx < partItems.size()) { + return partItems.get(idx); + } else { + return null; + } + } + + @Override + public String getFullyQualifiedName() { + StringBuilder fqn = new StringBuilder(); + + for (int i = partItems.size() - 1; i >= 0; i--) { + String part = partItems.get(i); + if (part == null) { + part = ""; + } + fqn.append(part); + if (i != 0) { + fqn.append("."); + } + } + + return fqn.toString(); + } + + @Override + public String getUnquotedName() { + return MultiPartName.unquote(partItems.get(NAME_IDX)); + } + + @Override + public String toString() { + StringBuilder sql = new StringBuilder(getFullyQualifiedName()); + if (dataType != null) { + sql.append(" AS ").append(dataType); + } + if (parameters != null) { + for (Sequence.Parameter parameter : parameters) { + sql.append(" ").append(parameter.formatParameter()); + } + } + if (ownership != null) { + sql.append(' ').append(ownership); + } + return sql.toString(); + } + + public Sequence withParameters(List parameters) { + this.setParameters(parameters); + return this; + } + + public Sequence addParameters(Parameter... parameters) { + List collection = Optional.ofNullable(getParameters()).orElseGet(ArrayList::new); + Collections.addAll(collection, parameters); + return this.withParameters(collection); + } + + public Sequence addParameters(Collection parameters) { + List collection = Optional.ofNullable(getParameters()).orElseGet(ArrayList::new); + collection.addAll(parameters); + return this.withParameters(collection); + } + + /** + * The available parameters to a sequence + */ + public enum ParameterType { + INCREMENT_BY, INCREMENT, START_WITH, START, RESTART_WITH, MAXVALUE, NOMAXVALUE, MINVALUE, NOMINVALUE, CYCLE, NOCYCLE, CACHE, NOCACHE, ORDER, NOORDER, KEEP, NOKEEP, SESSION, GLOBAL, NO_MINVALUE, NO_MAXVALUE, NO_CYCLE, SEQUENCE_NAME, LOGGED, UNLOGGED; + + public static ParameterType from(String type) { + return Enum.valueOf(ParameterType.class, type.toUpperCase(Locale.ROOT)); + } + } + + /** + * Represents a parameter when declaring a sequence + */ + public static class Parameter implements java.io.Serializable { + + private final ParameterType option; + private Long value; + private Sequence sequenceName; + + public Parameter(ParameterType option) { + this.option = option; + } + + public Long getValue() { + return value; + } + + public ParameterType getOption() { + return option; + } + + /** The sequence named by an identity declaration's SEQUENCE NAME option. */ + public Sequence getSequenceName() { + return sequenceName; + } + + public void setSequenceName(Sequence sequenceName) { + this.sequenceName = sequenceName; + } + + public Parameter withSequenceName(Sequence sequenceName) { + setSequenceName(sequenceName); + return this; + } + + @Override + public String toString() { + return formatParameter(); + } + + public void setValue(Long value) { + this.value = value; + } + + public String formatParameter() { + switch (option) { + case SEQUENCE_NAME: + return "SEQUENCE NAME " + sequenceName.getFullyQualifiedName(); + case INCREMENT_BY: + return prefix("INCREMENT BY"); + case INCREMENT: + return prefix("INCREMENT"); + case START_WITH: + return prefix("START WITH"); + case START: + return prefix("START"); + case RESTART_WITH: + if (value != null) { + return prefix("RESTART WITH"); + } else { + return "RESTART"; + } + case MAXVALUE: + case MINVALUE: + case CACHE: + return prefix(option.name()); + case NO_MINVALUE: + case NO_MAXVALUE: + case NO_CYCLE: + return option.name().replace('_', ' '); + default: + // fallthrough just return option name + return option.name(); + } + } + + private String prefix(String prefix) { + return prefix + " " + value; + } + + public Parameter withValue(Long value) { + this.setValue(value); + return this; + } + } +} diff --git a/src/main/java/net/sf/jsqlparser/schema/SequenceOwnership.java b/src/main/java/net/sf/jsqlparser/schema/SequenceOwnership.java new file mode 100644 index 0000000000..8f3f95322e --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/schema/SequenceOwnership.java @@ -0,0 +1,43 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.schema; + +import java.io.Serializable; +import java.util.Objects; + +/** Distinguishes explicit OWNED BY NONE from an owning column and from an omitted clause. */ +public class SequenceOwnership implements Serializable { + private final Column column; + + private SequenceOwnership(Column column) { + this.column = column; + } + + public static SequenceOwnership none() { + return new SequenceOwnership(null); + } + + public static SequenceOwnership ownedBy(Column column) { + return new SequenceOwnership(Objects.requireNonNull(column, "column")); + } + + public Column getColumn() { + return column; + } + + public boolean isNone() { + return column == null; + } + + @Override + public String toString() { + return "OWNED BY " + (column == null ? "NONE" : column); + } +} diff --git a/src/main/java/net/sf/jsqlparser/schema/Server.java b/src/main/java/net/sf/jsqlparser/schema/Server.java index f86b8e2f7e..7e4eaa51ca 100644 --- a/src/main/java/net/sf/jsqlparser/schema/Server.java +++ b/src/main/java/net/sf/jsqlparser/schema/Server.java @@ -1,22 +1,10 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.schema; @@ -24,20 +12,25 @@ import java.util.regex.*; public final class Server implements MultiPartName { - public static final Pattern SERVER_PATTERN = Pattern.compile("\\[([^\\]]+?)(?:\\\\([^\\]]+))?\\]"); + + public static final Pattern SERVER_PATTERN = + Pattern.compile("\\[([^\\]\\\\]+)(?:\\\\([^\\]]+))?\\]"); private String serverName; + private String instanceName; + private String simpleName; public Server(String serverAndInstanceName) { if (serverAndInstanceName != null) { final Matcher matcher = SERVER_PATTERN.matcher(serverAndInstanceName); if (!matcher.find()) { - throw new IllegalArgumentException(String.format("%s is not a valid database reference", serverAndInstanceName)); + simpleName = serverAndInstanceName; + } else { + setServerName(matcher.group(1)); + setInstanceName(matcher.group(2)); } - setServerName(matcher.group(1)); - setInstanceName(matcher.group(2)); } } @@ -64,17 +57,35 @@ public void setInstanceName(String instanceName) { @Override public String getFullyQualifiedName() { - if (serverName != null && !serverName.isEmpty() && instanceName != null && !instanceName.isEmpty()) { + if (serverName != null && !serverName.isEmpty() && instanceName != null + && !instanceName.isEmpty()) { return String.format("[%s\\%s]", serverName, instanceName); } else if (serverName != null && !serverName.isEmpty()) { return String.format("[%s]", serverName); + } else if (simpleName != null && !simpleName.isEmpty()) { + return simpleName; } else { return ""; } } + @Override + public String getUnquotedName() { + return MultiPartName.unquote(serverName); + } + @Override public String toString() { return getFullyQualifiedName(); } + + public Server withServerName(String serverName) { + this.setServerName(serverName); + return this; + } + + public Server withInstanceName(String instanceName) { + this.setInstanceName(instanceName); + return this; + } } diff --git a/src/main/java/net/sf/jsqlparser/schema/Synonym.java b/src/main/java/net/sf/jsqlparser/schema/Synonym.java new file mode 100644 index 0000000000..b052588c87 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/schema/Synonym.java @@ -0,0 +1,119 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2020 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.schema; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class Synonym extends ASTNodeAccessImpl implements MultiPartName { + + private static final int NAME_IDX = 0; + private static final int SCHEMA_IDX = 1; + private static final int DATABASE_IDX = 2; + private static final int SERVER_IDX = 3; + private List partItems = new ArrayList<>(); + + public Synonym() {} + + public Synonym(List partItems) { + this.partItems = new ArrayList<>(partItems); + Collections.reverse(this.partItems); + } + + public Database getDatabase() { + return new Database(getIndex(DATABASE_IDX)); + } + + public void setDatabase(Database database) { + setIndex(DATABASE_IDX, database.getDatabaseName()); + if (database.getServer() != null) { + setIndex(SERVER_IDX, database.getServer().getFullyQualifiedName()); + } + } + + public Synonym withDatabase(Database database) { + setDatabase(database); + return this; + } + + public String getSchemaName() { + return getIndex(SCHEMA_IDX); + } + + public void setSchemaName(String string) { + setIndex(SCHEMA_IDX, string); + } + + public Synonym withSchemaName(String string) { + setSchemaName(string); + return this; + } + + public String getName() { + return getIndex(NAME_IDX); + } + + public void setName(String string) { + setIndex(NAME_IDX, string); + } + + public Synonym withName(String string) { + setName(string); + return this; + } + + private void setIndex(int idx, String value) { + int size = partItems.size(); + for (int i = 0; i < idx - size + 1; i++) { + partItems.add(null); + } + partItems.set(idx, value); + } + + private String getIndex(int idx) { + if (idx < partItems.size()) { + return partItems.get(idx); + } else { + return null; + } + } + + @Override + public String getFullyQualifiedName() { + StringBuilder fqn = new StringBuilder(); + + for (int i = partItems.size() - 1; i >= 0; i--) { + String part = partItems.get(i); + if (part == null) { + part = ""; + } + fqn.append(part); + if (i != 0) { + fqn.append("."); + } + } + + return fqn.toString(); + } + + @Override + public String getUnquotedName() { + return MultiPartName.unquote(partItems.get(NAME_IDX)); + } + + @Override + public String toString() { + StringBuilder sql = new StringBuilder(getFullyQualifiedName()); + return sql.toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/schema/Table.java b/src/main/java/net/sf/jsqlparser/schema/Table.java index 90eb30f1a4..bbf9f4536a 100644 --- a/src/main/java/net/sf/jsqlparser/schema/Table.java +++ b/src/main/java/net/sf/jsqlparser/schema/Table.java @@ -1,81 +1,302 @@ -/* +/*- * #%L * JSQLParser library * %% - * Copyright (C) 2004 - 2013 JSQLParser + * Copyright (C) 2004 - 2019 JSQLParser * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 * #L% */ package net.sf.jsqlparser.schema; -import net.sf.jsqlparser.expression.*; -import net.sf.jsqlparser.statement.select.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import net.sf.jsqlparser.expression.Alias; +import net.sf.jsqlparser.expression.MySQLIndexHint; +import net.sf.jsqlparser.expression.SQLServerHints; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.ErrorDestination; +import net.sf.jsqlparser.statement.select.FromItem; +import net.sf.jsqlparser.statement.select.FromItemVisitor; +import net.sf.jsqlparser.statement.select.IntoTableVisitor; +import net.sf.jsqlparser.statement.select.Pivot; +import net.sf.jsqlparser.statement.select.SampleClause; +import net.sf.jsqlparser.statement.select.UnPivot; /** * A table. It can have an alias and the schema name it belongs to. */ -public class Table implements FromItem, MultiPartName { +public class Table extends ASTNodeAccessImpl + implements ErrorDestination, FromItem, MultiPartName, Cloneable { + + private static final int NAME_IDX = 0; + + private static final int SCHEMA_IDX = 1; + + private static final int DATABASE_IDX = 2; + + private static final int SERVER_IDX = 3; + + private List partItems = new ArrayList<>(); - private Database database; - private String schemaName; - private String name; + private List partDelimiters = new ArrayList<>(); + + private boolean tableVariable; + + // holds the various `time travel` syntax for BigQuery, RedShift, Snowflake or RedShift + private String timeTravelStr = null; private Alias alias; + + // thank you, Google! + private String timeTravelStrAfterAlias = null; + + private SampleClause sampleClause; + private Pivot pivot; - public Table() { + private UnPivot unpivot; + + private List mysqlIndexHints; + + private SQLServerHints sqlServerHints; + + // holds the physical table when resolved against an actual schema information + private Table resolvedTable = null; + + public Table() {} + + /** Whether this reference names a local table variable rather than a catalog table. */ + public boolean isTableVariable() { + return tableVariable; } + public void setTableVariable(boolean tableVariable) { + this.tableVariable = tableVariable; + } + + public Table withTableVariable(boolean tableVariable) { + setTableVariable(tableVariable); + return this; + } + + /** + * Instantiates a new Table. + * + * Sets the table name, splitting it into parts (catalog, schema, name) on `.` dots when quoted + * unless the system property `SPLIT_NAMES_ON_DELIMITER` points to `FALSE` + * + * @param name the table name, optionally quoted + */ public Table(String name) { - this.name = name; + setName(name); + } + + public Table(String name, boolean splitNamesOnDelimiter) { + setName(name, splitNamesOnDelimiter); } public Table(String schemaName, String name) { - this.schemaName = schemaName; - this.name = name; + setSchemaName(schemaName); + setName(name); } public Table(Database database, String schemaName, String name) { - this.database = database; - this.schemaName = schemaName; - this.name = name; + setDatabase(database); + setSchemaName(schemaName); + setName(name); + } + + public Table(String catalogName, String schemaName, String tableName) { + setSchemaName(schemaName); + setDatabase(new Database(catalogName)); + setName(tableName); + } + + public Table(List partItems) { + if (partItems.size() == 1) { + setName(partItems.get(0)); + } else { + this.partItems = new ArrayList<>(partItems); + Collections.reverse(this.partItems); + } + } + + public Table(List partItems, List partDelimiters) { + if (partItems.size() == 1) { + setName(partItems.get(0)); + } else { + if (partDelimiters.size() != partItems.size() - 1) { + throw new IllegalArgumentException( + "the length of the delimiters list must be 1 less than nameParts"); + } + this.partItems = new ArrayList<>(partItems); + this.partDelimiters = new ArrayList<>(partDelimiters); + Collections.reverse(this.partItems); + Collections.reverse(this.partDelimiters); + } + } + + public String getCatalogName() { + return getIndex(DATABASE_IDX); } public Database getDatabase() { - return database; + return new Database(getIndex(DATABASE_IDX)); + } + + public String getDatabaseName() { + return getIndex(DATABASE_IDX); + } + + public String getUnquotedCatalogName() { + return MultiPartName.unquote(getDatabaseName()); + } + + public String getUnquotedDatabaseName() { + return MultiPartName.unquote(getDatabaseName()); } public void setDatabase(Database database) { - this.database = database; + setIndex(DATABASE_IDX, database.getDatabaseName()); + if (database.getServer() != null) { + setIndex(SERVER_IDX, database.getServer().getFullyQualifiedName()); + } + } + + public Table setDatabaseName(String databaseName) { + this.setDatabase(new Database(databaseName)); + return this; + } + + public Table withDatabase(Database database) { + setDatabase(database); + return this; } public String getSchemaName() { - return schemaName; + return getIndex(SCHEMA_IDX); } - public void setSchemaName(String string) { - schemaName = string; + public String getUnquotedSchemaName() { + return MultiPartName.unquote(getSchemaName()); + } + + public Table setSchemaName(String schemaName) { + if (schemaName == null) { + setIndex(SCHEMA_IDX, null); + return this; + } + + // BigQuery seems to allow things like: `catalogName.schemaName.tableName` in only one pair + // of quotes + // however, some people believe that Dots in Names are a good idea, so provide a switch-off + boolean splitNamesOnDelimiter = System.getProperty("SPLIT_NAMES_ON_DELIMITER") == null || + !List + .of("0", "N", "n", "FALSE", "false", "OFF", "off") + .contains(System.getProperty("SPLIT_NAMES_ON_DELIMITER")); + + if (MultiPartName.isQuoted(schemaName) && schemaName.contains(".") + && splitNamesOnDelimiter) { + String[] parts = MultiPartName.unquote(schemaName).split("\\."); + switch (parts.length) { + case 2: + setIndex(DATABASE_IDX, "\"" + parts[0] + "\""); + setIndex(SCHEMA_IDX, "\"" + parts[1] + "\""); + break; + case 1: + setIndex(SCHEMA_IDX, "\"" + parts[0] + "\""); + break; + default: + throw new RuntimeException("Invalid schema name: " + schemaName); + } + } else if (schemaName.contains(".") && splitNamesOnDelimiter) { + String[] parts = MultiPartName.unquote(schemaName).split("\\."); + switch (parts.length) { + case 2: + setIndex(DATABASE_IDX, parts[0]); + setIndex(SCHEMA_IDX, parts[1]); + break; + case 1: + setIndex(SCHEMA_IDX, parts[0]); + break; + default: + throw new RuntimeException("Invalid schema name: " + schemaName); + } + } else { + this.setIndex(SCHEMA_IDX, schemaName); + } + return this; + } + + public Table withSchemaName(String schemaName) { + setSchemaName(schemaName); + return this; } public String getName() { + String name = getIndex(NAME_IDX); + if (name != null && name.contains("@")) { + int pos = name.lastIndexOf('@'); + if (pos > 0) { + name = name.substring(0, pos); + } + } + return name; + } + + + /** + * Sets the table name, splitting it into parts (catalog, schema, name) on `.` dots when quoted + * unless the system property `SPLIT_NAMES_ON_DELIMITER` points to `FALSE` + * + * @param name the table name, optionally quoted + */ + public void setName(String name) { + // BigQuery seems to allow things like: `catalogName.schemaName.tableName` in only one pair + // of quotes + // however, some people believe that Dots in Names are a good idea, so provide a switch-off + boolean splitNamesOnDelimiter = System.getProperty("SPLIT_NAMES_ON_DELIMITER") == null || + !List + .of("0", "N", "n", "FALSE", "false", "OFF", "off") + .contains(System.getProperty("SPLIT_NAMES_ON_DELIMITER")); + + setName(name, splitNamesOnDelimiter); + } + + public void setName(String name, boolean splitNamesOnDelimiter) { + if (MultiPartName.isQuoted(name) && name.contains(".") && splitNamesOnDelimiter) { + partItems.clear(); + for (String unquotedIdentifier : MultiPartName.unquote(name).split("\\.")) { + partItems.add("\"" + unquotedIdentifier + "\""); + } + Collections.reverse(partItems); + } else if (name.contains(".") && splitNamesOnDelimiter) { + partItems.clear(); + partItems.addAll(Arrays.asList(MultiPartName.unquote(name).split("\\."))); + Collections.reverse(partItems); + } else { + setIndex(NAME_IDX, name); + } + } + + public String getDBLinkName() { + String name = getIndex(NAME_IDX); + if (name != null && name.contains("@")) { + int pos = name.lastIndexOf('@'); + if (pos > 0) { + name = name.substring(pos + 1); + } + } return name; } - public void setName(String string) { - name = string; + public Table withName(String name) { + this.setName(name); + return this; } @Override @@ -88,38 +309,86 @@ public void setAlias(Alias alias) { this.alias = alias; } - @Override - public String getFullyQualifiedName() { - String fqn = ""; + public String getTimeTravelStrAfterAlias() { + return timeTravelStrAfterAlias; + } - if (database != null) { - fqn += database.getFullyQualifiedName(); + public Table setTimeTravelStrAfterAlias(String timeTravelStrAfterAlias) { + this.timeTravelStrAfterAlias = timeTravelStrAfterAlias; + return this; + } + + public void setNameParts(List nameParts) { + this.partItems = nameParts; + } + + private void setIndex(int idx, String value) { + int size = partItems.size(); + for (int i = 0; i < idx - size + 1; i++) { + partItems.add(null); } - if (!fqn.isEmpty()) { - fqn += "."; + + if (value == null && idx == partItems.size() - 1) { + partItems.remove(idx); + } else { + partItems.set(idx, value); } + } - if (schemaName != null) { - fqn += schemaName; + private String getIndex(int idx) { + if (idx < partItems.size()) { + return partItems.get(idx); + } else { + return null; } - if (!fqn.isEmpty()) { - fqn += "."; + } + + @Override + public String getFullyQualifiedName() { + StringBuilder fqn = new StringBuilder(); + + // remove any leading empty items + // only middle items can be suppressed (e.g. dbo..MY_TABLE ) + while (!partItems.isEmpty() && (partItems.get(partItems.size() - 1) == null + || partItems.get(partItems.size() - 1).isEmpty())) { + partItems.remove(partItems.size() - 1); } - if (name != null) { - fqn += name; + for (int i = partItems.size() - 1; i >= 0; i--) { + String part = partItems.get(i); + if (part == null) { + part = ""; + } + fqn.append(part); + if (i != 0) { + fqn.append(partDelimiters.isEmpty() ? "." : partDelimiters.get(i - 1)); + } } - return fqn; + return fqn.toString(); + } + + @Override + public String getUnquotedName() { + return MultiPartName.unquote(getName()); } @Override - public void accept(FromItemVisitor fromItemVisitor) { - fromItemVisitor.visit(this); + public T accept(FromItemVisitor fromItemVisitor, S context) { + return fromItemVisitor.visit(this, context); + } + + public T accept(IntoTableVisitor intoTableVisitor, S context) { + return intoTableVisitor.visit(this, context); + } + + public String getTimeTravel() { + return timeTravelStr; } - public void accept(IntoTableVisitor intoTableVisitor) { - intoTableVisitor.visit(this); + public Table setTimeTravel(String timeTravelStr) { + this.timeTravelStr = timeTravelStr; + return this; } @Override @@ -132,10 +401,237 @@ public void setPivot(Pivot pivot) { this.pivot = pivot; } + @Override + public UnPivot getUnPivot() { + return this.unpivot; + } + + @Override + public void setUnPivot(UnPivot unpivot) { + this.unpivot = unpivot; + } + + /** + * Returns the first MySQL index hint, or {@code null}. Use {@link #getIndexHints()} for a table + * with several hints. + */ + public MySQLIndexHint getIndexHint() { + return mysqlIndexHints == null || mysqlIndexHints.isEmpty() ? null + : mysqlIndexHints.get(0); + } + + public Table withHint(MySQLIndexHint hint) { + setHint(hint); + return this; + } + + /** + * Replaces the MySQL index hints with the given hint, or removes them for {@code null}. + */ + public void setHint(MySQLIndexHint hint) { + this.mysqlIndexHints = hint == null ? null : new ArrayList<>(Collections.singleton(hint)); + } + + /** + * Returns the MySQL index hints in their order, for example + * {@code USE INDEX (i1) IGNORE INDEX FOR ORDER BY (i2)}, or {@code null} when there are none. + */ + public List getIndexHints() { + return mysqlIndexHints; + } + + public void setIndexHints(List indexHints) { + this.mysqlIndexHints = indexHints; + } + + public Table withIndexHints(List indexHints) { + setIndexHints(indexHints); + return this; + } + + public Table addIndexHint(MySQLIndexHint hint) { + if (mysqlIndexHints == null) { + mysqlIndexHints = new ArrayList<>(); + } + mysqlIndexHints.add(hint); + return this; + } + + /** Appends the MySQL index hints, each with a leading space, in their order. */ + public StringBuilder appendIndexHintsTo(StringBuilder builder) { + if (mysqlIndexHints != null) { + for (MySQLIndexHint hint : mysqlIndexHints) { + hint.appendTo(builder); + } + } + return builder; + } + + public SQLServerHints getSqlServerHints() { + return sqlServerHints; + } + + public void setSqlServerHints(SQLServerHints sqlServerHints) { + this.sqlServerHints = sqlServerHints; + } + + public SampleClause getSampleClause() { + return sampleClause; + } + + public Table setSampleClause(SampleClause sampleClause) { + this.sampleClause = sampleClause; + return this; + } + + public StringBuilder appendTo(StringBuilder builder) { + builder.append(getFullyQualifiedName()); + + if (timeTravelStr != null) { + builder.append(" ").append(timeTravelStr); + } + + if (alias != null) { + builder.append(alias); + } + + if (timeTravelStrAfterAlias != null) { + builder.append(" ").append(timeTravelStrAfterAlias); + } + + if (sampleClause != null) { + sampleClause.appendTo(builder); + } + + if (pivot != null) { + builder.append(" ").append(pivot); + } + + if (unpivot != null) { + builder.append(" ").append(unpivot); + } + + appendIndexHintsTo(builder); + + if (sqlServerHints != null) { + builder.append(sqlServerHints); + } + return builder; + } + @Override public String toString() { - return getFullyQualifiedName() - + ((pivot != null) ? " " + pivot : "") - + ((alias != null) ? alias.toString() : ""); + return appendTo(new StringBuilder()).toString(); + } + + @Override + public Table withUnPivot(UnPivot unpivot) { + return (Table) FromItem.super.withUnPivot(unpivot); + } + + @Override + public Table withAlias(Alias alias) { + return (Table) FromItem.super.withAlias(alias); + } + + @Override + public Table withPivot(Pivot pivot) { + return (Table) FromItem.super.withPivot(pivot); + } + + public Table withSqlServerHints(SQLServerHints sqlServerHints) { + this.setSqlServerHints(sqlServerHints); + return this; + } + + public List getNameParts() { + return partItems; + } + + public List getNamePartDelimiters() { + return partDelimiters; + } + + /** + * Gets the actual table when resolved against a physical schema information. + * + * @return the actual table when resolved against a physical schema information + */ + public Table getResolvedTable() { + return resolvedTable; + } + + /** + * Stores a detached copy of the resolved table's identifier. Reference-specific flags and + * clauses are not copied. + * + * @param resolvedTable the resolved table + * @return this table + */ + public Table setResolvedTable(Table resolvedTable) { + if (resolvedTable != null) { + this.resolvedTable = new Table(); + resolvedTable.copyIdentifierPartsTo(this.resolvedTable); + } + return this; + } + + /** + * Sets a table's catalog and schema only when not set. Useful for setting CURRENT_SCHEMA() and + * CURRENT_DATABASE() + * + * @param currentCatalogName the catalog name + * @param currentSchemaName the schema name + * @return the provided table + */ + public Table setUnsetCatalogAndSchema(String currentCatalogName, String currentSchemaName) { + if (tableVariable) { + return this; + } + String databaseName = getDatabaseName(); + if (databaseName == null || databaseName.isEmpty()) { + setDatabaseName(currentCatalogName); + } + + String schemaName = getSchemaName(); + if (schemaName == null || schemaName.isEmpty()) { + setSchemaName(currentSchemaName); + } + return this; + } + + /** + * Sets a tables' catalog and schema only when not set. Useful for setting CURRENT_SCHEMA() and + * CURRENT_DATABASE() + * + * @param currentCatalogName the current catalog name + * @param currentSchemaName the current schema name + * @param tables the tables + * @return the tables + */ + public static Table[] setUnsetCatalogAndSchema(String currentCatalogName, + String currentSchemaName, Table... tables) { + for (Table t : tables) { + if (t != null) { + t.setUnsetCatalogAndSchema(currentCatalogName, currentSchemaName); + } + } + return tables; + } + + /** Copies the table identifier, table-variable flag and resolved table identifier. */ + @Override + public Table clone() { + Table clone = new Table(); + copyIdentifierPartsTo(clone); + clone.setTableVariable(tableVariable); + clone.setResolvedTable(this.resolvedTable != null ? this.resolvedTable.clone() : null); + return clone; + } + + /** Copies identifier components and separators, leaving the target's other state unchanged. */ + private void copyIdentifierPartsTo(Table target) { + target.partItems = new ArrayList<>(partItems); + target.partDelimiters = new ArrayList<>(partDelimiters); } } diff --git a/src/main/java/net/sf/jsqlparser/schema/TableReference.java b/src/main/java/net/sf/jsqlparser/schema/TableReference.java new file mode 100644 index 0000000000..2d64aa10b1 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/schema/TableReference.java @@ -0,0 +1,115 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.schema; + +import java.io.Serializable; + +/** + * A relation target with optional PostgreSQL inheritance scope, shared by LOCK, TRUNCATE and the + * targets of UPDATE, DELETE and MERGE. + */ +public class TableReference implements Serializable { + private Table table; + private boolean only; + private boolean includeDescendants; + private boolean parenthesized; + + public TableReference(Table table) { + this.table = table; + } + + public Table getTable() { + return table; + } + + public void setTable(Table table) { + this.table = table; + } + + public boolean isOnly() { + return only; + } + + public void setOnly(boolean only) { + this.only = only; + if (only) { + includeDescendants = false; + } else { + parenthesized = false; + } + } + + public boolean isIncludeDescendants() { + return includeDescendants; + } + + public void setIncludeDescendants(boolean includeDescendants) { + this.includeDescendants = includeDescendants; + if (includeDescendants) { + only = false; + parenthesized = false; + } + } + + public boolean isParenthesized() { + return parenthesized; + } + + public void setParenthesized(boolean parenthesized) { + this.parenthesized = parenthesized; + if (parenthesized) { + only = true; + includeDescendants = false; + } + } + + public StringBuilder appendTo(StringBuilder builder) { + if (only) { + builder.append("ONLY "); + } + if (parenthesized) { + builder.append('('); + } + builder.append(table.getFullyQualifiedName()); + if (parenthesized) { + builder.append(')'); + } + if (includeDescendants) { + builder.append(" *"); + } + return builder; + } + + /** + * Appends the target of UPDATE, DELETE or MERGE (PostgreSQL's relation_expr_opt_alias): the + * inheritance scope surrounds the table name and the alias of the table follows it. A target + * without a scope is the table as it renders itself, with its alias and hints. + */ + public StringBuilder appendWithAliasTo(StringBuilder builder) { + if (!only && !includeDescendants || table == null) { + return builder.append(table); + } + appendTo(builder); + if (table.getAlias() != null) { + builder.append(table.getAlias()); + } + return builder; + } + + /** Whether ONLY or * describes the inheritance scope of the table. */ + public boolean hasInheritanceScope() { + return only || includeDescendants; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/AssertStatement.java b/src/main/java/net/sf/jsqlparser/statement/AssertStatement.java new file mode 100644 index 0000000000..58a294bb5f --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/AssertStatement.java @@ -0,0 +1,91 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.StringValue; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +import java.util.function.Consumer; + +/** + * BigQuery's {@code ASSERT expression [AS description]}, which fails the script when the expression + * does not evaluate to {@code TRUE}. + * + * @see Debugging + * statements + */ +public class AssertStatement extends ASTNodeAccessImpl implements Statement { + private Expression expression; + private StringValue description; + + public AssertStatement() {} + + public AssertStatement(Expression expression) { + this.expression = expression; + } + + public AssertStatement(Expression expression, StringValue description) { + this.expression = expression; + this.description = description; + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + public AssertStatement withExpression(Expression expression) { + setExpression(expression); + return this; + } + + public StringValue getDescription() { + return description; + } + + public void setDescription(StringValue description) { + this.description = description; + } + + public AssertStatement withDescription(StringValue description) { + setDescription(description); + return this; + } + + public StringBuilder appendTo(StringBuilder builder) { + return appendTo(builder, builder::append); + } + + /** Shares statement syntax with deparsers while visiting both expression and description. */ + public StringBuilder appendTo(StringBuilder builder, Consumer expressionRenderer) { + builder.append("ASSERT "); + expressionRenderer.accept(expression); + if (description != null) { + builder.append(" AS "); + expressionRenderer.accept(description); + } + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } + + @Override + public T accept(StatementVisitor statementVisitor, S context) { + return statementVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/AttachStatement.java b/src/main/java/net/sf/jsqlparser/statement/AttachStatement.java new file mode 100644 index 0000000000..84726280d1 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/AttachStatement.java @@ -0,0 +1,122 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.select.PlainSelect; + +import java.util.List; + +/** + * DuckDB's {@code ATTACH [DATABASE] [IF NOT EXISTS] path [AS alias] [(options)]}, which adds + * another database file or remote database to the session. + * + * @see ATTACH + */ +public class AttachStatement extends ASTNodeAccessImpl implements Statement { + private String databasePath; + private String alias; + private boolean usingDatabaseKeyword; + private boolean ifNotExists; + private List options; + + public String getDatabasePath() { + return databasePath; + } + + public void setDatabasePath(String databasePath) { + this.databasePath = databasePath; + } + + public AttachStatement withDatabasePath(String databasePath) { + setDatabasePath(databasePath); + return this; + } + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public AttachStatement withAlias(String alias) { + setAlias(alias); + return this; + } + + public boolean isUsingDatabaseKeyword() { + return usingDatabaseKeyword; + } + + public void setUsingDatabaseKeyword(boolean usingDatabaseKeyword) { + this.usingDatabaseKeyword = usingDatabaseKeyword; + } + + public AttachStatement withUsingDatabaseKeyword(boolean usingDatabaseKeyword) { + setUsingDatabaseKeyword(usingDatabaseKeyword); + return this; + } + + public boolean isIfNotExists() { + return ifNotExists; + } + + public void setIfNotExists(boolean ifNotExists) { + this.ifNotExists = ifNotExists; + } + + public AttachStatement withIfNotExists(boolean ifNotExists) { + setIfNotExists(ifNotExists); + return this; + } + + public List getOptions() { + return options; + } + + public void setOptions(List options) { + this.options = options; + } + + public AttachStatement withOptions(List options) { + setOptions(options); + return this; + } + + public StringBuilder appendTo(StringBuilder builder) { + builder.append("ATTACH "); + if (usingDatabaseKeyword) { + builder.append("DATABASE "); + } + if (ifNotExists) { + builder.append("IF NOT EXISTS "); + } + builder.append(databasePath); + if (alias != null) { + builder.append(" AS ").append(alias); + } + if (options != null && !options.isEmpty()) { + builder.append(" ").append(PlainSelect.getStringList(options, true, true)); + } + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } + + @Override + public T accept(StatementVisitor statementVisitor, S context) { + return statementVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/Block.java b/src/main/java/net/sf/jsqlparser/statement/Block.java new file mode 100644 index 0000000000..a4e822f01b --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/Block.java @@ -0,0 +1,66 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import java.util.function.Consumer; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +public class Block extends ASTNodeAccessImpl implements Statement { + private boolean hasSemicolonAfterEnd = false; + + private Statements statements; + + public Statements getStatements() { + return statements; + } + + public void setStatements(Statements statements) { + this.statements = statements; + } + + public boolean hasSemicolonAfterEnd() { + return hasSemicolonAfterEnd; + } + + public void setSemicolonAfterEnd(boolean hasSemicolonAfterEnd) { + this.hasSemicolonAfterEnd = hasSemicolonAfterEnd; + } + + @Override + public T accept(StatementVisitor statementVisitor, S context) { + return statementVisitor.visit(this, context); + } + + public StringBuilder appendTo(StringBuilder builder) { + return appendTo(builder, builder::append); + } + + public StringBuilder appendTo(StringBuilder builder, Consumer statementsPrinter) { + builder.append("BEGIN\n"); + if (statements != null) { + statementsPrinter.accept(statements); + } + builder.append("END"); + if (hasSemicolonAfterEnd) { + builder.append(";"); + } + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } + + public Block withStatements(Statements statements) { + this.setStatements(statements); + return this; + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/CSVColumn.java b/src/main/java/net/sf/jsqlparser/statement/CSVColumn.java new file mode 100644 index 0000000000..08c7f4d1d9 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/CSVColumn.java @@ -0,0 +1,91 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2022 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import net.sf.jsqlparser.expression.StringValue; + +public class CSVColumn { + private Long startIndex; + private Long endIndex; + private StringValue format; + private String delimit; + + public CSVColumn(Long startIndex, Long endIndex) { + this.startIndex = startIndex; + this.endIndex = endIndex; + } + + public CSVColumn(Long index) { + this(index, null); + } + + public Long getStartIndex() { + return startIndex; + } + + public void setStartIndex(Long startIndex) { + this.startIndex = startIndex; + } + + public Long getIndex() { + return getStartIndex(); + } + + public void setIndex(Long index) { + setStartIndex(index); + } + + public Long getEndIndex() { + return endIndex; + } + + public void setEndIndex(Long endIndex) { + this.endIndex = endIndex; + } + + public StringValue getFormat() { + return format; + } + + public void setFormat(StringValue format) { + this.format = format; + } + + public String getDelimit() { + return delimit; + } + + public void setDelimit(String delimit) { + this.delimit = delimit; + } + + @Override + public String toString() { + StringBuilder sql = new StringBuilder(); + + sql.append(startIndex); + if (endIndex != null) { + sql.append(" .. "); + sql.append(endIndex); + } else if (format != null || delimit != null) { + if (format != null) { + sql.append(" FORMAT = "); + sql.append(format); + } + + if (delimit != null) { + sql.append(" DELIMIT = "); + sql.append(delimit); + } + } + + return sql.toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/CSVFileDestination.java b/src/main/java/net/sf/jsqlparser/statement/CSVFileDestination.java new file mode 100644 index 0000000000..697368f834 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/CSVFileDestination.java @@ -0,0 +1,75 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2022 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import net.sf.jsqlparser.expression.StringValue; + +public class CSVFileDestination implements ErrorDestination { + private ConnectionDefinition connectionDefinition; + private boolean local; + private boolean secure; + private StringValue file; + + public ConnectionDefinition getConnectionDefinition() { + return connectionDefinition; + } + + public void setConnectionDefinition(ConnectionDefinition connectionDefinition) { + this.connectionDefinition = connectionDefinition; + } + + public boolean isLocal() { + return local; + } + + public void setLocal(boolean local) { + this.local = local; + } + + public boolean isSecure() { + return secure; + } + + public void setSecure(boolean secure) { + this.secure = secure; + } + + public StringValue getFile() { + return file; + } + + public void setFile(StringValue file) { + this.file = file; + } + + @Override + public String toString() { + StringBuilder sql = new StringBuilder(); + + if (local) { + sql.append("LOCAL "); + if (secure) { + sql.append("SECURE "); + } + } + + sql.append("CSV"); + + if (connectionDefinition != null) { + sql.append(" "); + sql.append(connectionDefinition); + } + + sql.append(" FILE "); + sql.append(file); + + return sql.toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/CascadeBehavior.java b/src/main/java/net/sf/jsqlparser/statement/CascadeBehavior.java new file mode 100644 index 0000000000..a67de27309 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/CascadeBehavior.java @@ -0,0 +1,18 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +/** + * An explicit CASCADE or RESTRICT clause. A null field leaves the clause omitted and preserves the + * database's default behavior for that statement. + */ +public enum CascadeBehavior { + CASCADE, RESTRICT +} diff --git a/src/main/java/net/sf/jsqlparser/statement/CastSignature.java b/src/main/java/net/sf/jsqlparser/statement/CastSignature.java new file mode 100644 index 0000000000..2aeb0bb286 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/CastSignature.java @@ -0,0 +1,69 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.create.table.ColDataType; + +/** + * A PostgreSQL cast, named by the types it converts between: {@code (source_type AS target_type)}, + * as in {@code DROP CAST (text AS integer)}. + */ +public class CastSignature extends ASTNodeAccessImpl { + + private ColDataType sourceType; + private ColDataType targetType; + + public CastSignature() { + // the types are set by the parser or the setters + } + + public CastSignature(ColDataType sourceType, ColDataType targetType) { + this.sourceType = sourceType; + this.targetType = targetType; + } + + public ColDataType getSourceType() { + return sourceType; + } + + public void setSourceType(ColDataType sourceType) { + this.sourceType = sourceType; + } + + public CastSignature withSourceType(ColDataType sourceType) { + setSourceType(sourceType); + return this; + } + + public ColDataType getTargetType() { + return targetType; + } + + public void setTargetType(ColDataType targetType) { + this.targetType = targetType; + } + + public CastSignature withTargetType(ColDataType targetType) { + setTargetType(targetType); + return this; + } + + @Override + public StringBuilder appendTo(StringBuilder builder) { + return builder.append('(').append(sourceType).append(" AS ").append(targetType) + .append(')'); + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/CertificateVerification.java b/src/main/java/net/sf/jsqlparser/statement/CertificateVerification.java new file mode 100644 index 0000000000..7aabbb060f --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/CertificateVerification.java @@ -0,0 +1,67 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2025 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import net.sf.jsqlparser.expression.StringValue; + +import java.io.Serializable; + +public class CertificateVerification implements Serializable { + private Boolean ignoreCertificate; + private StringValue publicKey; + + public StringValue getPublicKey() { + return publicKey; + } + + public void setPublicKey(StringValue publicKey) { + this.publicKey = publicKey; + } + + public Boolean getIgnoreCertificate() { + return ignoreCertificate; + } + + public void setIgnoreCertificate(Boolean ignoreCertificate) { + this.ignoreCertificate = ignoreCertificate; + } + + public Boolean getVerifyCertificate() { + return !ignoreCertificate; + } + + public void setVerifyCertificate(Boolean verifyCertificate) { + this.ignoreCertificate = !verifyCertificate; + } + + @Override + public String toString() { + StringBuilder sql = new StringBuilder(); + + if (ignoreCertificate != null) { + if (ignoreCertificate) { + sql.append("IGNORE "); + } else { + sql.append("VERIFY "); + } + sql.append("CERTIFICATE"); + } + + if (publicKey != null) { + if (ignoreCertificate != null) { + sql.append(" "); + } + sql.append("PUBLIC KEY "); + sql.append(publicKey); + } + + return sql.toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/CloudConnectionDefinition.java b/src/main/java/net/sf/jsqlparser/statement/CloudConnectionDefinition.java new file mode 100644 index 0000000000..82b65fbd7d --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/CloudConnectionDefinition.java @@ -0,0 +1,37 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2022 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +public class CloudConnectionDefinition extends ConnectionDefinition { + private String storage; + + public String getStorage() { + return storage; + } + + public void setStorage(String storage) { + this.storage = storage; + } + + @Override + public void setCertificateVerification(CertificateVerification certificateVerification) {} + + @Override + public String toString() { + StringBuilder sql = new StringBuilder(); + + sql.append("AT CLOUD "); + sql.append(storage); + sql.append(" "); + appendConnectionDefinition(sql); + + return sql.toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/Commit.java b/src/main/java/net/sf/jsqlparser/statement/Commit.java new file mode 100644 index 0000000000..a0738414d9 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/Commit.java @@ -0,0 +1,80 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import java.util.Objects; + +/** + * COMMIT, or its PostgreSQL spelling END. PostgreSQL {@code COMMIT PREPARED 'id'} commits a + * prepared transaction instead of the current one. + */ +public class Commit extends TransactionCompletionStatement { + /** The keyword that starts the statement; both commit the current transaction. */ + public enum Command { + COMMIT, END + } + + private Command command = Command.COMMIT; + + public Command getCommand() { + return command; + } + + public void setCommand(Command command) { + this.command = Objects.requireNonNull(command, "command"); + } + + public Commit withCommand(Command command) { + setCommand(command); + return this; + } + + public Commit withKeyword(TransactionKeyword keyword) { + setKeyword(keyword); + return this; + } + + public Commit withChain(TransactionChain chain) { + setChain(chain); + return this; + } + + public Commit withRelease(TransactionRelease release) { + setRelease(release); + return this; + } + + /** + * Names the prepared transaction of PostgreSQL {@code COMMIT PREPARED 'id'}; null commits the + * current transaction. + */ + public Commit withPreparedTransaction(TransactionId id) { + setPreparedTransaction(PreparedTransactionKeyword.PREPARED, id); + return this; + } + + @Override + public boolean isPostgresSpelling() { + return command == Command.END; + } + + @Override + public T accept(StatementVisitor statementVisitor, S context) { + return statementVisitor.visit(this, context); + } + + @Override + public StringBuilder appendTo(StringBuilder builder) { + builder.append(command); + appendKeyword(builder); + appendPreparedTransaction(builder); + return appendCompletion(builder); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/ComponentVariable.java b/src/main/java/net/sf/jsqlparser/statement/ComponentVariable.java new file mode 100644 index 0000000000..4c50128e45 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/ComponentVariable.java @@ -0,0 +1,112 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import java.io.Serializable; +import java.util.Objects; +import java.util.function.Consumer; +import net.sf.jsqlparser.expression.Expression; + +/** + * One assignment of the {@code SET} clause of MySQL's {@code INSTALL COMPONENT}: + * {@code [GLOBAL | PERSIST] variable {= | :=} value}. The value is an expression, or the word + * {@code ON}, which is read as a column. + * + * @see PluginStatement + */ +public class ComponentVariable implements Serializable { + private SetScope scope = SetScope.NONE; + private String name; + private SetStatement.AssignmentOperator operator = SetStatement.AssignmentOperator.EQUALS; + private Expression value; + + public ComponentVariable(String name, Expression value) { + this.name = Objects.requireNonNull(name, "name"); + this.value = Objects.requireNonNull(value, "value"); + } + + /** {@link SetScope#GLOBAL}, {@link SetScope#PERSIST}, or {@link SetScope#NONE} if not given. */ + public SetScope getScope() { + return scope; + } + + /** + * Sets the scope keyword; null means none. + * + * @throws IllegalArgumentException for a scope other than GLOBAL, PERSIST or NONE + */ + public void setScope(SetScope scope) { + SetScope value = scope == null ? SetScope.NONE : scope; + if (value != SetScope.NONE && value != SetScope.GLOBAL && value != SetScope.PERSIST) { + throw new IllegalArgumentException("INSTALL COMPONENT SET does not accept " + value); + } + this.scope = value; + } + + public ComponentVariable withScope(SetScope scope) { + setScope(scope); + return this; + } + + /** The variable name as written: {@code variable} or {@code component.variable}. */ + public String getName() { + return name; + } + + public void setName(String name) { + this.name = Objects.requireNonNull(name, "name"); + } + + /** {@code =} or {@code :=}. */ + public SetStatement.AssignmentOperator getOperator() { + return operator; + } + + /** + * Sets the assignment operator. + * + * @throws IllegalArgumentException for an operator other than EQUALS or COLON_EQUALS + */ + public void setOperator(SetStatement.AssignmentOperator operator) { + if (operator != SetStatement.AssignmentOperator.EQUALS + && operator != SetStatement.AssignmentOperator.COLON_EQUALS) { + throw new IllegalArgumentException("INSTALL COMPONENT SET assigns with = or :="); + } + this.operator = operator; + } + + public ComponentVariable withOperator(SetStatement.AssignmentOperator operator) { + setOperator(operator); + return this; + } + + public Expression getValue() { + return value; + } + + public void setValue(Expression value) { + this.value = Objects.requireNonNull(value, "value"); + } + + public StringBuilder appendTo(StringBuilder builder, Consumer expressionPrinter) { + if (scope != SetScope.NONE) { + builder.append(scope.getKeyword()).append(' '); + } + builder.append(name).append(' ').append(operator.getToken()).append(' '); + expressionPrinter.accept(value); + return builder; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, builder::append).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/ConfigurationParameterChange.java b/src/main/java/net/sf/jsqlparser/statement/ConfigurationParameterChange.java new file mode 100644 index 0000000000..913cace5e6 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/ConfigurationParameterChange.java @@ -0,0 +1,175 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import java.io.Serializable; +import java.util.function.Consumer; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; + +/** + * A PostgreSQL {@code SET} or {@code RESET} of a configuration parameter, shared by statements that + * store parameter defaults: {@code ALTER ROLE}, {@code ALTER DATABASE} and the routine + * characteristics of {@code ALTER FUNCTION}, {@code ALTER PROCEDURE} and {@code ALTER ROUTINE}: + * + *
+ * SET parameter { TO | = } { value [, ...] | DEFAULT }
+ * SET parameter FROM CURRENT
+ * RESET { parameter | ALL }
+ * 
+ * + * Parameter names keep their SQL spelling, including qualifiers and identifier quotes. + * {@code RESET ALL} uses the parameter name {@code ALL}. + */ +public class ConfigurationParameterChange implements Serializable { + + public enum Action { + SET, RESET + } + + /** What a {@code SET} assigns. Only the selected kind is rendered. */ + public enum ValueKind { + /** The explicit values of {@link #getValues()}. */ + VALUES, + /** {@code TO DEFAULT} or {@code = DEFAULT}. */ + DEFAULT, + /** {@code FROM CURRENT}. */ + FROM_CURRENT + } + + private Action action = Action.SET; + private String parameter; + private ValueKind valueKind = ValueKind.VALUES; + private boolean useEquals; + private ExpressionList values; + + public ConfigurationParameterChange() {} + + public ConfigurationParameterChange(Action action, String parameter) { + this.action = action; + this.parameter = parameter; + } + + public Action getAction() { + return action; + } + + public void setAction(Action action) { + this.action = action; + } + + public String getParameter() { + return parameter; + } + + public void setParameter(String parameter) { + this.parameter = parameter; + } + + public ValueKind getValueKind() { + return valueKind; + } + + /** + * Selects what a {@code SET} assigns. The values are retained when another kind is selected. + * + * @param valueKind the assigned value kind + */ + public void setValueKind(ValueKind valueKind) { + this.valueKind = valueKind; + } + + /** + * Whether {@code =} rather than {@code TO} precedes the value. + * + * @return {@code true} for {@code =} + */ + public boolean isUseEquals() { + return useEquals; + } + + public void setUseEquals(boolean useEquals) { + this.useEquals = useEquals; + } + + /** + * The values assigned by {@link ValueKind#VALUES}, as a mutable list. + * + * @return the values, or {@code null} if none were set + */ + public ExpressionList getValues() { + return values; + } + + public void setValues(ExpressionList values) { + this.values = values; + } + + public ConfigurationParameterChange withAction(Action action) { + setAction(action); + return this; + } + + public ConfigurationParameterChange withParameter(String parameter) { + setParameter(parameter); + return this; + } + + public ConfigurationParameterChange withValueKind(ValueKind valueKind) { + setValueKind(valueKind); + return this; + } + + public ConfigurationParameterChange withUseEquals(boolean useEquals) { + setUseEquals(useEquals); + return this; + } + + public ConfigurationParameterChange withValues(ExpressionList values) { + setValues(values); + return this; + } + + /** + * Appends this clause to a builder. + * + * @param builder the target + * @param valueRenderer appends each value, for example through an expression deparser + * @return the builder + */ + public StringBuilder appendTo(StringBuilder builder, Consumer valueRenderer) { + if (action == Action.RESET) { + return builder.append("RESET ").append(parameter); + } + builder.append("SET ").append(parameter); + if (valueKind == ValueKind.FROM_CURRENT) { + return builder.append(" FROM CURRENT"); + } + builder.append(useEquals ? " = " : " TO "); + if (valueKind == ValueKind.DEFAULT) { + return builder.append("DEFAULT"); + } + if (values != null) { + for (int i = 0; i < values.size(); i++) { + if (i > 0) { + builder.append(", "); + } + valueRenderer.accept(values.get(i)); + } + } + return builder; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, builder::append).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/ConnectStatement.java b/src/main/java/net/sf/jsqlparser/statement/ConnectStatement.java new file mode 100644 index 0000000000..829410b280 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/ConnectStatement.java @@ -0,0 +1,71 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** + * DuckDB's {@code CONNECT target [AS alias]}, which routes the session's queries to a remote + * database. + */ +public class ConnectStatement extends ASTNodeAccessImpl implements Statement { + private String target; + private String alias; + + public ConnectStatement() {} + + public ConnectStatement(String target) { + this.target = target; + } + + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + + public ConnectStatement withTarget(String target) { + setTarget(target); + return this; + } + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public ConnectStatement withAlias(String alias) { + setAlias(alias); + return this; + } + + public StringBuilder appendTo(StringBuilder builder) { + builder.append("CONNECT ").append(target); + if (alias != null) { + builder.append(" AS ").append(alias); + } + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } + + @Override + public T accept(StatementVisitor statementVisitor, S context) { + return statementVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/ConnectionDefinition.java b/src/main/java/net/sf/jsqlparser/statement/ConnectionDefinition.java new file mode 100644 index 0000000000..f2887cf822 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/ConnectionDefinition.java @@ -0,0 +1,91 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2022 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import net.sf.jsqlparser.expression.StringValue; + +import java.io.Serializable; + +public class ConnectionDefinition implements Serializable { + private String connectionObjectName; + private StringValue connectionDefinition; + private UserIdentification userIdentification; + private CertificateVerification certificateVerification; + + public String getConnectionObjectName() { + return connectionObjectName; + } + + public void setConnectionObjectName(String connectionObjectName) { + this.connectionObjectName = connectionObjectName; + } + + public StringValue getConnectionDefinition() { + return connectionDefinition; + } + + public void setConnectionDefinition(StringValue connectionDefinition) { + this.connectionDefinition = connectionDefinition; + } + + public void setConnection(String connectionObjectName) { + this.connectionObjectName = connectionObjectName; + } + + public void setConnection(StringValue connectionDefinition) { + this.connectionDefinition = connectionDefinition; + } + + public UserIdentification getUserIdentification() { + return userIdentification; + } + + public void setUserIdentification(UserIdentification userIdentification) { + this.userIdentification = userIdentification; + } + + public CertificateVerification getCertificateVerification() { + return certificateVerification; + } + + public void setCertificateVerification(CertificateVerification certificateVerification) { + this.certificateVerification = certificateVerification; + } + + protected StringBuilder appendConnectionDefinition(StringBuilder sql) { + if (connectionObjectName != null) { + sql.append(connectionObjectName); + } else if (connectionDefinition != null) { + sql.append(connectionDefinition); + } + + if (userIdentification != null) { + sql.append(" "); + sql.append(userIdentification); + } + + if (certificateVerification != null) { + sql.append(" "); + sql.append(certificateVerification); + } + + return sql; + } + + @Override + public String toString() { + StringBuilder sql = new StringBuilder(); + + sql.append("AT "); + appendConnectionDefinition(sql); + + return sql.toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/ConnectionFileDefinition.java b/src/main/java/net/sf/jsqlparser/statement/ConnectionFileDefinition.java new file mode 100644 index 0000000000..f0e0d0cf14 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/ConnectionFileDefinition.java @@ -0,0 +1,60 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2022 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import net.sf.jsqlparser.expression.StringValue; + +import java.util.List; + +public class ConnectionFileDefinition { + private ConnectionDefinition connectionDefinition; + private List filePaths; + + public ConnectionFileDefinition(List filePaths) { + this(null, filePaths); + } + + public ConnectionFileDefinition(ConnectionDefinition connectionDefinition, + List filePaths) { + this.connectionDefinition = connectionDefinition; + this.filePaths = filePaths; + } + + public ConnectionDefinition getConnectionDefinition() { + return connectionDefinition; + } + + public void setConnectionDefinition(ConnectionDefinition connectionDefinition) { + this.connectionDefinition = connectionDefinition; + } + + public List getFilePaths() { + return filePaths; + } + + public void setFilePaths(List filePaths) { + this.filePaths = filePaths; + } + + @Override + public String toString() { + StringBuilder sql = new StringBuilder(); + + if (connectionDefinition != null) { + sql.append(connectionDefinition); + } + + for (StringValue filePath : filePaths) { + sql.append(" FILE ").append(filePath); + } + + return sql.toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/CopyLegacyOption.java b/src/main/java/net/sf/jsqlparser/statement/CopyLegacyOption.java new file mode 100644 index 0000000000..cbeafc4d6f --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/CopyLegacyOption.java @@ -0,0 +1,192 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import net.sf.jsqlparser.expression.StringValue; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.schema.Column; + +/** + * One option of the COPY option syntax PostgreSQL used before 9.0 and still accepts: a keyword + * without parentheses or commas, such as {@code CSV}, {@code HEADER}, {@code DELIMITER AS ';'} or + * {@code FORCE QUOTE *}. The options follow the file name and the optional {@code WITH} in any + * order, as {@code copy_opt_item} in PostgreSQL's grammar. + * + * @see COPY, section Compatibility + */ +public class CopyLegacyOption extends ASTNodeAccessImpl { + private Kind kind; + private boolean asKeyword; + private StringValue value; + private final List columns = new ArrayList<>(); + private boolean allColumns; + + /** The option keyword, and what it takes after it. */ + public enum Kind { + /** BINARY, the binary format */ + BINARY("BINARY", Argument.NONE), + /** FREEZE */ + FREEZE("FREEZE", Argument.NONE), + /** DELIMITER [AS] 'string' */ + DELIMITER("DELIMITER", Argument.STRING_AFTER_OPTIONAL_AS), + /** NULL [AS] 'string' */ + NULL("NULL", Argument.STRING_AFTER_OPTIONAL_AS), + /** CSV, the CSV format */ + CSV("CSV", Argument.NONE), + /** HEADER */ + HEADER("HEADER", Argument.NONE), + /** QUOTE [AS] 'string' */ + QUOTE("QUOTE", Argument.STRING_AFTER_OPTIONAL_AS), + /** ESCAPE [AS] 'string' */ + ESCAPE("ESCAPE", Argument.STRING_AFTER_OPTIONAL_AS), + /** FORCE QUOTE {column, ... | *} */ + FORCE_QUOTE("FORCE QUOTE", Argument.COLUMNS), + /** FORCE NOT NULL {column, ... | *} */ + FORCE_NOT_NULL("FORCE NOT NULL", Argument.COLUMNS), + /** FORCE NULL {column, ... | *} */ + FORCE_NULL("FORCE NULL", Argument.COLUMNS), + /** ENCODING 'string' */ + ENCODING("ENCODING", Argument.STRING); + + private final String keyword; + private final Argument argument; + + Kind(String keyword, Argument argument) { + this.keyword = keyword; + this.argument = argument; + } + + /** The keywords of the option, such as {@code FORCE NOT NULL}. */ + public String getKeyword() { + return keyword; + } + + /** Whether a string follows the keyword. */ + public boolean takesString() { + return argument == Argument.STRING || argument == Argument.STRING_AFTER_OPTIONAL_AS; + } + + /** Whether {@code AS} may precede the string. */ + public boolean allowsAsKeyword() { + return argument == Argument.STRING_AFTER_OPTIONAL_AS; + } + + /** Whether a column list or {@code *} follows the keyword. */ + public boolean takesColumns() { + return argument == Argument.COLUMNS; + } + } + + private enum Argument { + NONE, STRING, STRING_AFTER_OPTIONAL_AS, COLUMNS + } + + public CopyLegacyOption(Kind kind) { + setKind(kind); + } + + public Kind getKind() { + return kind; + } + + public void setKind(Kind kind) { + this.kind = Objects.requireNonNull(kind, "kind"); + } + + /** Whether {@code AS} precedes the string, as in {@code DELIMITER AS ','}. */ + public boolean isAsKeyword() { + return asKeyword; + } + + public void setAsKeyword(boolean asKeyword) { + this.asKeyword = asKeyword; + } + + public CopyLegacyOption withAsKeyword(boolean asKeyword) { + setAsKeyword(asKeyword); + return this; + } + + /** The string of DELIMITER, NULL, QUOTE, ESCAPE or ENCODING; null for the other options. */ + public StringValue getValue() { + return value; + } + + public void setValue(StringValue value) { + this.value = value; + } + + public CopyLegacyOption withValue(StringValue value) { + setValue(value); + return this; + } + + /** The columns of a FORCE option; empty for {@code *} and for the other options. */ + public List getColumns() { + return columns; + } + + public void setColumns(Collection columns) { + List replacement = + columns == null ? Collections.emptyList() : new ArrayList<>(columns); + this.columns.clear(); + this.columns.addAll(replacement); + } + + public CopyLegacyOption addColumns(Column... columns) { + Collections.addAll(this.columns, columns); + return this; + } + + public CopyLegacyOption withColumns(Collection columns) { + setColumns(columns); + return this; + } + + /** Whether a FORCE option applies to every column, written {@code *}. */ + public boolean isAllColumns() { + return allColumns; + } + + public void setAllColumns(boolean allColumns) { + this.allColumns = allColumns; + } + + public CopyLegacyOption withAllColumns(boolean allColumns) { + setAllColumns(allColumns); + return this; + } + + @Override + public StringBuilder appendTo(StringBuilder builder) { + builder.append(kind.getKeyword()); + if (value != null) { + builder.append(asKeyword ? " AS " : " ").append(value); + } + if (allColumns) { + builder.append(" *"); + } else { + for (int i = 0; i < columns.size(); i++) { + builder.append(i == 0 ? " " : ", ").append(columns.get(i).getFullyQualifiedName()); + } + } + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/CopyStatement.java b/src/main/java/net/sf/jsqlparser/statement/CopyStatement.java new file mode 100644 index 0000000000..e253143685 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/CopyStatement.java @@ -0,0 +1,223 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import net.sf.jsqlparser.expression.operators.relational.ExpressionList; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.schema.Column; +import net.sf.jsqlparser.schema.Table; +import net.sf.jsqlparser.statement.select.PlainSelect; +import net.sf.jsqlparser.statement.select.Select; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.function.Consumer; + +/** + * {@code COPY table [(columns)] FROM path [(options)]} and + * {@code COPY {table | (query)} TO path [(options)]}, the bulk import and export statement in + * DuckDB and PostgreSQL. PostgreSQL also accepts its option syntax from before 9.0, options without + * parentheses such as {@code CSV HEADER} (see {@link #getLegacyOptions()}), and + * {@code COPY BINARY table}. + * + * @see COPY + * @see PostgreSQL COPY + */ +public class CopyStatement extends ASTNodeAccessImpl implements Statement { + private Table table; + private ExpressionList columns; + private Select select; + private boolean from; + private String path; + private List options; + private boolean withKeyword; + private boolean binary; + private final List legacyOptions = new ArrayList<>(); + + public Table getTable() { + return table; + } + + public void setTable(Table table) { + this.table = table; + } + + public CopyStatement withTable(Table table) { + setTable(table); + return this; + } + + public ExpressionList getColumns() { + return columns; + } + + public void setColumns(ExpressionList columns) { + this.columns = columns; + } + + public CopyStatement withColumns(ExpressionList columns) { + setColumns(columns); + return this; + } + + public Select getSelect() { + return select; + } + + public void setSelect(Select select) { + this.select = select; + } + + public CopyStatement withSelect(Select select) { + setSelect(select); + return this; + } + + /** {@code true} for COPY ... FROM (import), {@code false} for COPY ... TO (export). */ + public boolean isFrom() { + return from; + } + + public void setFrom(boolean from) { + this.from = from; + } + + public CopyStatement withFrom(boolean from) { + setFrom(from); + return this; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public CopyStatement withPath(String path) { + setPath(path); + return this; + } + + /** The options in parentheses, each as written; null when the statement has none. */ + public List getOptions() { + return options; + } + + public void setOptions(List options) { + this.options = options; + } + + public CopyStatement withOptions(List options) { + setOptions(options); + return this; + } + + /** Whether the option list is introduced by the optional WITH keyword. */ + public boolean isWithKeyword() { + return withKeyword; + } + + public void setWithKeyword(boolean withKeyword) { + this.withKeyword = withKeyword; + } + + public CopyStatement withWithKeyword(boolean withKeyword) { + setWithKeyword(withKeyword); + return this; + } + + /** Whether the table is preceded by BINARY, PostgreSQL's spelling from before 7.3. */ + public boolean isBinary() { + return binary; + } + + public void setBinary(boolean binary) { + this.binary = binary; + } + + public CopyStatement withBinary(boolean binary) { + setBinary(binary); + return this; + } + + /** + * The options of PostgreSQL's syntax from before 9.0, in source order, such as {@code CSV} and + * {@code HEADER} in {@code COPY t TO STDOUT CSV HEADER}; empty when the statement has none. A + * statement has either these options or the options in parentheses. + */ + public List getLegacyOptions() { + return legacyOptions; + } + + public void setLegacyOptions(Collection legacyOptions) { + List replacement = legacyOptions == null + ? Collections.emptyList() + : new ArrayList<>(legacyOptions); + this.legacyOptions.clear(); + this.legacyOptions.addAll(replacement); + } + + public CopyStatement addLegacyOptions(CopyLegacyOption... legacyOptions) { + Collections.addAll(this.legacyOptions, legacyOptions); + return this; + } + + public CopyStatement withLegacyOptions(Collection legacyOptions) { + setLegacyOptions(legacyOptions); + return this; + } + + public StringBuilder appendTo(StringBuilder builder) { + return appendTo(builder, builder::append); + } + + /** Renders the query through the caller's select writer. */ + public StringBuilder appendTo(StringBuilder builder, Consumer selectPrinter, + Consumer expressionPrinter) { + builder.append(describeType).append(" "); + if (select != null) { + selectPrinter.accept(select); + } else { + builder.append(table); + if (columnPattern != null) { + builder.append(" "); + expressionPrinter.accept(columnPattern); + } + } + return builder; + } + + @Override + public T accept(StatementVisitor statementVisitor, S context) { + return statementVisitor.visit(this, context); + } + + public DescribeStatement withTable(Table table) { + this.setTable(table); + return this; + } + + public String getDescribeType() { + return describeType; + } + + public DescribeStatement setDescribeType(String describeType) { + this.describeType = describeType; + return this; + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/DetachStatement.java b/src/main/java/net/sf/jsqlparser/statement/DetachStatement.java new file mode 100644 index 0000000000..d8bd25f810 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/DetachStatement.java @@ -0,0 +1,90 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** + * DuckDB's {@code DETACH [DATABASE] [IF EXISTS] name}, the counterpart of {@link AttachStatement}. + * + * @see DETACH + */ +public class DetachStatement extends ASTNodeAccessImpl implements Statement { + private String databaseName; + private boolean usingDatabaseKeyword; + private boolean ifExists; + + public DetachStatement() {} + + public DetachStatement(String databaseName) { + this.databaseName = databaseName; + } + + public String getDatabaseName() { + return databaseName; + } + + public void setDatabaseName(String databaseName) { + this.databaseName = databaseName; + } + + public DetachStatement withDatabaseName(String databaseName) { + setDatabaseName(databaseName); + return this; + } + + public boolean isUsingDatabaseKeyword() { + return usingDatabaseKeyword; + } + + public void setUsingDatabaseKeyword(boolean usingDatabaseKeyword) { + this.usingDatabaseKeyword = usingDatabaseKeyword; + } + + public DetachStatement withUsingDatabaseKeyword(boolean usingDatabaseKeyword) { + setUsingDatabaseKeyword(usingDatabaseKeyword); + return this; + } + + public boolean isIfExists() { + return ifExists; + } + + public void setIfExists(boolean ifExists) { + this.ifExists = ifExists; + } + + public DetachStatement withIfExists(boolean ifExists) { + setIfExists(ifExists); + return this; + } + + public StringBuilder appendTo(StringBuilder builder) { + builder.append("DETACH "); + if (usingDatabaseKeyword) { + builder.append("DATABASE "); + } + if (ifExists) { + builder.append("IF EXISTS "); + } + builder.append(databaseName); + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } + + @Override + public T accept(StatementVisitor statementVisitor, S context) { + return statementVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/DiscardStatement.java b/src/main/java/net/sf/jsqlparser/statement/DiscardStatement.java new file mode 100644 index 0000000000..9d9987d6e0 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/DiscardStatement.java @@ -0,0 +1,79 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import java.util.Objects; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** + * PostgreSQL {@code DISCARD {ALL | PLANS | SEQUENCES | TEMP | TEMPORARY}}, which releases the + * session state that the target names. + * + * @see DISCARD + */ +public class DiscardStatement extends ASTNodeAccessImpl implements Statement { + private Target target = Target.ALL; + + /** + * What DISCARD releases. {@code TEMP} and {@code TEMPORARY} are one target, both kept so that + * the statement prints as written. + */ + public enum Target { + /** Every kind of session state, including the other targets. */ + ALL, + /** Cached query plans. */ + PLANS, + /** Cached sequence state. */ + SEQUENCES, + /** Temporary tables, spelled TEMP. */ + TEMP, + /** Temporary tables, spelled TEMPORARY. */ + TEMPORARY + } + + public DiscardStatement() {} + + public DiscardStatement(Target target) { + setTarget(target); + } + + public Target getTarget() { + return target; + } + + public void setTarget(Target target) { + this.target = Objects.requireNonNull(target, "target"); + } + + public DiscardStatement withTarget(Target target) { + setTarget(target); + return this; + } + + /** Whether the statement drops the temporary tables of the session: ALL, TEMP or TEMPORARY. */ + public boolean isDroppingTemporaryTables() { + return target == Target.ALL || target == Target.TEMP || target == Target.TEMPORARY; + } + + @Override + public StringBuilder appendTo(StringBuilder builder) { + return builder.append("DISCARD ").append(target.name()); + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } + + @Override + public T accept(StatementVisitor statementVisitor, S context) { + return statementVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/DisconnectStatement.java b/src/main/java/net/sf/jsqlparser/statement/DisconnectStatement.java new file mode 100644 index 0000000000..1231963f67 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/DisconnectStatement.java @@ -0,0 +1,56 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; + +/** + * DuckDB's {@code DISCONNECT [name]}, the counterpart of {@link ConnectStatement}. + */ +public class DisconnectStatement extends ASTNodeAccessImpl implements Statement { + private String name; + + public DisconnectStatement() {} + + public DisconnectStatement(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public DisconnectStatement withName(String name) { + setName(name); + return this; + } + + public StringBuilder appendTo(StringBuilder builder) { + builder.append("DISCONNECT"); + if (name != null) { + builder.append(" ").append(name); + } + return builder; + } + + @Override + public String toString() { + return appendTo(new StringBuilder()).toString(); + } + + @Override + public T accept(StatementVisitor statementVisitor, S context) { + return statementVisitor.visit(this, context); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/DoStatement.java b/src/main/java/net/sf/jsqlparser/statement/DoStatement.java new file mode 100644 index 0000000000..c8c87fd4aa --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/DoStatement.java @@ -0,0 +1,130 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2026 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import java.util.List; +import java.util.function.Consumer; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.StringValue; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.statement.select.SelectItem; + +/** + * A {@code DO} statement: a PostgreSQL anonymous routine, whose language-specific body remains a + * string literal, or MySQL's {@code DO expr [, expr] ...}, which evaluates expressions without + * returning a result. MySQL reads the expressions as a select list, so they can carry aliases. + * + * @see PostgreSQL DO + * @see MySQL DO + */ +public class DoStatement extends ASTNodeAccessImpl implements Statement { + private StringValue code; + private String language; + private boolean languageBeforeCode; + private List> selectItems; + + public StringValue getCode() { + return code; + } + + public void setCode(StringValue code) { + this.code = code; + } + + public DoStatement withCode(StringValue code) { + setCode(code); + return this; + } + + /** Returns the explicit language, or null when omitted. */ + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + + public DoStatement withLanguage(String language) { + setLanguage(language); + return this; + } + + public boolean isLanguageBeforeCode() { + return languageBeforeCode; + } + + public void setLanguageBeforeCode(boolean languageBeforeCode) { + this.languageBeforeCode = languageBeforeCode; + } + + /** The expressions of MySQL's form, or null for a PostgreSQL code block. */ + public List> getSelectItems() { + return selectItems; + } + + public void setSelectItems(List> selectItems) { + this.selectItems = selectItems; + } + + public DoStatement withSelectItems(List> selectItems) { + setSelectItems(selectItems); + return this; + } + + /** Visits the code block, or the expression of every select item. */ + public void visitExpressions(Consumer visitor) { + if (selectItems != null) { + for (SelectItem item : selectItems) { + visitor.accept(item.getExpression()); + } + } else if (code != null) { + visitor.accept(code); + } + } + + public StringBuilder appendTo(StringBuilder builder, Consumer codePrinter) { + return appendTo(builder, codePrinter, builder::append); + } + + /** Renders the code block or the select items through the caller's writers. */ + public StringBuilder appendTo(StringBuilder builder, Consumer codePrinter, + Consumer> itemPrinter) { + builder.append("DO "); + if (selectItems != null) { + for (int i = 0; i < selectItems.size(); i++) { + if (i > 0) { + builder.append(", "); + } + itemPrinter.accept(selectItems.get(i)); + } + return builder; + } + if (languageBeforeCode && language != null) { + builder.append("LANGUAGE ").append(language).append(' '); + } + codePrinter.accept(code); + if (!languageBeforeCode && language != null) { + builder.append(" LANGUAGE ").append(language); + } + return builder; + } + + @Override + public T accept(StatementVisitor visitor, S context) { + return visitor.visit(this, context); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + return appendTo(builder, value -> builder.append(value)).toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/ErrorClause.java b/src/main/java/net/sf/jsqlparser/statement/ErrorClause.java new file mode 100644 index 0000000000..92db1a3dcc --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/ErrorClause.java @@ -0,0 +1,90 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2022 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import net.sf.jsqlparser.expression.Expression; + +import java.io.Serializable; + +public class ErrorClause implements Serializable { + private ErrorDestination errorDestination; + private Expression expression; + private RejectClause rejectClause; + private boolean replace; + private boolean truncate; + + public ErrorDestination getErrorDestination() { + return errorDestination; + } + + public void setErrorDestination(ErrorDestination errorDestination) { + this.errorDestination = errorDestination; + } + + public Expression getExpression() { + return expression; + } + + public void setExpression(Expression expression) { + this.expression = expression; + } + + public RejectClause getRejectClause() { + return rejectClause; + } + + public void setRejectClause(RejectClause rejectClause) { + this.rejectClause = rejectClause; + } + + public boolean isReplace() { + return replace; + } + + public void setReplace(boolean replace) { + this.replace = replace; + } + + public boolean isTruncate() { + return truncate; + } + + public void setTruncate(boolean truncate) { + this.truncate = truncate; + } + + @Override + public String toString() { + StringBuilder sql = new StringBuilder(); + + if (errorDestination != null) { + sql.append("ERRORS INTO "); + sql.append(errorDestination); + if (expression != null) { + sql.append(" ("); + sql.append(expression); + sql.append(")"); + } + + if (replace) { + sql.append(" REPLACE"); + } else if (truncate) { + sql.append(" TRUNCATE"); + } + } + + if (rejectClause != null) { + sql.append(" "); + sql.append(rejectClause); + } + + return sql.toString(); + } +} diff --git a/src/main/java/net/sf/jsqlparser/statement/ErrorDestination.java b/src/main/java/net/sf/jsqlparser/statement/ErrorDestination.java new file mode 100644 index 0000000000..258a39ebb7 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/ErrorDestination.java @@ -0,0 +1,13 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2022 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +public interface ErrorDestination { +} diff --git a/src/main/java/net/sf/jsqlparser/statement/ExplainStatement.java b/src/main/java/net/sf/jsqlparser/statement/ExplainStatement.java new file mode 100644 index 0000000000..0bdcc1eb77 --- /dev/null +++ b/src/main/java/net/sf/jsqlparser/statement/ExplainStatement.java @@ -0,0 +1,398 @@ +/*- + * #%L + * JSQLParser library + * %% + * Copyright (C) 2004 - 2019 JSQLParser + * %% + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 + * #L% + */ +package net.sf.jsqlparser.statement; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.function.Consumer; +import net.sf.jsqlparser.expression.Expression; +import net.sf.jsqlparser.expression.UserVariable; +import net.sf.jsqlparser.parser.ASTNodeAccessImpl; +import net.sf.jsqlparser.schema.Table; + +/** + * An {@code EXPLAIN} statement. It explains a statement, describes a table, or, in MySQL, explains + * the statement another connection runs. + * + * @see MySQL EXPLAIN + */ +public class ExplainStatement extends ASTNodeAccessImpl implements Statement { + private String keyword; + private Statement statement; + private List