Skip to content

Commit 5d59365

Browse files
committed
test: debug test
1 parent 19df570 commit 5d59365

File tree

3 files changed

+38
-30
lines changed

3 files changed

+38
-30
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ jobs:
3030
- name: Test
3131
env:
3232
NX_REJECT_UNKNOWN_LOCAL_CACHE: 0
33-
run: npx nx affected -t test --parallel=3 --exclude='json-api-front,json-api-server,json-api-server-e2e,json-shared-type,database,@nestjs-json-api/source,type-for-rpc'
33+
run: npx nx affected -t test --parallel=3 --exclude='json-api-front,json-api-server,json-api-server-e2e,json-shared-type,microorm-database,typeorm-database,@nestjs-json-api/source,type-for-rpc'
3434
- name: Build
3535
env:
3636
NX_REJECT_UNKNOWN_LOCAL_CACHE: 0
37-
run: npx nx affected -t build --exclude='json-api-front,json-api-server,json-api-server-e2e,json-shared-type,database,@nestjs-json-api/source,type-for-rpc'
37+
run: npx nx affected -t build --exclude='json-api-front,json-api-server,json-api-server-e2e,json-shared-type,microorm-database,typeorm-database,@nestjs-json-api/source,type-for-rpc'
3838
- name: Save cached .nx
3939
id: cache-dependencies-save
4040
uses: actions/cache/save@v4

libs/json-api/json-api-nestjs/src/lib/modules/micro-orm/orm-methods/post-relationship/post-relationship.ts

+35-27
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,43 @@ export async function postRelationship<
1414
rel: Rel,
1515
input: PostRelationshipData
1616
): Promise<E> {
17-
const idsResult = await this.microOrmUtilService.validateRelationInputData(
18-
rel,
19-
input
20-
);
21-
const currentEntityRef = this.microOrmUtilService.entityManager.getReference(
22-
this.microOrmUtilService.entity,
23-
id as any
24-
);
17+
try {
18+
const idsResult = await this.microOrmUtilService.validateRelationInputData(
19+
rel,
20+
input
21+
);
2522

26-
const relEntity = this.microOrmUtilService.getRelation(rel as any).entity();
23+
const currentEntityRef =
24+
this.microOrmUtilService.entityManager.getReference(
25+
this.microOrmUtilService.entity,
26+
id as any
27+
);
2728

28-
if (Array.isArray(idsResult)) {
29-
const relRef = idsResult.map((i) =>
30-
this.microOrmUtilService.entityManager.getReference(relEntity, i as any)
31-
);
32-
currentEntityRef[rel].add(...relRef);
33-
} else {
34-
// @ts-ignore
35-
currentEntityRef[rel] = this.microOrmUtilService.entityManager.getReference(
36-
relEntity,
37-
idsResult as any
38-
);
39-
}
29+
const relEntity = this.microOrmUtilService.getRelation(rel as any).entity();
30+
31+
if (Array.isArray(idsResult)) {
32+
const relRef = idsResult.map((i) =>
33+
this.microOrmUtilService.entityManager.getReference(relEntity, i as any)
34+
);
35+
currentEntityRef[rel].add(...relRef);
36+
} else {
37+
// @ts-ignore
38+
currentEntityRef[rel] =
39+
this.microOrmUtilService.entityManager.getReference(
40+
relEntity,
41+
idsResult as any
42+
);
43+
}
4044

41-
await this.microOrmUtilService.entityManager.flush();
45+
await this.microOrmUtilService.entityManager.flush();
4246

43-
return getRelationship.call<
44-
MicroOrmService<E>,
45-
Parameters<typeof getRelationship<E, Rel>>,
46-
ReturnType<typeof getRelationship<E, Rel>>
47-
>(this, id, rel);
47+
return getRelationship.call<
48+
MicroOrmService<E>,
49+
Parameters<typeof getRelationship<E, Rel>>,
50+
ReturnType<typeof getRelationship<E, Rel>>
51+
>(this, id, rel);
52+
} catch (e) {
53+
console.log(e);
54+
throw e;
55+
}
4856
}

libs/json-api/json-api-nestjs/src/lib/modules/micro-orm/service/micro-orm-util.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ export class MicroOrmUtilService<E extends ObjectLiteral> {
720720
},
721721
})
722722
.getResult();
723-
723+
console.log(checkResult, prepareData, rel, inputData);
724724
if (checkResult.length === prepareData.length) {
725725
return (
726726
isArray ? inputData.map((i) => i.id) : inputData.id

0 commit comments

Comments
 (0)