Skip to content

Commit

Permalink
HCK-8490: Escape quotes in comment in DDL: Db2 (#38)
Browse files Browse the repository at this point in the history
<!--do not remove this marker, its needed to replace info when ticket
title is updated -->
<!--jira-description-action-hidden-marker-start-->

<table>
<td>
<a href="https://hackolade.atlassian.net/browse/HCK-8490"
title="HCK-8490" target="_blank"><img alt="Emergency"
src="https://hackolade.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10564?size=medium"
/>HCK-8490</a> SQLServer+Synapse - FE - Wrong DDL if single attribute in
composite key + quotes in comment
  </td></table>
  <br />
 

<!--jira-description-action-hidden-marker-end-->
  • Loading branch information
Nightlngale authored Oct 28, 2024
1 parent e789efb commit 00dcd5e
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ const OBJECT_TYPE = {
index: 'INDEX',
};

/**
* @param {string} description
* @returns {string}
*/
const escapeSpecialCharacters = description => description.replace(/'/g, "''");

/**
* @param {{ objectName: string, objectType: OBJECT_TYPE, description?: string }}
* @returns {string}
Expand All @@ -23,7 +29,11 @@ const getCommentStatement = ({ objectName, objectType, description }) => {

return assignTemplates({
template: templates.comment,
templateData: { objectType, objectName: trim(objectName), comment: wrapInSingleQuotes({ name: description }) },
templateData: {
objectType,
objectName: trim(objectName),
comment: wrapInSingleQuotes({ name: escapeSpecialCharacters(description) }),
},
});
};

Expand Down

0 comments on commit 00dcd5e

Please sign in to comment.