Skip to content

Commit 4ba734c

Browse files
committed
Merge commit 'refs/pull/2/head' of https://github.com/hackolade/PostgreSQL
2 parents 80169f0 + 744c259 commit 4ba734c

File tree

13 files changed

+133
-33
lines changed

13 files changed

+133
-33
lines changed

adapter/0.1.1.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* Copyright © 2016-2018 by IntegrIT S.A. dba Hackolade. All rights reserved.
3+
*
4+
* The copyright to the computer software herein is the property of IntegrIT S.A.
5+
* The software may be used and/or copied only with the written permission of
6+
* IntegrIT S.A. or in accordance with the terms and conditions stipulated in
7+
* the agreement/contract under which the software has been supplied.
8+
*
9+
* {
10+
* "add": {
11+
* "entity": [<names of new property>],
12+
* "container": [<names of new property>],
13+
* "model": [<names of new property>],
14+
* "view": [<names of new property>],
15+
* "field": {
16+
* "<type>": [<names of new property>]
17+
* }
18+
* },
19+
* "remove": {
20+
* "entity": [<names of new property>],
21+
* "container": [<names of new property>],
22+
* "model": [<names of new property>],
23+
* "view": [<names of new property>],
24+
* "field": {
25+
* "<type>": [<names of new property>]
26+
* }
27+
* },
28+
* "modify": {
29+
* "entity": [
30+
* {
31+
* "from": { <properties that identify record> },
32+
* "to": { <properties that need to be changed> }
33+
* }
34+
* ],
35+
* "container": [],
36+
* "model": [],
37+
* "view": [],
38+
* "field": []
39+
* },
40+
* }
41+
*/
42+
{
43+
"modify": {
44+
"container": [
45+
[
46+
"renamePropertiesInArrayElements",
47+
"UDFs",
48+
{
49+
"functionDefinition": "functionBody"
50+
}
51+
]
52+
]
53+
}
54+
}

forward_engineering/api.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const reApi = require('../reverse_engineering/api');
2-
const { createLogger } = require('../reverse_engineering/helpers/loggerHelper');
2+
const { createLogger, getSystemInfo } = require('../reverse_engineering/helpers/loggerHelper');
33
const applyToInstanceHelper = require('./applyToInstanceHelper');
44

