Skip to content

Commit cb1654a

Browse files
committed
Merge branch 'master' into json_table_support
# Conflicts: # src/main/java/net/sf/jsqlparser/util/deparser/ExpressionDeParser.java # src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
2 parents 0c55268 + 40ccf4b commit cb1654a

33 files changed

+1244
-42
lines changed

.github/workflows/ci.yml

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,104 @@ name: CI Pipeline
22

33
on:
44
push:
5-
branches: [ "master" ]
5+
branches: [ "**" ] # Run on every commit to any branch
66
pull_request:
7-
branches: [ "master" ]
7+
branches: [ "**" ] # Run for PRs from any branch
88
workflow_dispatch:
99

1010
permissions: write-all
1111

1212
jobs:
1313
gradle_check:
14-
runs-on: ubuntu-latest
14+
name: Gradle Check
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ ubuntu-latest, windows-latest, macos-latest ]
1519
steps:
1620
- uses: actions/checkout@main
1721
with:
1822
fetch-depth: 0
23+
1924
- name: Set up JDK 17
2025
uses: actions/setup-java@main
2126
with:
2227
java-version: '17'
2328
distribution: 'temurin'
24-
- name: Build with Gradle
29+
30+
- name: Set up Gradle
2531
uses: gradle/actions/setup-gradle@main
32+
2633
- name: Run Gradle Check
2734
run: ./gradlew check
2835

36+
maven_verify:
37+
name: Maven Verify
38+
needs: gradle_check # ✅ Run only after Gradle check succeeds
39+
runs-on: ${{ matrix.os }}
40+
strategy:
41+
matrix:
42+
# currently Windows does not work w/ code page related issues
43+
# os: [ ubuntu-latest, windows-latest, macos-latest ]
44+
os: [ ubuntu-latest, macos-latest ]
45+
steps:
46+
- uses: actions/checkout@main
47+
with:
48+
fetch-depth: 0
49+
50+
- name: Set up JDK 17
51+
uses: actions/setup-java@main
52+
with:
53+
java-version: '17'
54+
distribution: 'temurin'
55+
56+
- name: Run Maven Verify
57+
run: mvn --batch-mode verify
58+
2959
gradle_publish:
30-
needs: gradle_check
60+
name: Gradle Publish
61+
needs: [ gradle_check, maven_verify ] # ✅ Run only after both succeed
62+
if: github.ref == 'refs/heads/master' && github.repository == 'JSQLParser/JSqlParser' # ✅ Only for master branch of main repo
3163
runs-on: ubuntu-latest
3264
steps:
3365
- uses: actions/checkout@main
3466
with:
3567
fetch-depth: 0
68+
3669
- name: Set up JDK 17
3770
uses: actions/setup-java@main
3871
with:
3972
java-version: '17'
4073
distribution: 'temurin'
74+
4175
- name: Build with Gradle
4276
uses: gradle/actions/setup-gradle@main
77+
4378
- name: Publish with Gradle
4479
run: ./gradlew publish
4580
env:
4681
ossrhUsername: ${{ secrets.OSSRHUSERNAME }}
4782
ossrhPassword: ${{ secrets.OSSRHPASSWORD }}
83+
4884
- uses: actions/setup-python@main
85+
4986
- name: Install XSLT Processor
50-
run: sudo apt-get install xsltproc sphinx-common
87+
run: sudo apt-get install -y xsltproc sphinx-common
88+
5189
- name: Install Python dependencies
52-
#run: pip install furo myst_parser sphinx-prompt sphinx_substitution_extensions sphinx_issues sphinx_inline_tabs pygments
5390
run: pip install furo myst_parser sphinx_substitution_extensions sphinx_issues sphinx_inline_tabs pygments
91+
5492
- name: Build Sphinx documentation with Gradle
55-
run: ./gradlew -DFLOATING_TOC=false gitChangelogTask renderRR xslt xmldoc sphinx
56-
- name: Deploy Sphinx documentation
93+
run: FLOATING_TOC=false ./gradlew -DFLOATING_TOC=false gitChangelogTask renderRR xslt xmldoc sphinx
94+
95+
- name: Configure GitHub Pages
5796
uses: actions/configure-pages@main
97+
5898
- name: Upload artifact
5999
uses: actions/upload-pages-artifact@main
60100
with:
61101
path: 'build/sphinx'
102+
62103
- name: Deploy to GitHub Pages
63104
id: deployment
64105
uses: actions/deploy-pages@main

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ JSQLParserBenchmark.parseSQLStatements 5.1 avgt 15 86.592 ± 5.781 m
8989

