mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-12 16:10:30 +02:00
fix(core): Export boolean CSV values as true/false for Data Tables (#30007)
This commit is contained in:
parent
515ae7ced4
commit
94d91e13bf
|
|
@ -210,6 +210,12 @@ describe('GET /projects/:projectId/data-tables/:dataTableId/download-csv', () =>
|
|||
flag: true,
|
||||
timestamp: testDate,
|
||||
},
|
||||
{
|
||||
text: 'world',
|
||||
number: 99,
|
||||
flag: false,
|
||||
timestamp: testDate,
|
||||
},
|
||||
],
|
||||
columns,
|
||||
'id',
|
||||
|
|
@ -225,8 +231,10 @@ describe('GET /projects/:projectId/data-tables/:dataTableId/download-csv', () =>
|
|||
expect(lines[0]).toBe('id,text,number,flag,timestamp,createdAt,updatedAt');
|
||||
expect(lines[1]).toContain('hello');
|
||||
expect(lines[1]).toContain('42');
|
||||
// Boolean values vary by database: SQLite use 0/1, PostgreSQL uses true/false
|
||||
expect(lines[1]).toMatch(/,(true|1),/);
|
||||
expect(lines[1]).toContain(',true,');
|
||||
expect(lines[2]).toContain('world');
|
||||
expect(lines[2]).toContain('99');
|
||||
expect(lines[2]).toContain(',false,');
|
||||
// Check for date in ISO format (timezone may vary)
|
||||
expect(lines[1]).toMatch(/2025-01-15T\d{2}:\d{2}:\d{2}\.\d{3}Z/);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -830,6 +830,12 @@ export class DataTableService {
|
|||
}
|
||||
|
||||
if (columnType === 'boolean') {
|
||||
if (value === 1 || value === '1') {
|
||||
return 'true';
|
||||
}
|
||||
if (value === 0 || value === '0') {
|
||||
return 'false';
|
||||
}
|
||||
return String(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user