测试了select+aggregate,并修改了一个边界
This commit is contained in:
parent
eff1bbb20f
commit
20aa7f7c21
|
|
@ -785,7 +785,8 @@ var TreeStore = /** @class */ (function (_super) {
|
||||||
Object.assign(nodeDict2, nodeDict);
|
Object.assign(nodeDict2, nodeDict);
|
||||||
}
|
}
|
||||||
var exprResolveFns = [];
|
var exprResolveFns = [];
|
||||||
if (!filterFn || filterFn(n, nodeDict2, exprResolveFns)) {
|
// 如果没有filterFn,要保证行不为null(本事务remove的case)
|
||||||
|
if (filterFn ? filterFn(n, nodeDict2, exprResolveFns) : this.constructRow(n, context, option)) {
|
||||||
// 如果有延时处理的expression,在这里加以判断,此时所有在filter中的node应该都已经加以遍历了
|
// 如果有延时处理的expression,在这里加以判断,此时所有在filter中的node应该都已经加以遍历了
|
||||||
var exprResult = true;
|
var exprResult = true;
|
||||||
if (exprResolveFns.length > 0) {
|
if (exprResolveFns.length > 0) {
|
||||||
|
|
@ -991,8 +992,10 @@ var TreeStore = /** @class */ (function (_super) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (rel instanceof Array) {
|
else if (rel instanceof Array) {
|
||||||
if (data[attr] && data[attr] instanceof Array) {
|
if (!attr.endsWith('$$aggr')) {
|
||||||
data[attr].map(function (ele) { return _this.formExprInResult(rel[0], projection[attr].data, ele, nodeDict, context); });
|
if (data[attr] && data[attr] instanceof Array) {
|
||||||
|
data[attr].map(function (ele) { return _this.formExprInResult(rel[0], projection[attr].data, ele, nodeDict, context); });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
14
src/store.ts
14
src/store.ts
|
|
@ -849,7 +849,9 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
||||||
Object.assign(nodeDict2, nodeDict);
|
Object.assign(nodeDict2, nodeDict);
|
||||||
}
|
}
|
||||||
const exprResolveFns: Array<ExprResolveFn> = [];
|
const exprResolveFns: Array<ExprResolveFn> = [];
|
||||||
if (!filterFn || filterFn(n, nodeDict2, exprResolveFns)) {
|
|
||||||
|
// 如果没有filterFn,要保证行不为null(本事务remove的case)
|
||||||
|
if (filterFn ? filterFn(n, nodeDict2, exprResolveFns) : this.constructRow(n, context, option)) {
|
||||||
// 如果有延时处理的expression,在这里加以判断,此时所有在filter中的node应该都已经加以遍历了
|
// 如果有延时处理的expression,在这里加以判断,此时所有在filter中的node应该都已经加以遍历了
|
||||||
let exprResult = true;
|
let exprResult = true;
|
||||||
if (exprResolveFns.length > 0) {
|
if (exprResolveFns.length > 0) {
|
||||||
|
|
@ -1046,10 +1048,12 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (rel instanceof Array) {
|
else if (rel instanceof Array) {
|
||||||
if (data[attr] && (data[attr] as any) instanceof Array) {
|
if (!attr.endsWith('$$aggr')) {
|
||||||
data[attr].map(
|
if (data[attr] && (data[attr] as any) instanceof Array) {
|
||||||
(ele: any) => this.formExprInResult(rel[0], projection[attr].data, ele, nodeDict, context)
|
data[attr].map(
|
||||||
)
|
(ele: any) => this.formExprInResult(rel[0], projection[attr].data, ele, nodeDict, context)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
97
test/test.ts
97
test/test.ts
|
|
@ -625,7 +625,7 @@ describe('基础测试', function () {
|
||||||
entity: 1,
|
entity: 1,
|
||||||
},
|
},
|
||||||
}, context, {});
|
}, context, {});
|
||||||
assert(me2.length === 2 && !!me2.find(ele => !!ele.$$deleteAt$$));
|
assert(me2.length === 1 && !me2.find(ele => !!ele.$$deleteAt$$));
|
||||||
context.rollback();
|
context.rollback();
|
||||||
|
|
||||||
context.begin();
|
context.begin();
|
||||||
|
|
@ -636,7 +636,6 @@ describe('基础测试', function () {
|
||||||
entity: 1,
|
entity: 1,
|
||||||
},
|
},
|
||||||
}, context, {});
|
}, context, {});
|
||||||
assert(me3.length === 2);
|
|
||||||
assert(me3.length === 2 && !me3.find(ele => !!ele.$$deleteAt$$));
|
assert(me3.length === 2 && !me3.find(ele => !!ele.$$deleteAt$$));
|
||||||
|
|
||||||
context.commit();
|
context.commit();
|
||||||
|
|
@ -726,5 +725,99 @@ describe('基础测试', function () {
|
||||||
// console.log(result);
|
// console.log(result);
|
||||||
context.commit();
|
context.commit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('[1.9]selection+aggregate', () => {
|
||||||
|
const store = new FrontendStore(storageSchema);
|
||||||
|
const context = new FrontendRuntimeContext(store);
|
||||||
|
context.begin();
|
||||||
|
store.operate('modi', {
|
||||||
|
id: generateNewId(),
|
||||||
|
action: 'create',
|
||||||
|
data: [{
|
||||||
|
id: generateNewId(),
|
||||||
|
targetEntity: 'ddd',
|
||||||
|
entity: 'user',
|
||||||
|
entityId: 'user-id-1',
|
||||||
|
action: 'create',
|
||||||
|
data: {},
|
||||||
|
modiEntity$modi: {
|
||||||
|
action: 'create',
|
||||||
|
data: [{
|
||||||
|
id: generateNewId(),
|
||||||
|
entity: 'user',
|
||||||
|
entityId: 'user-id-1',
|
||||||
|
}, {
|
||||||
|
id: generateNewId(),
|
||||||
|
entity: 'user',
|
||||||
|
entityId: 'user-id-1',
|
||||||
|
}, {
|
||||||
|
id: generateNewId(),
|
||||||
|
entity: 'user',
|
||||||
|
entityId: 'user-id-1',
|
||||||
|
}, {
|
||||||
|
id: generateNewId(),
|
||||||
|
entity: 'user',
|
||||||
|
entityId: 'user-id-1',
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
id: generateNewId(),
|
||||||
|
targetEntity: 'ddd2',
|
||||||
|
entity: 'user',
|
||||||
|
entityId: 'user-id-2',
|
||||||
|
action: 'create',
|
||||||
|
data: {},
|
||||||
|
modiEntity$modi: {
|
||||||
|
action: 'create',
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: generateNewId(),
|
||||||
|
entity: 'user',
|
||||||
|
entityId: 'user-id-2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: generateNewId(),
|
||||||
|
entity: 'user',
|
||||||
|
entityId: 'user-id-2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: generateNewId(),
|
||||||
|
entity: 'user',
|
||||||
|
entityId: 'user-id-2',
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
}, context, {});
|
||||||
|
context.commit();
|
||||||
|
|
||||||
|
context.begin();
|
||||||
|
const result = store.select('modi', {
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
modiEntity$modi$$aggr: {
|
||||||
|
$entity: 'modiEntity',
|
||||||
|
data: {
|
||||||
|
'$count-1': {
|
||||||
|
id: 1,
|
||||||
|
},
|
||||||
|
'$avg-1': {
|
||||||
|
$$createAt$$: 1,
|
||||||
|
},
|
||||||
|
$aggr: {
|
||||||
|
modi: {
|
||||||
|
targetEntity: 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
entity: 'user',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, context, {});
|
||||||
|
console.log(result);
|
||||||
|
context.commit();
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue