fix(core): Export boolean CSV values as true/false for Data Tables (#30007)

This commit is contained in:
Daria 2026-05-11 12:30:00 +03:00 committed by GitHub
parent 515ae7ced4
commit 94d91e13bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View File

@ -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/);
});

View File

@ -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);
}