Skip to content

Commit 2005338

Browse files
committed
fix 198: remove technical columns when describe is cold
1 parent 6076608 commit 2005338

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

addon/data-export.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,11 +1539,11 @@ class Model {
15391539
return {records: [], done: true, totalSize: -1};
15401540
}
15411541
throw err;
1542-
}).then(data => {
1542+
}).then(async data => {
15431543
let total;
15441544
let recs;
15451545
if (vm.isSearchMode()) {
1546-
exportedData.addToTable(data.searchRecords);
1546+
await exportedData.addToTable(data.searchRecords);
15471547
recs = exportedData.records.length;
15481548
total = exportedData.totalSize;
15491549
} else if (vm.isGraphMode()) {
@@ -1561,11 +1561,11 @@ class Model {
15611561
records.push(result);
15621562
});
15631563
}
1564-
exportedData.addToTable(records);
1564+
await exportedData.addToTable(records);
15651565
recs = exportedData.records.length;
15661566
total = exportedData.totalSize;
15671567
} else {
1568-
exportedData.addToTable(data.records);
1568+
await exportedData.addToTable(data.records);
15691569
recs = exportedData.records.length;
15701570
total = exportedData.totalSize;
15711571
if (data.totalSize != -1) {
@@ -1660,8 +1660,8 @@ class Model {
16601660
let vm = this; // eslint-disable-line consistent-this
16611661
let exportedData = new RecordTable(vm);
16621662

1663-
vm.spinFor(sfConn.rest("/services/data/v" + apiVersion + "/query/?explain=" + encodeURIComponent(vm.editor.value)).then(res => {
1664-
exportedData.addToTable(res.plans);
1663+
vm.spinFor(sfConn.rest("/services/data/v" + apiVersion + "/query/?explain=" + encodeURIComponent(vm.editor.value)).then(async res => {
1664+
await exportedData.addToTable(res.plans);
16651665
vm.exportStatus = "";
16661666
vm.performancePoints = [];
16671667
vm.exportedData = exportedData;
@@ -1693,7 +1693,7 @@ function RecordTable(vm) {
16931693
let datetimeFormat = localStorage.getItem("datetimeFormat");
16941694
let decimalFormat = localStorage.getItem("decimalFormat");
16951695
// try to respect the right order of column by matching query column and record column
1696-
function discoverQueryColumns(record, fields) {
1696+
async function discoverQueryColumns(record, fields) {
16971697
let sobjectDescribe = null;
16981698
//TODO we will need parent model of rt maybe
16991699
if (record.attributes && record.attributes.type) {
@@ -1718,7 +1718,10 @@ function RecordTable(vm) {
17181718
if (arr.length > 0) {
17191719
if (arr[0].referenceTo) {
17201720
//only take first referenceTo
1721-
currentSobjectDescribe = vm.describeInfo.describeSobject(vm.queryTooling, arr[0].referenceTo[0]).sobjectDescribe;
1721+
currentSobjectDescribe = await new Promise(resolve =>
1722+
vm.describeInfo.describeSobject(vm.queryTooling, arr[0].referenceTo[0], resolve));
1723+
1724+
//currentSobjectDescribe = vm.describeInfo.describeSobject(vm.queryTooling, arr[0].referenceTo[0]).sobjectDescribe;
17221725
fieldName = fieldName ? fieldName + "." + arr[0].relationshipName : arr[0].relationshipName;
17231726
continue;
17241727
}
@@ -1791,6 +1794,9 @@ function RecordTable(vm) {
17911794
discoverColumns(record[field], column + ".", row);
17921795
continue;
17931796
}
1797+
if (typeof record[field] == "object" && record[field] == null && skipTechnicalColumns) {
1798+
continue;
1799+
}
17941800
let c;
17951801
if (columnIdx.has(column)) {
17961802
c = columnIdx.get(column);
@@ -1871,7 +1877,7 @@ function RecordTable(vm) {
18711877
countOfVisibleRecords: null,
18721878
isTooling: false,
18731879
totalSize: -1,
1874-
addToTable(expRecords) {
1880+
async addToTable(expRecords) {
18751881
rt.records = rt.records.concat(expRecords);
18761882
if (rt.table.length == 0 && expRecords.length > 0) {
18771883
rt.table.push(header);
@@ -1883,7 +1889,7 @@ function RecordTable(vm) {
18831889
row[0] = record;
18841890
rt.table.push(row);
18851891
rt.rowVisibilities.push(isVisible(row, filter));
1886-
discoverQueryColumns(record, vm.columnIndex.fields);
1892+
await discoverQueryColumns(record, vm.columnIndex.fields);
18871893
discoverColumns(record, "", row);
18881894
}
18891895
},

addon/data-load.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function DescribeInfo(spinFor, didUpdate) {
100100
// "loadfailed": Downloading of describe info for the object failed
101101
// "ready": Describe info is available
102102
// - sobjectDescribe: contains a DescribeSObjectResult if the object exists and has been loaded
103-
describeSobject(useToolingApi, sobjectName) {
103+
describeSobject(useToolingApi, sobjectName, onUpdate) {
104104
let apiDescribes = getGlobal(useToolingApi);
105105
if (!apiDescribes.sobjects) {
106106
return {sobjectStatus: apiDescribes.global.globalStatus, sobjectDescribe: null};
@@ -115,10 +115,18 @@ export function DescribeInfo(spinFor, didUpdate) {
115115
sobjectInfo.sobject.sobjectStatus = "ready";
116116
sobjectInfo.sobject.sobjectDescribe = res;
117117
didUpdate();
118+
if (onUpdate) {
119+
onUpdate(sobjectInfo.sobject.sobjectDescribe);
120+
}
118121
}, () => {
119122
sobjectInfo.sobject.sobjectStatus = "loadfailed";
120123
didUpdate();
124+
if (onUpdate){
125+
onUpdate(null);
126+
}
121127
}));
128+
} else if (onUpdate){
129+
onUpdate(sobjectInfo.sobject.sobjectDescribe);
122130
}
123131
return sobjectInfo.sobject;
124132
},

0 commit comments

Comments
 (0)