Skip to content

Commit 5854cff

Browse files
HCK-12935: comments in alter script (#213)
1 parent 785039d commit 5854cff

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

forward_engineering/alterScript/alterScriptHelpers/columnHelpers/commentsHelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ const getUpdatedCommentOnColumnScriptDtos = ({ scriptFormat, collection }) => {
4141
const oldName = jsonSchema.compMod.oldField.name;
4242
const oldComment = collection.role.properties[oldName]?.description;
4343

44-
return newComment && (!oldComment || newComment !== oldComment);
44+
return newComment !== oldComment;
4545
})
4646
.map(([name, jsonSchema]) => {
47-
const wrappedComment = wrapComment(jsonSchema.description);
47+
const wrappedComment = jsonSchema.description ? wrapComment(jsonSchema.description) : 'NULL';
4848
const columnName = prepareNameForScriptFormat(scriptFormat)(name);
4949
const fullColumnName = `${fullTableName}.${columnName}`;
5050

forward_engineering/alterScript/alterScriptHelpers/entityHelpers/commentsHelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ const getUpdatedCommentOnCollectionScriptDto = ({ scriptFormat, collection }) =>
3131
}
3232

3333
const { old: oldComment, new: newComment } = descriptionInfo;
34-
if (!newComment || newComment === oldComment) {
34+
if (newComment === oldComment) {
3535
return undefined;
3636
}
3737

3838
const collectionSchema = getSchemaOfAlterCollection(collection);
3939
const fullTableName = getFullCollectionName(scriptFormat)(collectionSchema);
40-
const comment = wrapComment(newComment);
40+
const comment = newComment ? wrapComment(newComment) : 'NULL';
4141
const script = updateTableComment(fullTableName, comment);
4242

4343
return AlterScriptDto.getInstance([script], true, false);

forward_engineering/alterScript/alterScriptHelpers/viewHelpers/commentsHelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ const updateViewComment = (objectName, comment, isMaterializedView) => {
2525
const getUpdatedCommentScriptDto = ({ scriptFormat, view }) => {
2626
const description = view?.role?.compMod?.description || {};
2727

28-
if (!description.new || description.new === description.old) {
28+
if (description.new === description.old) {
2929
return;
3030
}
3131

3232
const schemaName = view.compMod?.keyspaceName;
3333
const fullViewName = getNamePrefixedWithSchemaNameForScriptFormat(scriptFormat)(view.code || view.name, schemaName);
34-
const wrappedComment = wrapComment(description.new);
34+
const wrappedComment = description.new ? wrapComment(description.new) : 'NULL';
3535
const script = updateViewComment(fullViewName, wrappedComment, view.materialized);
3636

3737
return AlterScriptDto.getInstance([script], true, false);

0 commit comments

Comments
 (0)