Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
Fix JSON vis in Table
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Mar 23, 2021
1 parent e4f85b1 commit cc004b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
loadScript('https://cdnjs.cloudflare.com/ajax/libs/sql-formatter/4.0.2/sql-formatter.min.js')

class SqlVisualization extends Visualization {
static inputType = 'Any' // 'Standard.Database.Data.Table.Table | Standard.Database.Data.Column.Column'
static inputType = 'Any' // 'Standard.Database.Data.Table.Table | Standard.Database.Data.Column.Column' // TODO change this once sum types are properly supported
static label = 'SQL Query'

constructor(api) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,13 @@ class TableVisualization extends Visualization {

function genGenericTable(data, level) {
let result = ''
data.forEach((point, ix) => {
result += '<tr><th>' + ix + '</th>' + toTableCell(point, level) + '</tr>'
})
if (Array.isArray(data)) {
data.forEach((point, ix) => {
result += '<tr><th>' + ix + '</th>' + toTableCell(point, level) + '</tr>'
})
} else {
result += '<tr>' + toTableCell(data, level) + '</tr>'
}
return tableOf(result, level)
}

Expand Down

0 comments on commit cc004b3

Please sign in to comment.