9090
| RDBMS | Statements |
9191
|-----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
92-
| Oracle<br>MS SQL Server and Sybase<br>Postgres<br>MySQL and MariaDB<br>DB2<br>H2 and HSQLDB and Derby<br>SQLite | `SELECT`<br>`INSERT`, `UPDATE`, `UPSERT`, `MERGE`<br>`DELETE`, `TRUNCATE TABLE`<br>`CREATE ...`, `ALTER ....`, `DROP ...`<br>`WITH ...` |
92+
| BigQuery<br>Snowflake<br>DuckDB<br>Redshift<br>Oracle<br>MS SQL Server and Sybase<br>Postgres<br>MySQL and MariaDB<br>DB2<br>H2 and HSQLDB and Derby<br>SQLite | `SELECT`<br>`INSERT`, `UPDATE`, `UPSERT`, `MERGE`<br>`DELETE`, `TRUNCATE TABLE`<br>`CREATE ...`, `ALTER ....`, `DROP ...`<br>`WITH ...` |
93+
| PostgreSQL Row Level Security | `CREATE POLICY`<br>`ALTER TABLE ... ENABLE/DISABLE/FORCE/NO FORCE ROW LEVEL SECURITY` |
9394
| Salesforce SOQL | `INCLUDES`, `EXCLUDES` |
9495
| Piped SQL (also known as FROM SQL) | |
9596

build.gradle

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask
22
import com.nwalsh.gradle.saxon.SaxonXsltTask
33

