处理了includeDeleted的查询结果处理
This commit is contained in:
parent
109e348ae8
commit
d5b99e5012
|
|
@ -167,8 +167,11 @@ function polishSelection(schema, entity, selection, context, option) {
|
|||
}
|
||||
const toBeAssignNode2 = {}; // 用来记录在表达式中涉及到的结点
|
||||
const projectionNodeDict = {};
|
||||
const checkProjectionNode = (entity2, projectionNode) => {
|
||||
const necessaryAttrs = ['id', '$$createAt$$', '$$updateAt$$']; // 有的页面依赖于其它页面取数据,有时两个页面的filter的差异会导致有一个加createAt,有一个不加,此时可能产生前台取数据不完整的异常。先统一加上
|
||||
const checkProjectionNode = (entity2, projectionNode, root) => {
|
||||
const necessaryAttrs = [types_1.PrimaryKeyAttribute, Entity_1.CreateAtAttribute, Entity_1.UpdateAtAttribute]; // 有的页面依赖于其它页面取数据,有时两个页面的filter的差异会导致有一个加createAt,有一个不加,此时可能产生前台取数据不完整的异常。先统一加上
|
||||
if (root && option?.includedDeleted) {
|
||||
necessaryAttrs.push(Entity_1.DeleteAtAttribute);
|
||||
}
|
||||
for (const attr in projectionNode) {
|
||||
if (attr === '#id') {
|
||||
(0, assert_1.default)(!projectionNodeDict[projectionNode[attr]], `projection中结点的id有重复, ${projectionNode[attr]}`);
|
||||
|
|
@ -264,7 +267,7 @@ function polishSelection(schema, entity, selection, context, option) {
|
|||
}
|
||||
}
|
||||
};
|
||||
checkProjectionNode(entity, data);
|
||||
checkProjectionNode(entity, data, true);
|
||||
if (!sorter && relevantIds.length === 0) {
|
||||
// 如果没有sorter,就给予一个按createAt逆序的sorter
|
||||
Object.assign(selection, {
|
||||
|
|
@ -1702,7 +1705,7 @@ class CascadeStore extends RowStore_1.RowStore {
|
|||
const entityBranch = lastOperation.d[entity];
|
||||
if (entityBranch) {
|
||||
rows.forEach((row) => {
|
||||
if (row && row.id) { // 如果没有row.id就不加入结果集了
|
||||
if (row && row.id && !row[Entity_1.DeleteAtAttribute]) { // 如果没有row.id就不加入结果集了
|
||||
const { id } = row;
|
||||
if (!entityBranch[id]) {
|
||||
Object.assign(entityBranch, {
|
||||
|
|
@ -1727,7 +1730,7 @@ class CascadeStore extends RowStore_1.RowStore {
|
|||
}
|
||||
const entityBranch = {};
|
||||
rows.forEach((row) => {
|
||||
if (row) {
|
||||
if (row && row.id && !row[Entity_1.DeleteAtAttribute]) {
|
||||
const { id } = row;
|
||||
Object.assign(entityBranch, {
|
||||
[id]: (0, lodash_1.cloneDeep)(row),
|
||||
|
|
|
|||
|
|
@ -203,8 +203,11 @@ export function polishSelection<ED extends EntityDict & BaseEntityDict, Cxt exte
|
|||
|
||||
const toBeAssignNode2: Record<string, string[]> = {}; // 用来记录在表达式中涉及到的结点
|
||||
const projectionNodeDict: Record<string, ED[keyof ED]['Projection']> = {};
|
||||
const checkProjectionNode = (entity2: keyof ED, projectionNode: ED[keyof ED]['Projection']) => {
|
||||
const necessaryAttrs: string[] = ['id', '$$createAt$$', '$$updateAt$$']; // 有的页面依赖于其它页面取数据,有时两个页面的filter的差异会导致有一个加createAt,有一个不加,此时可能产生前台取数据不完整的异常。先统一加上
|
||||
const checkProjectionNode = (entity2: keyof ED, projectionNode: ED[keyof ED]['Projection'], root?: boolean) => {
|
||||
const necessaryAttrs: string[] = [PrimaryKeyAttribute, CreateAtAttribute, UpdateAtAttribute]; // 有的页面依赖于其它页面取数据,有时两个页面的filter的差异会导致有一个加createAt,有一个不加,此时可能产生前台取数据不完整的异常。先统一加上
|
||||
if (root && option?.includedDeleted) {
|
||||
necessaryAttrs.push(DeleteAtAttribute);
|
||||
}
|
||||
for (const attr in projectionNode) {
|
||||
if (attr === '#id') {
|
||||
assert(!projectionNodeDict[projectionNode[attr]!], `projection中结点的id有重复, ${projectionNode[attr]}`);
|
||||
|
|
@ -301,7 +304,7 @@ export function polishSelection<ED extends EntityDict & BaseEntityDict, Cxt exte
|
|||
}
|
||||
}
|
||||
};
|
||||
checkProjectionNode(entity, data);
|
||||
checkProjectionNode(entity, data, true);
|
||||
|
||||
if (!sorter && relevantIds.length === 0) {
|
||||
// 如果没有sorter,就给予一个按createAt逆序的sorter
|
||||
|
|
@ -2104,7 +2107,7 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
if (entityBranch) {
|
||||
rows.forEach(
|
||||
(row) => {
|
||||
if (row && row.id) { // 如果没有row.id就不加入结果集了
|
||||
if (row && row.id && !row[DeleteAtAttribute]) { // 如果没有row.id就不加入结果集了
|
||||
const { id } = row;
|
||||
if (!entityBranch![id!]) {
|
||||
Object.assign(entityBranch!, {
|
||||
|
|
@ -2132,7 +2135,7 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
const entityBranch = {};
|
||||
rows.forEach(
|
||||
(row) => {
|
||||
if (row) {
|
||||
if (row && row.id && !row[DeleteAtAttribute]) {
|
||||
const { id } = row as { id: string };
|
||||
Object.assign(entityBranch!, {
|
||||
[id!]: cloneDeep(row),
|
||||
|
|
|
|||
Loading…
Reference in New Issue