Skip to content

Commit b8e7da1

Browse files
author
DrMyroslav
committed
HCK-1819 <message>
1 parent 22d85ac commit b8e7da1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

forward_engineering/helpers/columnDefinitionHelper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module.exports = ({ _, wrap, assignTemplates, templates, commentIfDeactivated, w
7979
const decorateDefault = (type, defaultValue) => {
8080
const constantsValues = ['current_timestamp', 'null'];
8181
if ((isString(type) || isDateTime(type)) && !constantsValues.includes(_.toLower(defaultValue))) {
82-
return wrap(defaultValue, '$$', '$$');
82+
return wrapComment(defaultValue);
8383
} else {
8484
return defaultValue;
8585
}

forward_engineering/helpers/general.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ const POSTGRES_RESERVED_WORDS = [
9696
'WITH',
9797
];
9898

99+
const MUST_BE_ESCAPED = /'|\\b|\\f|\\n|\\r|\\t|\\o|\\u|\\x|\\$/g;
100+
99101
module.exports = ({ _, divideIntoActivatedAndDeactivated, commentIfDeactivated }) => {
100102
const getFunctionArguments = functionArguments => {
101103
return _.map(functionArguments, arg => {
@@ -177,7 +179,10 @@ module.exports = ({ _, divideIntoActivatedAndDeactivated, commentIfDeactivated }
177179
);
178180
};
179181

180-
const wrapComment = comment => `$$${comment}$$`;
182+
const prepareComment = (comment = '') =>
183+
comment.replace(MUST_BE_ESCAPED, character => `${'\\'}${character}`);
184+
185+
const wrapComment = comment => `E'${prepareComment(comment)}'`;
181186

182187
return {
183188
getFunctionArguments,

0 commit comments

Comments
 (0)