|
|
@ -867,6 +867,98 @@ function tableTest() { |
|
|
|
throw new Error('Wrong sort'); |
|
|
|
throw new Error('Wrong sort'); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('Find one sorted filtered table with nested fields data list with a rollup column in customer table', async function () { |
|
|
|
|
|
|
|
const rollupColumn = await createRollupColumn(context, { |
|
|
|
|
|
|
|
project: sakilaProject, |
|
|
|
|
|
|
|
title: 'Number of rentals', |
|
|
|
|
|
|
|
rollupFunction: 'count', |
|
|
|
|
|
|
|
table: customerTable, |
|
|
|
|
|
|
|
relatedTableName: 'rental', |
|
|
|
|
|
|
|
relatedTableColumnTitle: 'RentalDate', |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const paymentListColumn = (await customerTable.getColumns()).find( |
|
|
|
|
|
|
|
(c) => c.title === 'Payment List' |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const activeColumn = (await customerTable.getColumns()).find( |
|
|
|
|
|
|
|
(c) => c.title === 'Active' |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const nestedFields = { |
|
|
|
|
|
|
|
'Rental List': ['RentalDate', 'ReturnDate'], |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const nestedFilter = [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fk_column_id: rollupColumn?.id, |
|
|
|
|
|
|
|
status: 'create', |
|
|
|
|
|
|
|
logical_op: 'and', |
|
|
|
|
|
|
|
comparison_op: 'gte', |
|
|
|
|
|
|
|
value: '25', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
is_group: true, |
|
|
|
|
|
|
|
status: 'create', |
|
|
|
|
|
|
|
logical_op: 'or', |
|
|
|
|
|
|
|
children: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fk_column_id: rollupColumn?.id, |
|
|
|
|
|
|
|
status: 'create', |
|
|
|
|
|
|
|
logical_op: 'and', |
|
|
|
|
|
|
|
comparison_op: 'lte', |
|
|
|
|
|
|
|
value: '30', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fk_column_id: paymentListColumn?.id, |
|
|
|
|
|
|
|
status: 'create', |
|
|
|
|
|
|
|
logical_op: 'and', |
|
|
|
|
|
|
|
comparison_op: 'notempty', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
is_group: true, |
|
|
|
|
|
|
|
status: 'create', |
|
|
|
|
|
|
|
logical_op: 'and', |
|
|
|
|
|
|
|
children: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
logical_op: 'and', |
|
|
|
|
|
|
|
fk_column_id: activeColumn?.id, |
|
|
|
|
|
|
|
status: 'create', |
|
|
|
|
|
|
|
comparison_op: 'notempty', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ascResponse = await request(context.app) |
|
|
|
|
|
|
|
.get( |
|
|
|
|
|
|
|
`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/find-one` |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.set('xc-auth', context.token) |
|
|
|
|
|
|
|
.query({ |
|
|
|
|
|
|
|
nested: nestedFields, |
|
|
|
|
|
|
|
filterArrJson: JSON.stringify([nestedFilter]), |
|
|
|
|
|
|
|
sort: `${rollupColumn.title}`, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.expect(200); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ascResponse.body[rollupColumn.title] !== 12) { |
|
|
|
|
|
|
|
console.log(ascResponse.body); |
|
|
|
|
|
|
|
throw new Error('Wrong filter'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const nestedRentalResponse = Object.keys(ascResponse.body['Rental List']); |
|
|
|
|
|
|
|
if ( |
|
|
|
|
|
|
|
nestedRentalResponse.includes('RentalId') && |
|
|
|
|
|
|
|
nestedRentalResponse.includes('RentalDate') && |
|
|
|
|
|
|
|
nestedRentalResponse.length === 2 |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
throw new Error('Wrong nested fields'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export default function () { |
|
|
|
export default function () { |
|
|
|