Commit 482d478a by zhaochengxiang

类主见自动生成索引

parent c43fa49d
......@@ -337,6 +337,39 @@ const ImportAction = (props) => {
})
}
//类主键自动创建索引
let autoEasyDataModelerIndex = {
"name": `i_pk_${newModelerData.name}`,
"indextype": {
"name": "btree",
"displayName": "B-tree",
"supportedDBTypes": [
"Greenplum",
"MySQL"
],
"default": true
},
"indexedAttributeOrders": [
"ASC"
],
"indexedEasyDataModelAttributes": [...newModelerData.easyDataModelerSemiPrimaryKey],
"unique": true
};
let newEasyDataModelerIndices = [];
(newModelerData.easyDataModelerIndices||[]).forEach((easyDataModelerIndex, index) => {
if (easyDataModelerIndex.name!==`i_pk_${modelerDataRef.current?.name}` && easyDataModelerIndex.name!==`i_pk_${newModelerData.name}`) {
newEasyDataModelerIndices.push(easyDataModelerIndex);
}
});
newEasyDataModelerIndices.push(autoEasyDataModelerIndex);
newEasyDataModelerIndices = newEasyDataModelerIndices.filter(item => (item.indexedEasyDataModelAttributes||[]).length > 0);
newModelerData = {...newModelerData, easyDataModelerIndices: newEasyDataModelerIndices};
setModelerData(newModelerData);
modelerDataRef.current = newModelerData;
......@@ -436,12 +469,21 @@ const ImportAction = (props) => {
}
//类主键
let newSemiPrimary = [...(newModelerData.easyDataModelerSemiPrimaryKey||[])];
let newSemiPrimary = [];
(newModelerData.easyDataModelerSemiPrimaryKey||[]).forEach((item, index) => {
const _index = (newModelerData.easyDataModelerDataModelAttributes||[]).findIndex(_item => item.iid === _item.iid);
if (_index !== -1) {
newSemiPrimary.push({...newModelerData.easyDataModelerDataModelAttributes[_index]});
}
})
//索引
let newEasyDataModelerIndices = [...(newModelerData.easyDataModelerIndices||[])];
(newModelerData.easyDataModelerIndices||[]).forEach((easyDataModelerIndex, index) => {
const newIndexedEasyDataModelAttributes = [], newIndexedAttributeOrders = [];
(easyDataModelerIndex.indexedEasyDataModelAttributes||[]).forEach((indexedEasyDataModelAttribute, _index) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment