Skip to content

Commit e8eae62

Browse files
committed
refactor: narrow lookahead cleanup to grammar changes
Signed-off-by: 付典 <fudianchn@gmail.com>
2 parents 1c729e4 + 2927bad commit e8eae62

156 files changed

Lines changed: 16977 additions & 4327 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,6 @@ jobs:
4545
- name: Check for grammar ambiguities
4646
run: ./gradlew checkGrammarAmbiguity --no-daemon
4747

48-
- name: Restore and save lookahead facts
49-
uses: actions/cache@v5
50-
with:
51-
path: build/lookahead-cache/
52-
key: lookahead-facts-${{ runner.os }}-${{ hashFiles('src/test/java/net/sf/jsqlparser/parser/audit/**', 'build.gradle', 'gradle/wrapper/gradle-wrapper.properties') }}-${{ github.sha }}
53-
restore-keys: |
54-
lookahead-facts-${{ runner.os }}-${{ hashFiles('src/test/java/net/sf/jsqlparser/parser/audit/**', 'build.gradle', 'gradle/wrapper/gradle-wrapper.properties') }}-
55-
56-
- name: Report changed lookahead contexts
57-
env:
58-
LOOKAHEAD_BASE: ${{ github.event.pull_request.base.sha || github.event.before || github.sha }}
59-
run: ./gradlew lookaheadAudit --no-daemon -PlookaheadBase="$LOOKAHEAD_BASE"
60-
61-
- name: Upload lookahead review report
62-
if: always()
63-
uses: actions/upload-artifact@v5
64-
with:
65-
name: lookahead-review
66-
path: build/reports/lookahead/
67-
retention-days: 7
68-
if-no-files-found: ignore
69-
7048
- name: Upload grammar warning report
7149
if: failure()
7250
uses: actions/upload-artifact@v5
@@ -238,4 +216,4 @@ jobs:
238216

239217
- name: Deploy to GitHub Pages
240218
id: deployment
241-
uses: actions/deploy-pages@v5
219+
uses: actions/deploy-pages@v5

