Skip to content

Commit

Permalink
HCK-9128: Handle indexes without indxKey
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightlngale committed Dec 15, 2024
1 parent 8534455 commit 3c6f304
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
3 changes: 1 addition & 2 deletions forward_engineering/configs/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ module.exports = {
'CREATE${unique}${clustered}${columnstore} INDEX ${name}\n' +
'\tON ${table}${keys}${include}${expression}${relational_index_option}${terminator}\n',

fullTextIndex:
'CREATE FULLTEXT INDEX ON ${table} (\n\t${keys}\n)\nKEY INDEX ${indexName}\n${catalog}${options}${terminator}\n',
fullTextIndex: 'CREATE FULLTEXT INDEX ON ${table}\nKEY INDEX ${indexName}\n${catalog}${options}${terminator}\n',

spatialIndex: 'CREATE SPATIAL INDEX ${name} ON ${table} (${column})${using}\n${options}${terminator}\n',

Expand Down
44 changes: 23 additions & 21 deletions forward_engineering/helpers/indexHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = app => {
};

const createIndex = (terminator, tableName, index, isParentActivated = true) => {
const isInvalidColumnStore = index.type !== 'columnstore' || (index.type === 'columnstore' && index.clustered);
const isInvalidColumnStore = index.type !== 'columnstore' || (index.type === 'columnstore' && !index.clustered);

if ((_.isEmpty(index.keys) && isInvalidColumnStore) || !index.name) {
return '';
Expand Down Expand Up @@ -136,33 +136,35 @@ module.exports = app => {
};

const createFullTextIndex = (terminator, tableName, index, isParentActivated) => {
if (_.isEmpty(index.keys) || !index.keyIndex) {
if (!index.keyIndex) {
return '';
}
const catalog = getFulltextCatalog(index);
const options = getFullTextOptions(index);

return assignTemplates(templates.fullTextIndex, {
table: getTableName(tableName, index.schemaName),
keys: index.keys
.map(key => {
let column = `[${key.name}]`;
const keys = index.keys
.map(key => {
let column = `[${key.name}]`;

if (key.columnType) {
column += ` TYPE COLUMN ${key.columnType}`;
}
if (key.columnType) {
column += ` TYPE COLUMN ${key.columnType}`;
}

if (key.languageTerm) {
column += ` LANGUAGE ${key.languageTerm}`;
}
if (key.languageTerm) {
column += ` LANGUAGE ${key.languageTerm}`;
}

if (key.statisticalSemantics) {
column += ` STATISTICAL_SEMANTICS`;
}
if (key.statisticalSemantics) {
column += ` STATISTICAL_SEMANTICS`;
}

return isParentActivated ? commentIfDeactivated(column, key) : column;
})
.join(',\n\t'),
return isParentActivated ? commentIfDeactivated(column, key) : column;
})
.join(',\n\t');

return assignTemplates(templates.fullTextIndex, {
table: getTableName(tableName, index.schemaName),
keys: keys ? ` (\n\t${keys}\n)\n` : '',
indexName: index.keyIndex,
catalog: catalog ? `ON ${catalog}\n` : '',
options: options ? `WITH (\n\t${options}\n)` : '',
Expand Down Expand Up @@ -230,9 +232,9 @@ module.exports = app => {
return createSpatialIndex(terminator, tableName, index);
} else if (index.type === 'fulltext') {
return createFullTextIndex(terminator, tableName, index);
} else {
return createIndex(terminator, tableName, index, isParentActivated);
}

return createIndex(terminator, tableName, index, isParentActivated);
};

const createMemoryOptimizedClusteredIndex = indexData => {
Expand Down
17 changes: 10 additions & 7 deletions properties_pane/entity_level/entityLevelConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,13 @@ making sure that you maintain a proper JSON format.
"value": "Columnstore"
},
{
"key": "clusteredIndx",
"value": false
"type": "not",
"values": [
{
"key": "clusteredIndx",
"value": true
}
]
}
]
},
Expand Down Expand Up @@ -1388,10 +1393,6 @@ making sure that you maintain a proper JSON format.
"dependency": {
"key": "indxType",
"value": "FullText"
},
"validation": {
"required": true,
"minLength": 1
}
},
{
Expand Down Expand Up @@ -1423,11 +1424,13 @@ making sure that you maintain a proper JSON format.
{
"propertyName": "Key index",
"propertyKeyword": "indxFullTextKeyIndex",
"requiredProperty": true,
"propertyType": "text",
"dependency": {
"key": "indxType",
"value": "FullText"
},
"validation": {
"required": true
}
},
{
Expand Down

0 comments on commit 3c6f304

Please sign in to comment.