Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ const TABLE_TYPE = {

const INLINE_COMMENT = '--';

const PERSENT = '__PERCENT__';

module.exports = {
ERROR_MESSAGE,
TABLE_TYPE,
INLINE_COMMENT,
PERSENT,
};
5 changes: 4 additions & 1 deletion reverse_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ const getDbCollectionsNames = async (connectionInfo, appLogger, callback, app) =
});

try {
const connection = await connectionHelper.connect({ connectionInfo, logger });
const dbVersion = await instanceHelper.getDbVersion({ connection });
logger.info('Db version: ' + dbVersion);

logger.info('Get table and schema names');
logger.info(connectionInfo);

const connection = await connectionHelper.connect({ connectionInfo, logger });
const tableNames = await instanceHelper.getDatabasesWithTableNames({
connection,
tableType: TABLE_TYPE.table,
Expand Down
2 changes: 1 addition & 1 deletion shared/Db2Client/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

mvn clean compile assembly:single
mvn clean package
36 changes: 23 additions & 13 deletions shared/Db2Client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,29 @@

<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.db2.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.7.1</version>
<configuration>
<archive>
<manifest>
<mainClass>org.db2.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
8 changes: 2 additions & 6 deletions shared/Db2Client/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ For compiling client Using Maven plugin execute:
Lifecycle methods:

- `mvn clean`
- `mvn compile`

Plugins:

- `mvn assembly:single`
- `mvn package`

### Built artifacts

The built JAR file you can find following by `./target/Db2Client-1.0-jar-with-dependencies.jar`
The built JAR file you can find following by `./target/Db2Client-1.0-jar-with-dependencies.jar`, **NOT `Db2Client-1.0.jar`!!!**
For use in Db2 plugin rename this JAR file to `Db2Client.jar` and put to `shared/addons/Db2Client.jar`
3 changes: 2 additions & 1 deletion shared/Db2Client/src/main/java/org/db2/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static void main(String[] args) {
JSONObject errorObj = new JSONObject();
errorObj.put("message", e.getMessage());
errorObj.put("stack", e.getStackTrace());
errorObj.put("query", query);

result.put("error", errorObj);
} finally {
Expand All @@ -46,7 +47,7 @@ public static void main(String[] args) {
}

private static String cleanStringValue(String value) {
return value.replace("<\\$>", "\"");
return value.replace("__PERCENT__", "%");
}

private static String findArgument(String[] args, Argument argument) {
Expand Down
Binary file modified shared/addons/Db2Client.jar
Binary file not shown.
22 changes: 13 additions & 9 deletions shared/helpers/queryHelper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { TABLE_TYPE } = require('../../constants/constants');
const { TABLE_TYPE, PERSENT } = require('../../constants/constants');

/**
* @param {{ query: string }}
Expand All @@ -11,14 +11,18 @@ const cleanUpQuery = ({ query = '' }) => query.replaceAll(/\s+/g, ' ');
* @returns {string}
*/
const getNonSystemSchemaWhereClause = ({ query, schemaNameKeyword }) => {
const whereClause = `
WHERE ${schemaNameKeyword} NOT LIKE 'SYS%'
AND ${schemaNameKeyword} NOT LIKE '%SYSCAT%'
AND ${schemaNameKeyword} NOT LIKE '%SYSIBM%'
AND ${schemaNameKeyword} NOT LIKE '%SYSSTAT%'
AND ${schemaNameKeyword} NOT LIKE '%SYSTOOLS%'
AND ${schemaNameKeyword} NOT LIKE '%NULLID%'
AND ${schemaNameKeyword} NOT LIKE '%SQLJ%';`;
// On Windows (cmd.exe), environment variables can be referenced using syntax like %PATH%.
// When a command contains such patterns, cmd.exe automatically replaces them with the corresponding environment variable values.
// To prevent this automatic substitution, a placeholder string (PERSENT) is used here instead,
// which will later be replaced with the % symbol inside the Db2Client Java client.
const whereClause = `
WHERE ${schemaNameKeyword} NOT LIKE 'SYS${PERSENT}'
AND ${schemaNameKeyword} NOT LIKE '${PERSENT}SYSCAT${PERSENT}'
AND ${schemaNameKeyword} NOT LIKE '${PERSENT}SYSIBM${PERSENT}'
AND ${schemaNameKeyword} NOT LIKE '${PERSENT}SYSSTAT${PERSENT}'
AND ${schemaNameKeyword} NOT LIKE '${PERSENT}SYSTOOLS${PERSENT}'
AND ${schemaNameKeyword} NOT LIKE '${PERSENT}NULLID${PERSENT}'
AND ${schemaNameKeyword} NOT LIKE '${PERSENT}SQLJ${PERSENT}';`;

const clause = query.includes('WHERE') ? whereClause.replace('WHERE', 'AND') : whereClause;

Expand Down