Skip to content

Commit

Permalink
Upgrade CLC
Browse files Browse the repository at this point in the history
Use Java8 as jdbc driver requires Java8 to support SCRAM.
Major version bump to 2.0.0
Add missing resource file for test
  • Loading branch information
zapov committed Sep 3, 2022
1 parent f3650ff commit 4cf2dd6
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 16 deletions.
12 changes: 6 additions & 6 deletions CommandLineClient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.dslplatform</groupId>
<artifactId>dsl-clc</artifactId>
<packaging>jar</packaging>
<version>1.9.10</version>
<version>2.0.0</version>
<name>DSL Platform - Compiler Command-Line Client</name>
<url>https://github.com/ngs-doo/dsl-compiler-client</url>
<description>Command line client for interaction with DSL Platform compiler (https://dsl-platform.com)</description>
Expand All @@ -13,17 +13,17 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5.jre6</version>
<version>42.5.0</version>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>1.17.1</version>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -60,8 +60,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import com.dslplatform.compiler.client.Context;
import com.dslplatform.compiler.client.ExitException;
import org.postgresql.util.Base64;

import java.io.ByteArrayOutputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.Base64;
import java.util.LinkedHashMap;
import java.util.Map;

Expand Down Expand Up @@ -35,7 +36,8 @@ public String currentHash() {
}
MessageDigest md5 = MessageDigest.getInstance("MD5");
byte[] hash = md5.digest(stream.toByteArray());
return Base64.encodeBytes(hash);
byte[] encoded = Base64.getEncoder().encode(hash);
return new String(encoded, 0, encoded.length, StandardCharsets.UTF_8);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
public class TestUtils {
public static String fileContent(String filename) {
try {
InputStream inputStream = TestUtils.class.getResourceAsStream(filename);
BufferedInputStream bis = new BufferedInputStream(inputStream);
ByteArrayOutputStream buf = new ByteArrayOutputStream();
int result = bis.read();
while (result != -1) {
buf.write((byte) result);
result = bis.read();
try(InputStream inputStream = TestUtils.class.getResourceAsStream(filename);
BufferedInputStream bis = new BufferedInputStream(inputStream);
ByteArrayOutputStream buf = new ByteArrayOutputStream()) {
int result = bis.read();
while (result != -1) {
buf.write((byte) result);
result = bis.read();
}
return buf.toString("UTF-8");
}
return buf.toString("UTF-8");
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*MIGRATION_DESCRIPTION
MIGRATION_DESCRIPTION*/

DO $$ BEGIN
IF EXISTS(SELECT * FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = '-DSL-' AND c.relname = 'database_setting') THEN
IF EXISTS(SELECT * FROM "-DSL-".Database_Setting WHERE Key ILIKE 'mode' AND NOT Value ILIKE 'unsafe') THEN
RAISE EXCEPTION 'Database upgrade is forbidden. Change database mode to allow upgrade';
END IF;
END IF;
END $$ LANGUAGE plpgsql;

DO $$ BEGIN
END $$ LANGUAGE plpgsql;

SELECT "-DSL-".Persist_Concepts('"test/alias.dsl"=>"type ExternalID = String(64);
", "test/quotes.dsl"=>"module spec
{
aggregate Fact(date, account) {
Date date;
Long account { index; }
specification ByAccounts ''it => ids.Contains(it.accountID)'' {
Long[] ids;
}
persistence { specification delete enabled; }
}
", "test/escapes.dsl"=>"module escapes
{
aggregate Cheque(number, bank) {
String number;
String bank { default ''it => \"Test me\"''; }
Bool cancelled; // Only an \"Test me\" can be used
}
}
"', '\x','2.1.0.14620','ABCD');
SELECT pg_notify('migration', 'new');

0 comments on commit 4cf2dd6

Please sign in to comment.