Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 8ce4a30

Browse files
Merge pull request #261 from Trivadis/feature/issues-260-support-sqlcl-23.3
Feature/issues 260 support sqlcl 23.3
2 parents 521a068 + 65d47b8 commit 8ce4a30

8 files changed

Lines changed: 75 additions & 65 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
## Introduction
44

5-
This repository provides formatter settings for the [coding style rules](https://trivadis.github.io/plsql-and-sql-coding-guidelines/v4.0/3-coding-style/coding-style/#rules) of the Trivadis PL/SQL & SQL Coding Guidelines.
5+
This repository provides formatter settings for the [coding style rules](https://trivadis.github.io/plsql-and-sql-coding-guidelines/v4.3/3-coding-style/coding-style/#rules) of the Trivadis PL/SQL & SQL Coding Guidelines.
66

77
Settings are primarily provided for
88

9-
- [Oracle SQLcl, Version 23.1.0](https://www.oracle.com/tools/downloads/sqlcl-downloads.html)
10-
- [Oracle SQL Developer, Version 23.1.0](https://www.oracle.com/tools/downloads/sqldev-downloads.html)
9+
- [Oracle SQLcl, Version 23.3.0](https://www.oracle.com/tools/downloads/sqlcl-downloads.html)
10+
- [Oracle SQL Developer, Version 23.1.0](https://www.oracle.com/tools/downloads/sqldev-downloads.html) with patched `dbtools-common.jar`
1111

1212
These settings have been defined and tested with the product versions mentioned above. They might not work in other versions.
1313

settings/sql_developer/trivadis_custom_format.arbori

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
include "std.arbori"
1818

1919
/**
20-
* Lightweight Formatter for SQL Developer and SQLcl, version 23.1.1-SNAPSHOT
20+
* Lightweight Formatter for SQL Developer and SQLcl, version 23.3.0-SNAPSHOT
2121
* The idea is to keep the code formatted "as is" and apply chosen formatting rules only.
2222
*
2323
* The Arbori program is processed from top to bottom.
@@ -1679,9 +1679,9 @@ a8_accessible_by:
16791679
a8_merge:
16801680
[node) 'MERGE' & [node^) merge
16811681
| [node) 'INTO' & [node^) merge
1682-
| [node-1) 'INTO' & ![node+1) 'USING' & [node^) merge
1683-
| [node-2) 'INTO' & ![node+1) 'USING' & [node^) merge
1684-
| [node) 'USING' & [node^) merge
1682+
| [node-1) 'INTO' & ![node+1) 'USING' & [node^) merge___2
1683+
| [node-2) 'INTO' & ![node+1) 'USING' & [node^) merge___2
1684+
| [node) 'USING' & [node^) merge___2
16851685
| [node) 'WHEN' & ([node^) merge_update_clause | [node^) merge_insert_clause)
16861686
| [node) 'NOT' & [node^) merge_insert_clause
16871687
| [node) 'MATCHED' & ([node^) merge_update_clause | [node^) merge_insert_clause)
@@ -2532,7 +2532,7 @@ a16_delete:
25322532
a16_merge:
25332533
[parent) merge
25342534
& (
2535-
[node) 'USING'
2535+
[node) merge___2
25362536
| [node) 'ON'
25372537
| [node) merge_update_clause
25382538
| [node) merge_insert_clause
@@ -3106,7 +3106,7 @@ r2_increment_left_margin_by_keyword_outside_update_delete_merge:
31063106

31073107
-- use merge keyword for right alignment (5 chars)
31083108
r2_increment_left_margin_by_keyword_outside_node_for_merge:
3109-
[node) merge___2 & [keyword) 'USING' & [node^) merge & keyword+1 = node
3109+
[keyword) 'USING' & [node^) merge___2 & keyword+1 = node
31103110
| [node) condition & [keyword) 'ON' & [node^) merge & keyword+2 = node
31113111
| [node) ')' & [keyword) 'ON' & [node^) merge & keyword+3 = node
31123112
-> {
@@ -3456,15 +3456,22 @@ r7_delete:
34563456
r7_merge:
34573457
[parent) merge
34583458
& (
3459-
[keyword) 'USING'
3460-
| [keyword) 'ON'
3459+
[keyword) 'ON'
34613460
| [keyword) 'WHEN'
34623461
| [keyword) 'LOG'
34633462
| [keyword) 'REJECT'
34643463
)
34653464
& parent < keyword
34663465
;
34673466

3467+
r7_merge_using:
3468+
[parent) merge___2
3469+
& (
3470+
[keyword) 'USING'
3471+
)
3472+
& parent < keyword
3473+
;
3474+
34683475
r7_merge_update_clause:
34693476
[grandparent) merge_update_clause
34703477
& ([parent) 'UPDATE' | [parent) 'DELETE')
@@ -3495,6 +3502,7 @@ r7_right_align_keywords:
34953502
| r7_update
34963503
| r7_delete
34973504
| r7_merge
3505+
| r7_merge_using
34983506
| r7_merge_update_clause
34993507
| r7_merge_insert_clause
35003508
-> {

sqlcl/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ We recommend you download, clone, or fork this repository when you plan to use [
2828
However, [`format.js`](format.js) also works as a standalone script. Here's the usage:
2929

3030
```
31-
Trivadis PL/SQL & SQL Formatter (format.js), version 23.1.0
31+
Trivadis PL/SQL & SQL Formatter (format.js), version 23.3.0
3232
3333
usage: script format.js <rootPath> [options]
3434

sqlcl/format.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var javaSqlEarley = Java.type("oracle.dbtools.parser.plsql.SqlEarley");
5151
var javaProgram = Java.type("oracle.dbtools.arbori.Program");
5252

5353
var getVersion = function() {
54-
return "23.1.1-SNAPSHOT";
54+
return "23.3.1-SNAPSHOT";
5555
}
5656

5757
var getFiles = function (rootPath, extensions, ignoreMatcher) {

standalone/README.md

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The parameters are the same as for the [SQLcl command `tvdformat`](../sqlcl/READ
3131

3232
A native image is a platform specific executable. It does not require a JDK at runtime. A native image uses less resources and is faster. The following images can be produced with a GraalVM JDK 17:
3333

34-
OS | amd64 (Intel))? | aarch64 (ARM)? |
34+
OS | amd64 (Intel)? | aarch64 (ARM)? |
3535
------- | :-------------: | :------------: |
3636
macOS | yes | yes |
3737
Linux | yes | yes |
@@ -56,44 +56,46 @@ The reason is that the underlying parser uses AWT/Swing components (for whatever
5656
AWT/Swing components are supported on AMD/Linux platforms only by GraalVM.
5757
As a result this build process will produce a non-working native image on most platforms.
5858

59-
You will see the following stacktrace similar to the following when running the resulting native image:
59+
You will see the following stacktrace similar to the following when running the resulting native image
60+
(based on SQLcl 23.3.0 on macOS 14.1.2 with an M-series chip):
6061

6162
```
62-
at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:120)
63-
at java.base@17.0.6/java.lang.ClassLoader.loadLibrary(ClassLoader.java:50)
64-
at java.base@17.0.6/java.lang.Runtime.loadLibrary0(Runtime.java:818)
65-
at java.base@17.0.6/java.lang.System.loadLibrary(System.java:1989)
66-
at java.desktop@17.0.6/java.awt.Toolkit$2.run(Toolkit.java:1388)
67-
at java.desktop@17.0.6/java.awt.Toolkit$2.run(Toolkit.java:1386)
68-
at java.base@17.0.6/java.security.AccessController.executePrivileged(AccessController.java:168)
69-
at java.base@17.0.6/java.security.AccessController.doPrivileged(AccessController.java:318)
70-
at java.desktop@17.0.6/java.awt.Toolkit.loadLibraries(Toolkit.java:1385)
71-
at java.desktop@17.0.6/java.awt.Toolkit.initStatic(Toolkit.java:1423)
72-
at java.desktop@17.0.6/java.awt.Toolkit.<clinit>(Toolkit.java:1397)
73-
at java.desktop@17.0.6/java.awt.Component.<clinit>(Component.java:624)
74-
at java.base@17.0.6/java.lang.Class.ensureInitialized(DynamicHub.java:528)
75-
at java.base@17.0.6/java.lang.Class.ensureInitialized(DynamicHub.java:528)
76-
at java.base@17.0.6/java.lang.Class.ensureInitialized(DynamicHub.java:528)
77-
at java.base@17.0.6/java.lang.Class.ensureInitialized(DynamicHub.java:528)
78-
at java.base@17.0.6/java.lang.Class.ensureInitialized(DynamicHub.java:528)
63+
Exception in thread "main" javax.script.ScriptException: java.lang.Exception: java.lang.UnsatisfiedLinkError: no awt in java.library.path
64+
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:136)
65+
at java.base@17.0.9/java.lang.ClassLoader.loadLibrary(ClassLoader.java:50)
66+
at java.base@17.0.9/java.lang.Runtime.loadLibrary0(Runtime.java:818)
67+
at java.base@17.0.9/java.lang.System.loadLibrary(System.java:1989)
68+
at java.desktop@17.0.9/java.awt.Toolkit$2.run(Toolkit.java:1388)
69+
at java.desktop@17.0.9/java.awt.Toolkit$2.run(Toolkit.java:1386)
70+
at java.base@17.0.9/java.security.AccessController.executePrivileged(AccessController.java:171)
71+
at java.base@17.0.9/java.security.AccessController.doPrivileged(AccessController.java:318)
72+
at java.desktop@17.0.9/java.awt.Toolkit.loadLibraries(Toolkit.java:1385)
73+
at java.desktop@17.0.9/java.awt.Toolkit.initStatic(Toolkit.java:1423)
74+
at java.desktop@17.0.9/java.awt.Toolkit.<clinit>(Toolkit.java:1397)
75+
at java.desktop@17.0.9/java.awt.Component.<clinit>(Component.java:624)
76+
at java.base@17.0.9/java.lang.Class.ensureInitialized(DynamicHub.java:579)
77+
at java.base@17.0.9/java.lang.Class.ensureInitialized(DynamicHub.java:579)
78+
at java.base@17.0.9/java.lang.Class.ensureInitialized(DynamicHub.java:579)
79+
at java.base@17.0.9/java.lang.Class.ensureInitialized(DynamicHub.java:579)
80+
at java.base@17.0.9/java.lang.Class.ensureInitialized(DynamicHub.java:579)
7981
at oracle.dbtools.parser.Visual.<init>(Visual.java:404)
8082
at oracle.dbtools.parser.Grammar.parseGrammarFile(Grammar.java:172)
8183
at oracle.dbtools.parser.Grammar.parseGrammarFile(Grammar.java:152)
82-
at oracle.dbtools.arbori.Program.getRules(Program.java:277)
83-
at oracle.dbtools.arbori.Program.getArboriParser(Program.java:187)
84-
at oracle.dbtools.arbori.Program.compile(Program.java:330)
85-
at oracle.dbtools.arbori.Program.compile(Program.java:319)
86-
at oracle.dbtools.arbori.Program.compile(Program.java:316)
87-
at oracle.dbtools.app.XML2Table.<init>(XML2Table.java:70)
88-
at oracle.dbtools.app.Persist2XML.<init>(Persist2XML.java:48)
89-
at oracle.dbtools.app.Persist2XML.read(Persist2XML.java:95)
90-
at <js>.configure(<eval>:104)
91-
at <js>.getConfiguredFormatter(<eval>:161)
92-
at <js>.run(<eval>:727)
84+
at oracle.dbtools.arbori.Program.getRules(Program.java:285)
85+
at oracle.dbtools.arbori.Program.getArboriParser(Program.java:194)
86+
at oracle.dbtools.arbori.Program.compile(Program.java:338)
87+
at oracle.dbtools.arbori.Program.compile(Program.java:327)
88+
at oracle.dbtools.arbori.SqlProgram.<init>(SqlProgram.java:32)
89+
at oracle.dbtools.app.Format$3.<init>(Format.java:343)
90+
at oracle.dbtools.app.Format.format(Format.java:343)
91+
at <js>.formatInSandbox(<eval>:168)
92+
at <js>.formatFile(<eval>:670)
93+
at <js>.formatFiles(<eval>:683)
94+
at <js>.run(<eval>:737)
9395
at <js>.:program(<eval>:803)
94-
at org.graalvm.sdk/org.graalvm.polyglot.Context.eval(Context.java:399)
95-
at org.graalvm.js.scriptengine/com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:478)
96-
at org.graalvm.js.scriptengine/com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:420)
96+
at org.graalvm.sdk/org.graalvm.polyglot.Context.eval(Context.java:403)
97+
at org.graalvm.js.scriptengine/com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:485)
98+
at org.graalvm.js.scriptengine/com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:427)
9799
at com.trivadis.plsql.formatter.TvdFormat.run(TvdFormat.java:36)
98100
at com.trivadis.plsql.formatter.TvdFormat.main(TvdFormat.java:49)
99101
```
@@ -105,10 +107,10 @@ See also [macOS: no awt in java.library.path](https://github.com/oracle/graal/is
105107

106108
## How to Build
107109

108-
1. [Download](https://www.oracle.com/tools/downloads/sqlcl-downloads.html) and install SQLcl 23.1.0
109-
2. [Download](https://github.com/graalvm/graalvm-ce-builds/releases) and install the GraalVM JDK 17 22.3.1
110+
1. [Download](https://www.oracle.com/tools/downloads/sqlcl-downloads.html) and install SQLcl 23.3.0
111+
2. [Download](https://github.com/graalvm/graalvm-ce-builds/releases/tag/jdk-17.0.9) and install the GraalVM JDK 17.0.9
110112
3. Go to the `bin` directory of the GraalVM JDK and run `./gu install js native-image visualvm`. For native image on Windows you need to [download](https://visualstudio.microsoft.com/downloads/) Visual Studio Community 2022 and install the C++ compiler. Use `x64 Native Tools Command Prompt for VS 2022` to get a terminal window with the correct environment.
111-
4. [Download](https://maven.apache.org/download.cgi) and install Apache Maven 3.9.1
113+
4. [Download](https://maven.apache.org/download.cgi) and install Apache Maven 3.9.6
112114
5. [Download](https://git-scm.com/downloads) and install a git command line client
113115
6. Clone the plsql-formatter-settings repository. The repository uses symbolic links. On Windows you have to use `git clone -c core.symlinks=true https://github.com/Trivadis/plsql-formatter-settings.git` as Administrator to make it work. See also [Symbolic Links in Windows](https://github.com/git-for-windows/git/wiki/Symbolic-Links) for more information.
114116
7. Open a terminal window in the plsql-formatter-settings root folder and type

standalone/install_sqlcl_libs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if ! test -f "${SQLCL_LIBDIR}/dbtools-common.jar"; then
1515
fi
1616

1717
# define common Maven properties
18-
SQLCL_VERSION="23.1.0"
18+
SQLCL_VERSION="23.3.0"
1919

2020
# install JAR files in local Maven repository, these libs are not available in public Maven repositories
2121
mvn install:install-file -Dfile=$SQLCL_LIBDIR/dbtools-common.jar -DgeneratePom=true \

standalone/pom.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
<!-- The Basics -->
77
<groupId>com.trivadis.plsql.formatter</groupId>
88
<artifactId>tvdformat</artifactId>
9-
<version>23.1.1-SNAPSHOT</version>
9+
<version>23.3.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1313
<jdk.version>11</jdk.version>
1414
<jdk.test.version>17</jdk.test.version>
15-
<sqlcl.version>23.1.0</sqlcl.version>
16-
<graalvm.version>22.3.1</graalvm.version>
17-
<native.maven.plugin.version>0.9.21</native.maven.plugin.version>
15+
<sqlcl.version>23.3.0</sqlcl.version>
16+
<graalvm.version>22.3.4</graalvm.version>
17+
<native.maven.plugin.version>0.9.28</native.maven.plugin.version>
1818
<reflections.version>0.10.2</reflections.version>
19-
<slf4j.version>2.0.7</slf4j.version>
19+
<slf4j.version>2.0.9</slf4j.version>
2020
<javassist.version>3.29.2-GA</javassist.version>
2121
<skip.native>true</skip.native>
2222
<disable.logging>true</disable.logging>
@@ -26,20 +26,20 @@
2626
<dependency>
2727
<groupId>org.graalvm.js</groupId>
2828
<artifactId>js</artifactId>
29-
<version>${graalvm.version}</version>
29+
<version>23.0.2</version>
3030
<scope>compile</scope>
3131
</dependency>
3232
<dependency>
3333
<groupId>org.graalvm.js</groupId>
3434
<artifactId>js-scriptengine</artifactId>
35-
<version>${graalvm.version}</version>
35+
<version>23.1.1</version>
3636
<scope>compile</scope>
3737
</dependency>
3838
<!-- SQLcl dependencies available in public Maven repositories -->
3939
<dependency>
4040
<groupId>com.google.guava</groupId>
4141
<artifactId>guava</artifactId>
42-
<version>31.1-jre</version>
42+
<version>32.1.3-jre</version>
4343
<scope>test</scope>
4444
</dependency>
4545
<!-- SQLcl dependencies not available in public Maven repositories -->
@@ -82,7 +82,7 @@
8282
<dependency>
8383
<groupId>org.junit.jupiter</groupId>
8484
<artifactId>junit-jupiter</artifactId>
85-
<version>5.9.2</version>
85+
<version>5.10.1</version>
8686
<scope>test</scope>
8787
</dependency>
8888
<dependency>

standalone/src/test/java/com/trivadis/plsql/formatter/sqlcl/tests/AbstractFormatTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void process_dir(final RunType runType) {
2222
for r in /*(*/ select x.* from x join y on y.a = x.a)
2323
^^^
2424
25-
Expected: expr#,function,constraint,name,name_wo_function_ca... skipped.
25+
Expected: expr#,function,literal,factor,boolean_primary,func... skipped.
2626
""".replace("#TEMP_DIR#", getTempDir());
2727
var actual = run(runType, getTempDir(), "mext=");
2828
assertEquals(expected, actual);
@@ -552,7 +552,7 @@ public void process_config_dir_array(final RunType runType) throws IOException {
552552
for r in /*(*/ select x.* from x join y on y.a = x.a)
553553
^^^
554554
555-
Expected: expr#,function,constraint,name,name_wo_function_ca... skipped.
555+
Expected: expr#,function,literal,factor,boolean_primary,func... skipped.
556556
""".replace("#TEMP_DIR#", getTempDir());
557557
var configFileContent = """
558558
[
@@ -611,7 +611,7 @@ public void process_dir_all_errors(final RunType runType) {
611611
for r in /*(*/ select x.* from x join y on y.a = x.a)
612612
^^^
613613
614-
Expected: expr#,function,constraint,name,name_wo_function_ca... skipped... #3... done... done.
614+
Expected: expr#,function,literal,factor,boolean_primary,func... skipped... #3... done... done.
615615
Formatting file 2 of 4: #TEMP_DIR#/package_body.pkb... done.
616616
Formatting file 3 of 4: #TEMP_DIR#/query.sql... done.
617617
Formatting file 4 of 4: #TEMP_DIR#/syntax_error.sql... Syntax Error at line 6, column 12
@@ -620,7 +620,7 @@ public void process_dir_all_errors(final RunType runType) {
620620
for r in /*(*/ select x.* from x join y on y.a = x.a)
621621
^^^
622622
623-
Expected: expr#,function,constraint,name,name_wo_function_ca... skipped.
623+
Expected: expr#,function,literal,factor,boolean_primary,func... skipped.
624624
""".replace("#TEMP_DIR#", getTempDir());
625625
var actual = run(runType, getTempDir());
626626
assertEquals(expected, actual);
@@ -636,7 +636,7 @@ public void process_dir_mext_errors(final RunType runType) {
636636
for r in /*(*/ select x.* from x join y on y.a = x.a)
637637
^^^
638638
639-
Expected: expr#,function,constraint,name,name_wo_function_ca... skipped... #3... done... done.
639+
Expected: expr#,function,literal,factor,boolean_primary,func... skipped... #3... done... done.
640640
Formatting file 2 of 4: #TEMP_DIR#/package_body.pkb... done.
641641
Formatting file 3 of 4: #TEMP_DIR#/query.sql... done.
642642
Formatting file 4 of 4: #TEMP_DIR#/syntax_error.sql... skipped.
@@ -658,7 +658,7 @@ public void process_dir_ext_errors(final RunType runType) {
658658
for r in /*(*/ select x.* from x join y on y.a = x.a)
659659
^^^
660660
661-
Expected: expr#,function,constraint,name,name_wo_function_ca... skipped.
661+
Expected: expr#,function,literal,factor,boolean_primary,func... skipped.
662662
""".replace("#TEMP_DIR#", getTempDir());
663663
var actual = run(runType, getTempDir(), "serr=ext");
664664
assertEquals(expected, actual);

0 commit comments

Comments
 (0)