Skip to content

Commit

Permalink
HCK-6860: fix dependency for primary key structure
Browse files Browse the repository at this point in the history
  • Loading branch information
serhii-filonenko committed Jun 20, 2024
1 parent ac87bac commit a176ce4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
* @typedef {import('../../../shared/types').UUID} UUID
*/
const RandExp = require('randexp');
const { isEmpty } = require('lodash');
const { PK_SEGMENT_TYPE } = require('../../../shared/constants');

/**
* @param {{ collection: object, jsonData: object }}
* @returns {string}
*/
const getPrimaryKeySampleByStructure = ({ collection, jsonData }) => {
const keyField = Object.values(collection.properties || {}).find(field => field.primaryKeyStructure);
const keyField = Object.values(collection.properties || {}).find(
field => field.primaryKey && !isEmpty(field.primaryKeyStructure),
);
const primaryKeyStructure = keyField?.primaryKeyStructure;

if (!Array.isArray(primaryKeyStructure)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const getInsertScriptForCollection = ({ jsonData, collection }) => {
}

const keyPropertyName = Object.keys(collection?.properties ?? {}).find(propertyName =>
Boolean(collection?.properties?.[propertyName]['<key>']),
Boolean(collection?.properties?.[propertyName]?.primaryKey),
);

const insertionPath = getKeySpaceReference(collection);
Expand Down
2 changes: 1 addition & 1 deletion properties_pane/field_level/fieldLevelConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ making sure that you maintain a proper JSON format.
}
],
"dependency": {
"key": "containerLevelKey",
"key": "primaryKey",
"value": true
}
},
Expand Down

0 comments on commit a176ce4

Please sign in to comment.