Skip to content

Commit 7143de8

Browse files
HCK-13023: if no key in composite PK/UK then default to empty array (#163)
1 parent 70524ce commit 7143de8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

forward_engineering/alterScript/alterScriptHelpers/entityHelpers/primaryKeyHelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const wasCompositePkChangedInTransitionFromCompositeToRegular = collection => {
7676
* @type {AlterCollectionRoleCompModPKDto[]}
7777
* */
7878
const oldPrimaryKeys = pkDto.old || [];
79-
const idsOfColumns = oldPrimaryKeys.flatMap(pk => pk.compositePrimaryKey.map(dto => dto.keyId));
79+
const idsOfColumns = oldPrimaryKeys.flatMap(pk => pk.compositePrimaryKey?.map(dto => dto.keyId) || []);
8080
if (idsOfColumns.length !== amountOfColumnsInRegularPk) {
8181
// We return false, because it wouldn't count as transition between regular PK and composite PK
8282
// if composite PK did not constraint exactly 1 column
@@ -120,7 +120,7 @@ const wasCompositePkChangedInTransitionFromRegularToComposite = collection => {
120120
* @type {AlterCollectionRoleCompModPKDto[]}
121121
* */
122122
const newPrimaryKeys = pkDto.new || [];
123-
const idsOfColumns = newPrimaryKeys.flatMap(pk => pk.compositePrimaryKey.map(dto => dto.keyId));
123+
const idsOfColumns = newPrimaryKeys.flatMap(pk => pk.compositePrimaryKey?.map(dto => dto.keyId) || []);
124124
if (idsOfColumns.length !== amountOfColumnsInRegularPk) {
125125
// We return false, because it wouldn't count as transition between regular PK and composite PK
126126
// if composite PK does not constraint exactly 1 column

forward_engineering/alterScript/alterScriptHelpers/entityHelpers/uniqueKeyHelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const wasCompositeUniqueKeyChangedInTransitionFromCompositeToRegular = collectio
7979
* @type {AlterCollectionRoleCompModUniqueKeyDto[]}
8080
* */
8181
const oldUniqueKeys = uniqueDto.old || [];
82-
const idsOfColumns = oldUniqueKeys.flatMap(unique => unique.compositeUniqueKey.map(dto => dto.keyId));
82+
const idsOfColumns = oldUniqueKeys.flatMap(unique => unique.compositeUniqueKey?.map(dto => dto.keyId) || []);
8383
if (idsOfColumns.length !== amountOfColumnsInRegularUniqueKey) {
8484
// We return false, because it wouldn't count as transition between regular UniqueKey and composite UniqueKey
8585
// if composite UniqueKey did not constraint exactly 1 column
@@ -124,7 +124,7 @@ const wasCompositeUniqueKeyChangedInTransitionFromRegularToComposite = collectio
124124
* @type {AlterCollectionRoleCompModUniqueKeyDto[]}
125125
* */
126126
const newUniqueKeys = uniqueDto.new || [];
127-
const idsOfColumns = newUniqueKeys.flatMap(unique => unique.compositeUniqueKey.map(dto => dto.keyId));
127+
const idsOfColumns = newUniqueKeys.flatMap(unique => unique.compositeUniqueKey?.map(dto => dto.keyId) || []);
128128
if (idsOfColumns.length !== amountOfColumnsInRegularUniqueKey) {
129129
// We return false, because it wouldn't count as transition between regular UniqueKey and composite UniqueKey
130130
// if composite UniqueKey does not constraint exactly 1 column

0 commit comments

Comments
 (0)