mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
fix cast-csv read action for csv field's revisions (#16438)
Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
This commit is contained in:
@@ -61,6 +61,19 @@ describe('Integration Tests', () => {
|
||||
expect(result).toMatchObject([]);
|
||||
});
|
||||
|
||||
it('Returns array values as is', async () => {
|
||||
const result = await service.transformers['cast-csv']({
|
||||
value: ['test', 'directus'],
|
||||
action: 'read',
|
||||
payload: {},
|
||||
accountability: { role: null },
|
||||
specials: [],
|
||||
helpers,
|
||||
});
|
||||
|
||||
expect(result).toEqual(['test', 'directus']);
|
||||
});
|
||||
|
||||
it('Splits the CSV string', async () => {
|
||||
const result = await service.transformers['cast-csv']({
|
||||
value: 'test,directus',
|
||||
|
||||
@@ -121,7 +121,9 @@ export class PayloadService {
|
||||
async 'cast-csv'({ action, value }) {
|
||||
if (Array.isArray(value) === false && typeof value !== 'string') return;
|
||||
|
||||
if (action === 'read' && Array.isArray(value) === false) {
|
||||
if (action === 'read') {
|
||||
if (Array.isArray(value)) return value;
|
||||
|
||||
if (value === '') return [];
|
||||
|
||||
return value.split(',');
|
||||
|
||||
Reference in New Issue
Block a user