mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
fix csv result when column names have spaces #59
This commit is contained in:
@@ -13,7 +13,7 @@ export default {
|
|||||||
result.columns = source.meta.fields.map(col => col.trim())
|
result.columns = source.meta.fields.map(col => col.trim())
|
||||||
result.values = source.data.map(row => {
|
result.values = source.data.map(row => {
|
||||||
const resultRow = []
|
const resultRow = []
|
||||||
result.columns.forEach(col => { resultRow.push(row[col]) })
|
source.meta.fields.forEach(col => { resultRow.push(row[col]) })
|
||||||
return resultRow
|
return resultRow
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ describe('csv.js', () => {
|
|||||||
it('getResult with fields', () => {
|
it('getResult with fields', () => {
|
||||||
const source = {
|
const source = {
|
||||||
data: [
|
data: [
|
||||||
{ id: 1, name: 'foo' },
|
{ id: 1, 'name ': 'foo' },
|
||||||
{ id: 2, name: 'bar' }
|
{ id: 2, 'name ': 'bar' }
|
||||||
],
|
],
|
||||||
meta: {
|
meta: {
|
||||||
fields: ['id', 'name ']
|
fields: ['id', 'name ']
|
||||||
|
|||||||
Reference in New Issue
Block a user