mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-01 01:07:04 +02:00
add object test cases
This commit is contained in:
parent
87ecaad9ca
commit
272bba1889
|
|
@ -3568,6 +3568,9 @@ describe('dataTable', () => {
|
|||
[{ key: 'value' }, 0, 'eq', true],
|
||||
[true, 1, 'eq', true],
|
||||
[false, 0, 'eq', true],
|
||||
[{ a: 3 }, { a: 3 }, 'eq', true],
|
||||
[{ a: 3 }, { a: 4 }, 'neq', true],
|
||||
[{}, {}, 'eq', true],
|
||||
])(
|
||||
'inserts json with input %p, filter %p, operator %p, expectPresent %p',
|
||||
async (input, filter, operator, expectPresent) => {
|
||||
|
|
@ -3655,5 +3658,42 @@ describe('dataTable', () => {
|
|||
]);
|
||||
}
|
||||
});
|
||||
it('handles object comparison', async () => {
|
||||
// ARRANGE
|
||||
const { id: dataStoreId } = await dataTableService.createDataTable(project1.id, {
|
||||
name: 'dataStore',
|
||||
columns: [{ name: 'c1', type: 'json' }],
|
||||
});
|
||||
|
||||
// ACT
|
||||
const rows = [{ c1: { a: { b: 4 } } }];
|
||||
await dataTableService.insertRows(dataStoreId, project1.id, rows, 'id');
|
||||
|
||||
// ASSERT
|
||||
|
||||
{
|
||||
const { data } = await dataTableService.getManyRowsAndCount(dataStoreId, project1.id, {
|
||||
filter: {
|
||||
type: 'and',
|
||||
filters: [
|
||||
{
|
||||
columnName: 'c1',
|
||||
condition: 'eq',
|
||||
value: { a: { b: 4 } },
|
||||
path: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
expect(data).toEqual([
|
||||
{
|
||||
c1: { a: { b: 4 } },
|
||||
id: 1,
|
||||
createdAt: expect.any(Date),
|
||||
updatedAt: expect.any(Date),
|
||||
},
|
||||
]);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -490,7 +490,8 @@ export class DataTableService {
|
|||
const fieldType = columnTypeToFieldType[columnType];
|
||||
if (!fieldType) return cell;
|
||||
|
||||
if (!validateJsonInput && columnType === 'json') return cell;
|
||||
if (!validateJsonInput && columnType === 'json')
|
||||
return typeof cell === 'object' ? JSON.stringify(cell) : cell;
|
||||
|
||||
const validationResult = validateFieldType(key, cell, fieldType, {
|
||||
strict: false, // Allow type coercion (e.g., string numbers to numbers)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user