This commit is contained in:
Charlie Kolb 2025-10-17 15:27:58 +02:00
parent 9a99f7cdeb
commit f9d9428dad
No known key found for this signature in database
2 changed files with 4 additions and 75 deletions

View File

@ -1497,73 +1497,6 @@ describe('dataTable', () => {
},
]);
});
it('inserts json', async () => {
// ARRANGE
const { id: dataStoreId } = await dataTableService.createDataTable(project1.id, {
name: 'dataStore',
columns: [{ name: 'c1', type: 'json' }],
});
console.log('AAA');
// ACT
const d = new Date();
const rows = [{ c1: { a: 3, b: { c: true }, d } }];
const result = await dataTableService.insertRows(dataStoreId, project1.id, rows, 'id');
console.log('BBB');
// ASSERT
expect(result).toEqual([{ id: 1 }]);
{
const { count, data } = await dataTableService.getManyRowsAndCount(
dataStoreId,
project1.id,
{},
);
expect(count).toEqual(1);
expect(data).toHaveLength(1);
expect(data[0]).toMatchObject({
c1: { a: 3, b: { c: true }, d: `${d.toISOString()}` },
});
}
console.log('CCC');
{
const { data } = await dataTableService.getManyRowsAndCount(dataStoreId, project1.id, {
filter: {
type: 'and',
filters: [
{
columnName: 'c1',
condition: 'eq',
value: 3,
path: 'a',
},
{
columnName: 'c1',
condition: 'eq',
value: true,
path: 'b.c',
},
{
columnName: 'c1',
condition: 'gte',
value: `${d.toISOString()}`,
path: 'd',
},
],
},
});
expect(data).toEqual([
{
c1: { a: 3, b: { c: true }, d: d.toISOString() },
id: 1,
createdAt: expect.any(Date),
updatedAt: expect.any(Date),
},
]);
}
});
describe('bulk', () => {
it('handles single empty row correctly in bulk mode', async () => {
@ -3614,8 +3547,10 @@ describe('dataTable', () => {
[3, 3, 'neq', false],
[3, '3', 'eq', true],
[3, '3', 'neq', false],
[null, null, 'eq', true],
[null, null, 'neq', false],
// these tests fail in MariaDB and MySQL
// in face of V2 we decided to accept these breaking
// [null, null, 'eq', true],
// [null, null, 'neq', false],
[11, 3, 'gt', true],
[11, 3, 'lt', false],
[11, '3', 'gt', false],

View File

@ -573,15 +573,11 @@ export class DataTableRowsRepository {
this.dataSource.manager,
trx,
async (em) => {
console.log('NNN');
const [countQuery, query] = this.getManyQuery(dataTableId, dto, em);
console.log('MMM');
const data: DataTableRowsReturn = await query.select('*').getRawMany();
console.log('OOO');
const countResult = await countQuery.select('COUNT(*) as count').getRawOne<{
count: number | string | null;
}>();
console.log('PPP');
const count =
typeof countResult?.count === 'number'
? countResult.count
@ -661,11 +657,9 @@ export class DataTableRowsRepository {
if (conditionsAndParams.length === 1) {
// Always use AND for a single filter
const [condition, params] = conditionsAndParams[0];
console.log('XXX', condition);
query.andWhere(condition, params);
} else {
for (const [condition, params] of conditionsAndParams) {
console.log('YYY', condition);
if (filterType === 'or') {
query.orWhere(condition, params);
} else {