@@ -86,30 +86,27 @@ export class IBMiController {
86
86
const results = await query . execute ( 1000 ) ;
87
87
88
88
const table = results . data ;
89
+ const columnNames = results . metadata . columns . map ( c => c . name ) ;
90
+
89
91
if ( table === undefined && results . success && ! results . has_results ) {
90
92
items . push ( vscode . NotebookCellOutputItem . text ( `Statement executed successfully. ${ results . update_count ? `${ results . update_count } rows affected.` : `` } ` , `text/markdown` ) ) ;
91
93
break ;
92
94
}
93
95
94
96
if ( table . length > 0 ) {
95
-
96
- const keys = Object . keys ( table [ 0 ] ) ;
97
-
98
97
// Add `-` for blanks.
99
98
table . forEach ( row => {
100
- keys . forEach ( key => {
99
+ columnNames . forEach ( key => {
101
100
//@ts -ignore
102
101
if ( ! row [ key ] ) { row [ key ] = `-` ; }
103
102
} ) ;
104
103
} ) ;
105
104
106
- const columns = results . metadata . columns . map ( c => c . label ) ;
107
-
108
105
let fallbackToTable = true ;
109
106
110
107
if ( chartDetail . type ) {
111
108
if ( chartJsTypes . includes ( chartDetail . type as ChartJsType ) ) {
112
- const possibleChart = generateChart ( execution . executionOrder , chartDetail , columns , table , generateChartHTMLCell ) ;
109
+ const possibleChart = generateChart ( execution . executionOrder , chartDetail , columnNames , table , generateChartHTMLCell ) ;
113
110
if ( possibleChart ) {
114
111
items . push ( vscode . NotebookCellOutputItem . text ( possibleChart , `text/html` ) ) ;
115
112
fallbackToTable = false ;
@@ -118,7 +115,7 @@ export class IBMiController {
118
115
}
119
116
120
117
if ( fallbackToTable ) {
121
- items . push ( vscode . NotebookCellOutputItem . text ( mdTable ( table , columns ) , `text/markdown` ) ) ;
118
+ items . push ( vscode . NotebookCellOutputItem . text ( mdTable ( table , columnNames ) , `text/markdown` ) ) ;
122
119
}
123
120
} else {
124
121
items . push ( vscode . NotebookCellOutputItem . stderr ( `No rows returned from statement.` ) ) ;
0 commit comments