55
module.exports = {
@@ -10,6 +10,7 @@ module.exports = {
1010
},
1111
applyToInstance(connectionInfo, logger, callback, app) {
1212
logger.clear();
13+
logger.log('info', getSystemInfo(connectionInfo.appVersion), 'Apply to instance');
1314
logger.log(
1415
'info',
1516
app.require('lodash').omit(connectionInfo, 'script', 'containerData'),

forward_engineering/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"type": "ddl",
33
"ddlType": "plugin",
44
"namePrefix": "PostgreSQL",
5+
"mode": "pgsql",
56
"level": {
67
"container": true,
78
"entity": true,

forward_engineering/configs/templates.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
module.exports = {
22
createDatabase: 'CREATE DATABASE ${name}${template}${encoding}${locale}${collate}${characterClassification}${tablespace};\n',
33

4-
createSchema: 'CREATE SCHEMA${ifNotExist} ${name};\nSET search_path TO ${name};\n${comment}\n',
4+
createSchema: 'CREATE SCHEMA${ifNotExist} ${name};\nSET search_path TO ${name};\n\n${comment}\n',
55

66
comment: 'COMMENT ON ${object} ${objectName} IS ${comment};\n',
77

88
createTable:
99
'CREATE${temporary} TABLE${ifNotExist} ${name} (\n' +
1010
'${columnDefinitions}${keyConstraints}${checkConstraints}${foreignKeyConstraints}\n' +
11-
')${options};\n${comment}${columnDescriptions}',
11+
')${options};\n\n${comment}${columnDescriptions}',
1212

1313
columnDefinition: '${name} ${type}${collation}${primaryKey}${uniqueKey}${defaultValue}${notNull}',
1414

@@ -26,7 +26,7 @@ module.exports = {
2626
' ON${only} ${tableName}${using}${keys}${options};\n\n',
2727

2828
createView:
29-
'CREATE${orReplace}${temporary} VIEW ${name}${withOptions}\nAS ${selectStatement}${checkOption};\n${comment}\n',
29+
'CREATE${orReplace}${temporary} VIEW ${name}${withOptions}\nAS ${selectStatement}${checkOption};\n\n${comment}\n',
3030

3131
viewSelectStatement: 'SELECT ${keys}\n\tFROM ${tableName}',
3232

@@ -43,8 +43,8 @@ module.exports = {
4343
'\tLANGUAGE ${language}\n' +
4444
'AS $BODY$\n${body}\n$BODY$;\n',
4545

46-
createCompositeType: 'CREATE TYPE ${name} AS (\n\t${columnDefinitions}\n);\n${comment}',
47-
createEnumType: 'CREATE TYPE ${name} AS ENUM (${values});\n${comment}',
48-
createRangeType: 'CREATE TYPE ${name} AS RANGE (\n\tSUBTYPE=${subtype}${options}\n);\n${comment}',
49-
createDomainType: 'CREATE DOMAIN ${name} AS ${underlyingType}${notNull}${collate}${default}${constraints};\n${comment}'
46+
createCompositeType: 'CREATE TYPE ${name} AS (\n\t${columnDefinitions}\n);\n\n${comment}',
47+
createEnumType: 'CREATE TYPE ${name} AS ENUM (${values});\n\n${comment}',
48+
createRangeType: 'CREATE TYPE ${name} AS RANGE (\n\tSUBTYPE=${subtype}${options}\n);\n\n${comment}',
49+
createDomainType: 'CREATE DOMAIN ${name} AS ${underlyingType}${notNull}${collate}${default}${constraints};\n\n${comment}'
5050
};

forward_engineering/ddlProvider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module.exports = (baseProvider, options, app) => {
8282
assignTemplates,
8383
templates,
8484
commentIfDeactivated,
85-
getNamePrefixedWithSchemaName,
85+
wrapInQuotes,
8686
wrapComment,
8787
});
8888

forward_engineering/helpers/columnDefinitionHelper.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module.exports = ({
44
assignTemplates,
55
templates,
66
commentIfDeactivated,
7-
getNamePrefixedWithSchemaName,
87
wrapComment,
8+
wrapInQuotes
99
}) => {
1010
const addLength = (type, length) => {
1111
return `${type}(${length})`;
@@ -60,12 +60,10 @@ module.exports = ({
6060
const isString = type => ['char', 'varchar', 'text', 'bit', 'varbit'].includes(type);
6161
const isDateTime = type => ['date', 'time', 'timestamp', 'interval'].includes(type);
6262

63-
const escapeQuotes = str => _.trim(str).replace(/(\')+/g, "'$1");
64-
6563
const decorateDefault = (type, defaultValue) => {
6664
const constantsValues = ['current_timestamp', 'null'];
6765
if ((isString(type) || isDateTime(type)) && !constantsValues.includes(_.toLower(defaultValue))) {
68-
return wrap(escapeQuotes(defaultValue), "'", "'");
66+
return wrap(defaultValue, "$$", "$$");
6967
} else {
7068
return defaultValue;
7169
}
@@ -77,7 +75,7 @@ module.exports = ({
7775
.map(columnData => {
7876
const comment = assignTemplates(templates.comment, {
7977
object: 'COLUMN',
80-
objectName: getNamePrefixedWithSchemaName(columnData.name, tableName),
78+
objectName: `${tableName}.${wrapInQuotes(columnData.name)}`,
8179
comment: wrapComment(columnData.comment),
8280
});
8381

forward_engineering/helpers/functionHelper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = ({ _, templates, assignTemplates, getFunctionArguments, getName
1010
returnType: udf.functionReturnsSetOf ? `SETOF ${udf.functionReturnType}` : udf.functionReturnType,
1111
language: udf.functionLanguage,
1212
properties: getProperties(udf),
13-
definition: udf.functionDefinition,
13+
definition: udf.functionBody,
1414
});
1515
}).join('\n');
1616
};

forward_engineering/helpers/general.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,7 @@ module.exports = ({ _, divideIntoActivatedAndDeactivated, commentIfDeactivated }
177177
);
178178
};
179179

180-
const wrapComment = comment => {
181-
if (_.includes(comment, "'")) {
182-
return `'${comment.replace("'", "''")}'`;
183-
}
184-
185-
return `'${comment}'`;
186-
};
180+
const wrapComment = comment => `$$${comment}$$`;
187181

188182
return {
189183
getFunctionArguments,

properties_pane/container_level/containerLevelConfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ making sure that you maintain a proper JSON format.
175175
"defaultValue": "IN",
176176
"options": [
177177
"IN",
178+
"OUT",
178179
"INOUT",
179180
"VARIADIC"
180181
]
@@ -226,7 +227,7 @@ making sure that you maintain a proper JSON format.
226227
},
227228
{
228229
"propertyName": "Definition",
229-
"propertyKeyword": "functionDefinition",
230+
"propertyKeyword": "functionBody",
230231
"propertyTooltip": "A string constant defining the function; the meaning depends on the language. It can be an internal function name, the path to an object file, an SQL command, or text in a procedural language.",
231232
"propertyType": "details",
232233
"template": "textarea",
@@ -400,6 +401,7 @@ making sure that you maintain a proper JSON format.
400401
"defaultValue": "IN",
401402
"options": [
402403
"IN",
404+
"OUT",
403405
"INOUT",
404406
"VARIADIC"
405407
]

reverse_engineering/api.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const { createLogger } = require('./helpers/loggerHelper');
3+
const { createLogger, getSystemInfo } = require('./helpers/loggerHelper');
44
const postgresService = require('./helpers/postgresService');
55

66
module.exports = {
@@ -12,8 +12,7 @@ module.exports = {
1212

1313
async testConnection(connectionInfo, logger, callback, app) {
1414
try {
15-
logger.clear();
16-
logger.log('info', connectionInfo, 'connectionInfo', connectionInfo.hiddenKeys);
15+
logInfo('Test connection', connectionInfo, logger);
1716

1817
const postgresLogger = createLogger({
1918
title: 'Test connection instance log',
@@ -35,8 +34,7 @@ module.exports = {
3534

3635
async getDatabases(connectionInfo, logger, cb, app) {
3736
try {
38-
logger.clear();
39-
logger.log('info', connectionInfo, 'connectionInfo', connectionInfo.hiddenKeys);
37+
logInfo('Get databases', connectionInfo, logger);
4038

4139
const postgresLogger = createLogger({
4240
title: 'Get DB names',
@@ -63,8 +61,7 @@ module.exports = {
6361

6462
async getDbCollectionsNames(connectionInfo, logger, callback, app) {
6563
try {
66-
logger.clear();
67-
logger.log('info', connectionInfo, 'connectionInfo', connectionInfo.hiddenKeys);
64+
logInfo('Get DB table names', connectionInfo, logger);
6865

6966
const postgresLogger = createLogger({
7067
title: 'Get DB collections names',
@@ -204,3 +201,9 @@ const prepareError = error => {
204201
error = JSON.parse(error);
205202
return error;
206203
};
204+
205+
const logInfo = (step, connectionInfo, logger) => {
206+
logger.clear();
207+
logger.log('info', getSystemInfo(connectionInfo.appVersion), step);
208+
logger.log('info', connectionInfo, 'connectionInfo', connectionInfo.hiddenKeys);
209+
};

0 commit comments

Comments
 (0)