From 6920d6af34df8e25777c1c5c5a5e2bffaa146e6a Mon Sep 17 00:00:00 2001 From: Yevhenii Moroziuk Date: Mon, 16 Dec 2024 18:36:41 +0200 Subject: [PATCH] HCK-9128: Handle indexes without name in PostgreSQL (#130) * HCK-9128: Handle indexes without indxKey * HCK-9128: Handle indexes without indxKey * HCK-9128: fix config --- .../ddlProvider/ddlHelpers/indexHelper.js | 6 ++++ .../entity_level/entityLevelConfig.json | 32 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/forward_engineering/ddlProvider/ddlHelpers/indexHelper.js b/forward_engineering/ddlProvider/ddlHelpers/indexHelper.js index 4d10ac7..2a585df 100644 --- a/forward_engineering/ddlProvider/ddlHelpers/indexHelper.js +++ b/forward_engineering/ddlProvider/ddlHelpers/indexHelper.js @@ -94,6 +94,12 @@ const getValue = value => { }; const createIndex = (tableName, index, dbData, isParentActivated = true) => { + const isNameEmpty = !index.indxName && index.ifNotExist; + + if (!index.columns.length || isNameEmpty) { + return ''; + } + const isUnique = index.unique && index.index_method === 'btree'; const name = wrapInQuotes(index.indxName); const unique = isUnique ? ' UNIQUE' : ''; diff --git a/properties_pane/entity_level/entityLevelConfig.json b/properties_pane/entity_level/entityLevelConfig.json index 0992a19..2b9abae 100644 --- a/properties_pane/entity_level/entityLevelConfig.json +++ b/properties_pane/entity_level/entityLevelConfig.json @@ -883,7 +883,29 @@ making sure that you maintain a proper JSON format. "propertyName": "Name", "propertyKeyword": "indxName", "propertyTooltip": "Optional, if not specified an automatic name will be assigned. Index name are needed to drop indexes and appear in error messages when a constraint is violated.", - "propertyType": "text" + "propertyType": "text", + "dependency": { + "type": "not", + "values": [ + { + "key": "ifNotExist", + "value": true + } + ] + } + }, + { + "propertyName": "Name", + "propertyKeyword": "indxName", + "propertyTooltip": "", + "propertyType": "text", + "validation": { + "required": true + }, + "dependency": { + "key": "ifNotExist", + "value": true + } }, { "propertyName": "Activated", @@ -1024,6 +1046,10 @@ making sure that you maintain a proper JSON format. "dependency": { "key": "index_method", "value": "btree" + }, + "validation": { + "required": true, + "minLength": 1 } }, { @@ -1068,6 +1094,10 @@ making sure that you maintain a proper JSON format. "value": "brin" } ] + }, + "validation": { + "required": true, + "minLength": 1 } }, {