‎README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,17 @@ and missing syntax gets added on demand — [open an issue](https://github.com/J
142142
| **ksqlDB windows** | JOIN `WITHIN`, window `GRACE PERIOD`, and `EMIT CHANGES`/`FINAL` |
143143
| **ClickHouse column selection** | `COLUMNS('regexp')` select items with chained `APPLY`, `EXCEPT`, and `REPLACE` transformers |
144144
| **DML** | `INSERT` · `UPDATE` · `UPSERT` · `MERGE` · `DELETE` · `TRUNCATE TABLE` |
145+
| **Oracle RETURNING** | Named output binds (`INTO :name`), JDBC output parameters (`INTO ?`), and `BULK COLLECT INTO` |
145146
| **DDL** | `CREATE …` · `ALTER …` · `DROP …` |
147+
| **Oracle vector types** | `VECTOR(*, *)` · `VECTOR(*, FLOAT32)` · `VECTOR(3, *)`, including dense and sparse storage formats |
146148
| **PostgreSQL ownership** | `DROP OWNED` · `REASSIGN OWNED` |
147149
| **MySQL table maintenance** | `ANALYZE` · `CHECK` · `OPTIMIZE` · `REPAIR TABLE` |
150+
| **MySQL account management** | `CREATE`/`ALTER`/`RENAME USER` · `CREATE ROLE` · `SET ROLE` · `SET DEFAULT ROLE` · `SET PASSWORD` |
151+
| **Tablespaces** | MySQL and PostgreSQL `CREATE TABLESPACE` · `ALTER TABLESPACE` |
148152
| **PostgreSQL RLS** | `CREATE POLICY` · `ALTER TABLE … ENABLE`/`DISABLE`/`FORCE`/`NO FORCE ROW LEVEL SECURITY` |
153+
| **Routine changes** | `ALTER FUNCTION` · `ALTER PROCEDURE` · `ALTER ROUTINE` · PostgreSQL `ALTER TRIGGER` |
154+
| **MySQL metadata statements** | `SHOW [FULL] COLUMNS`/`FIELDS` · `SHOW TABLE STATUS` · `SHOW CREATE TABLE`/`VIEW`/`PROCEDURE`/`FUNCTION`/`TRIGGER`/`EVENT`/`DATABASE`/`USER` |
155+
| **PostgreSQL administration** | `CREATE`/`ALTER EVENT TRIGGER` · `REINDEX` · `SECURITY LABEL` |
149156
| **Informix constraints** | `ALTER TABLE … ADD CONSTRAINT` with trailing constraint names for primary, unique, foreign and check constraints; enable with `parser.withDialect(Dialect.INFORMIX)` |
150157
| **Salesforce SOQL** | `INCLUDES` · `EXCLUDES` |
151158

‎build.gradle‎

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ tasks.register('xmldoc', Javadoc) {
265265
}
266266

267267
test {
268-
environment 'EXPORT_TEST_TO_FILE', 'False'
268+
environment = [ 'EXPORT_TEST_TO_FILE': 'False' ]
269269
useJUnitPlatform()
270270

271271
// set heap size for the test JVM(s)
@@ -846,24 +846,3 @@ tasks.register('checkGrammarAmbiguity') {
846846
tasks.named('check') {
847847
dependsOn('checkGrammarAmbiguity')
848848
}
849-
850-
// Report base/working-tree context changes without making historical lookahead debt a new gate.
851-
// The analyzer lives in test sources: no audit classes or dependencies enter the library JAR.
852-
tasks.register('lookaheadAudit', JavaExec) {
853-
group = 'verification'
854-
description = 'Reports changed lookahead decisions and stale evidence against a Git base.'
855-
dependsOn(testClasses)
856-
classpath = sourceSets.test.runtimeClasspath
857-
mainClass = 'net.sf.jsqlparser.parser.audit.LookaheadAudit'
858-
javaLauncher = javaToolchains.launcherFor(java.toolchain)
859-
jvmArgs '-Xss4m', '-Xmx1g', '-Dfile.encoding=UTF-8'
860-
workingDir = projectDir
861-
doFirst {
862-
args = [projectDir.absolutePath,
863-
providers.gradleProperty('lookaheadBase').getOrElse('HEAD'),
864-
layout.buildDirectory.dir('reports/lookahead').get().asFile.absolutePath,
865-
file('config/lookahead-evidence.tsv').absolutePath,
866-
providers.gradleProperty('lookaheadFailOnFindings').getOrElse('false'),
867-
providers.gradleProperty('lookaheadFull').getOrElse('false')]
868-
}
869-
}

‎config/lookahead-evidence.tsv‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎src/main/java/net/sf/jsqlparser/expression/DateUnitExpression.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ public class DateUnitExpression extends ASTNodeAccessImpl implements Expression
1818

1919
private final DateUnit type;
2020

21+
private final String text;
22+
2123
public DateUnitExpression(DateUnit type) {
2224
this.type = Objects.requireNonNull(type);
25+
this.text = type.toString();
2326
}
2427

2528
public DateUnitExpression(String DateUnitStr) {
2629
this.type = Objects.requireNonNull(DateUnit.from(DateUnitStr));
30+
this.text = DateUnitStr;
2731
}
2832

2933
public DateUnit getType() {
@@ -38,7 +42,7 @@ public <T, S> T accept(ExpressionVisitor<T> expressionVisitor, S context) {
3842

3943
@Override
4044
public String toString() {
41-
return type.toString();
45+
return text;
4246
}
4347

4448
public enum DateUnit {

‎src/main/java/net/sf/jsqlparser/expression/JsonFunction.java‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -436,12 +436,11 @@ public StringBuilder appendObject(StringBuilder builder) {
436436
@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
437437
public StringBuilder appendObject(StringBuilder builder,
438438
Consumer<Expression> expressionPrinter) {
439-
builder.append("JSON_OBJECT( ");
439+
builder.append("JSON_OBJECT(");
440+
int start = builder.length();
440441
int i = 0;
441442
for (JsonKeyValuePair keyValuePair : keyValuePairs) {
442-
if (i > 0) {
443-
builder.append(", ");
444-
}
443+
builder.append(i > 0 ? ", " : " ");
445444
keyValuePair.appendTo(builder, expressionPrinter);
446445
i++;
447446
}
@@ -453,7 +452,8 @@ public StringBuilder appendObject(StringBuilder builder,
453452
appendUniqueKeys(builder);
454453
appendReturningClause(builder, true);
455454

456-
builder.append(" ) ");
455+
// An empty argument list renders as JSON_OBJECT()
456+
builder.append(builder.length() > start ? " )" : ")");
457457

458458
return builder;
459459
}
@@ -495,20 +495,18 @@ public StringBuilder appendArray(StringBuilder builder) {
495495
@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
496496
public StringBuilder appendArray(StringBuilder builder,
497497
Consumer<Expression> expressionPrinter) {
498-
builder.append("JSON_ARRAY( ");
498+
builder.append("JSON_ARRAY(");
499499
int i = 0;
500500

501501
for (JsonFunctionExpression expr : expressions) {
502-
if (i > 0) {
503-
builder.append(", ");
504-
}
502+
builder.append(i > 0 ? ", " : " ");
505503
expr.appendTo(builder, expressionPrinter);
506504
i++;
507505
}
508506

509507
appendOnNullType(builder);
510508
appendReturningClause(builder, true);
511-
builder.append(") ");
509+
builder.append(')');
512510

513511
return builder;
514512
}

0 commit comments

Comments
 (0)