4+
import java.time.Instant
5+
46
buildscript {
57
dependencies {
68
classpath group: 'net.sf.saxon', name: 'Saxon-HE', version: 'latest.release'
@@ -72,6 +74,60 @@ version = getVersion( !System.getenv("RELEASE") )
7274
group = 'com.github.jsqlparser'
7375
description = 'JSQLParser library'
7476

77+
tasks.register('generateBuildInfo') {
78+
outputs.dir layout.buildDirectory.file("resources/main")
79+
doLast {
80+
def outputDir = new File( layout.buildDirectory.file("generated/sources/buildinfo/java/main").get().asFile, "net/sf/jsqlparser")
81+
outputDir.mkdirs()
82+
83+
def gitVersionStr = providers.exec {
84+
commandLine "git", "--no-pager", "-C", project.projectDir, "describe", "--tags", "--always", "--dirty=-SNAPSHOT"
85+
}.standardOutput.asText.get().trim()
86+
87+
def gitCommitStr = providers.exec {
88+
commandLine "git", "--no-pager", "-C", project.projectDir, "rev-parse", "--short", "HEAD"
89+
}.standardOutput.asText.get().trim()
90+
91+
def buildTime = Instant.now().toString()
92+
93+
def content = """\
94+
|package ai.starlake.jsqltranspiler;
95+
|
96+
|public final class BuildInfo {
97+
| public static final String NAME = "${project.name}";
98+
| public static final String VERSION = "${gitVersionStr}";
99+
| public static final String GIT_COMMIT = "${gitCommitStr ?: 'unknown'}";
100+
| public static final String BUILD_TIME = "${buildTime}";
101+
|}
102+
""".stripMargin()
103+
104+
new File(outputDir, "BuildInfo.java").text = content
105+
}
106+
}
107+
108+
// Make sure the file is included in the compiled sources
109+
sourceSets {
110+
main {
111+
java {
112+
srcDir layout.buildDirectory.file("generated/sources/buildinfo/java/main").get().asFile
113+
}
114+
}
115+
}
116+
117+
tasks.withType(JavaCompile).configureEach {
118+
mustRunAfter("generateBuildInfo")
119+
}
120+
121+
tasks.withType(Pmd).configureEach {
122+
mustRunAfter("generateBuildInfo")
123+
}
124+
125+
tasks.withType(Checkstyle).configureEach {
126+
exclude '**/module-info.java', '**/package-info.java'
127+
128+
mustRunAfter("generateBuildInfo")
129+
}
130+
75131
repositories {
76132
gradlePluginPortal()
77133
mavenCentral()
@@ -179,6 +235,8 @@ jar {
179235
"Automatic-Module-Name": "net.sf.jsqlparser"
180236
)
181237
}
238+
239+
dependsOn(generateBuildInfo)
182240
}
183241

184242
tasks.register('xmldoc', Javadoc) {

pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,14 @@
285285
<goal>jjtree-javacc</goal>
286286
</goals>
287287
<configuration>
288+
<grammarEncoding>UTF-8</grammarEncoding>
289+
<isStatic>false</isStatic>
290+
<debugParser>false</debugParser>
291+
<debugLookAhead>false</debugLookAhead>
288292
<codeGenerator>java</codeGenerator>
293+
294+
<!-- <unicodeInput>true</unicodeInput> -->
295+
<!-- <javaUnicodeEscape>true</javaUnicodeEscape> -->
289296
</configuration>
290297
</execution>
291298
</executions>
@@ -680,6 +687,7 @@
680687

681688
<properties>
682689
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
690+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
683691
<pmdVersion>6.55.0</pmdVersion>
684692
<checkStyleVersion>10.14.0</checkStyleVersion>
685693
</properties>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*-
2+
* #%L
3+
* JSQLParser library
4+
* %%
5+
* Copyright (C) 2004 - 2019 JSQLParser
6+
* %%
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
* #L%
9+
*/
10+
package net.sf.jsqlparser.expression;
11+
12+
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
13+
14+
import java.util.Objects;
15+
16+
public class DateUnitExpression extends ASTNodeAccessImpl implements Expression {
17+
18+
private final DateUnit type;
19+
20+
public DateUnitExpression(DateUnit type) {
21+
this.type = Objects.requireNonNull(type);
22+
}
23+
24+
public DateUnitExpression(String DateUnitStr) {
25+
this.type = Objects.requireNonNull(DateUnit.from(DateUnitStr));
26+
}
27+
28+
public DateUnit getType() {
29+
return type;
30+
}
31+
32+
33+
@Override
34+
public <T, S> T accept(ExpressionVisitor<T> expressionVisitor, S context) {
35+
return expressionVisitor.visit(this, context);
36+
}
37+
38+
@Override
39+
public String toString() {
40+
return type.toString();
41+
}
42+
43+
public enum DateUnit {
44+
CENTURY, DECADE, YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND, MICROSECOND, NANOSECOND;
45+
46+
public static DateUnit from(String UnitStr) {
47+
return Enum.valueOf(DateUnit.class, UnitStr.toUpperCase());
48+
}
49+
}
50+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,4 +779,6 @@ default void visit(Inverse inverse) {
779779
<S> T visit(CosineSimilarity cosineSimilarity, S context);
780780

781781
<S> T visit(FromQuery fromQuery, S context);
782+
783+
<S> T visit(DateUnitExpression dateUnitExpression, S context);
782784
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,4 +840,9 @@ public <S> T visit(FromQuery fromQuery, S context) {
840840
return null;
841841
}
842842

843+
@Override
844+
public <S> T visit(DateUnitExpression dateUnitExpression, S context) {
845+
return null;
846+
}
847+
843848
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*-
2+
* #%L
3+
* JSQLParser library
4+
* %%
5+
* Copyright (C) 2004 - 2025 JSQLParser
6+
* %%
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
* #L%
9+
*/
110
package net.sf.jsqlparser.expression;
211

312
/**

src/main/java/net/sf/jsqlparser/schema/Sequence.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public Sequence addParameters(Collection<? extends Parameter> parameters) {
158158
* The available parameters to a sequence
159159
*/
160160
public enum ParameterType {
161-
INCREMENT_BY, START_WITH, RESTART_WITH, MAXVALUE, NOMAXVALUE, MINVALUE, NOMINVALUE, CYCLE, NOCYCLE, CACHE, NOCACHE, ORDER, NOORDER, KEEP, NOKEEP, SESSION, GLOBAL;
161+
INCREMENT_BY, INCREMENT, START_WITH, START, RESTART_WITH, MAXVALUE, NOMAXVALUE, MINVALUE, NOMINVALUE, CYCLE, NOCYCLE, CACHE, NOCACHE, ORDER, NOORDER, KEEP, NOKEEP, SESSION, GLOBAL;
162162

163163
public static ParameterType from(String type) {
164164
return Enum.valueOf(ParameterType.class, type.toUpperCase());
@@ -189,8 +189,12 @@ public String formatParameter() {
189189
switch (option) {
190190
case INCREMENT_BY:
191191
return prefix("INCREMENT BY");
192+
case INCREMENT:
193+
return prefix("INCREMENT");
192194
case START_WITH:
193195
return prefix("START WITH");
196+
case START:
197+
return prefix("START");
194198
case RESTART_WITH:
195199
if (value != null) {
196200
return prefix("RESTART WITH");

src/main/java/net/sf/jsqlparser/statement/StatementVisitor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import net.sf.jsqlparser.statement.analyze.Analyze;
1818
import net.sf.jsqlparser.statement.comment.Comment;
1919
import net.sf.jsqlparser.statement.create.index.CreateIndex;
20+
import net.sf.jsqlparser.statement.create.policy.CreatePolicy;
2021
import net.sf.jsqlparser.statement.create.schema.CreateSchema;
2122
import net.sf.jsqlparser.statement.create.sequence.CreateSequence;
2223
import net.sf.jsqlparser.statement.create.synonym.CreateSynonym;
@@ -351,4 +352,10 @@ default void visit(LockStatement lock) {
351352
this.visit(lock, null);
352353
}
353354

355+
<S> T visit(CreatePolicy createPolicy, S context);
356+
357+
default void visit(CreatePolicy createPolicy) {
358+
this.visit(createPolicy, null);
359+
}
360+
354361
}

0 commit comments

Comments
 (0)