added strictness to methods in the repository and query builder - now if they are returning undefined method signature has undefined in returned value

This commit is contained in:
Umed Khudoiberdiev 2016-11-29 12:41:00 +05:00
parent 1f89acecc7
commit 57e13f689b
22 changed files with 96 additions and 91 deletions

View File

@ -48,7 +48,7 @@ createConnection(options).then(async connection => {
console.log("employee has been updated: ", employee);
console.log("now loading the employee: ");
const loadedEmployee = await employeeRepository.findOneById(1);
const loadedEmployee = (await employeeRepository.findOneById(1))!;
console.log("loaded employee: ", loadedEmployee);
loadedEmployee.firstName = "dima";

View File

@ -211,27 +211,27 @@ export class EntityManager extends BaseEntityManager {
/**
* Finds first entity that matches given conditions.
*/
findOne<Entity>(entityClass: ObjectType<Entity>): Promise<Entity>;
findOne<Entity>(entityClass: ObjectType<Entity>): Promise<Entity|undefined>;
/**
* Finds first entity that matches given conditions.
*/
findOne<Entity>(entityClass: ObjectType<Entity>, conditions: ObjectLiteral): Promise<Entity>;
findOne<Entity>(entityClass: ObjectType<Entity>, conditions: ObjectLiteral): Promise<Entity|undefined>;
/**
* Finds first entity that matches given conditions.
*/
findOne<Entity>(entityClass: ObjectType<Entity>, options: FindOptions): Promise<Entity>;
findOne<Entity>(entityClass: ObjectType<Entity>, options: FindOptions): Promise<Entity|undefined>;
/**
* Finds first entity that matches given conditions.
*/
findOne<Entity>(entityClass: ObjectType<Entity>, conditions: ObjectLiteral, options: FindOptions): Promise<Entity>;
findOne<Entity>(entityClass: ObjectType<Entity>, conditions: ObjectLiteral, options: FindOptions): Promise<Entity|undefined>;
/**
* Finds first entity that matches given conditions.
*/
findOne<Entity>(entityClass: ObjectType<Entity>, conditionsOrFindOptions?: ObjectLiteral|FindOptions, options?: FindOptions): Promise<Entity> {
findOne<Entity>(entityClass: ObjectType<Entity>, conditionsOrFindOptions?: ObjectLiteral|FindOptions, options?: FindOptions): Promise<Entity|undefined> {
if (conditionsOrFindOptions && options) {
return this.getRepository(entityClass).findOne(conditionsOrFindOptions, options);
@ -243,10 +243,18 @@ export class EntityManager extends BaseEntityManager {
}
}
/**
* Finds entities with ids.
* Optionally find options can be applied.
*/
findByIds<Entity>(entityClass: ObjectType<Entity>, ids: any[], options?: FindOptions): Promise<Entity[]> {
return this.getRepository(entityClass).findByIds(ids, options);
}
/**
* Finds entity with given id.
*/
findOneById<Entity>(entityClass: ObjectType<Entity>, id: any, options?: FindOptions): Promise<Entity> {
findOneById<Entity>(entityClass: ObjectType<Entity>, id: any, options?: FindOptions): Promise<Entity|undefined> {
return this.getRepository(entityClass).findOneById(id, options);
}

View File

@ -163,7 +163,6 @@ export class SubjectBuilder<Entity extends ObjectLiteral> {
// here we should use findByEntityLike instead of findByEntity because findByEntityLike relays on ids,
// however these ids are missing in insert operation and using findByEntityLike can bring recursion
const alreadyExistValueSubject = this.findByEntity(value);
console.log(alreadyExistValueSubject);
if (alreadyExistValueSubject) {
if (alreadyExistValueSubject.canBeInserted === false)
alreadyExistValueSubject.canBeInserted = relation.isCascadeInsert === true;

View File

@ -1157,7 +1157,7 @@ export class QueryBuilder<Entity> {
/**
* Gets single entity returned by execution of generated query builder sql.
*/
getSingleResult(): Promise<Entity> {
getSingleResult(): Promise<Entity|undefined> {
return this.getResults().then(entities => entities[0]);
}

View File

@ -22,7 +22,7 @@ export class PlainObjectToDatabaseEntityTransformer {
// Public Methods
// -------------------------------------------------------------------------
async transform<Entity extends ObjectLiteral>(plainObject: ObjectLiteral, metadata: EntityMetadata, queryBuilder: QueryBuilder<Entity>): Promise<Entity> {
async transform<Entity extends ObjectLiteral>(plainObject: ObjectLiteral, metadata: EntityMetadata, queryBuilder: QueryBuilder<Entity>): Promise<Entity|undefined> {
// if plain object does not have id then nothing to load really
if (!metadata.checkIfObjectContainsAllPrimaryKeys(plainObject))

View File

@ -253,27 +253,27 @@ export class Repository<Entity extends ObjectLiteral> {
/**
* Finds first entity that matches given conditions.
*/
async findOne(): Promise<Entity>;
async findOne(): Promise<Entity|undefined>;
/**
* Finds first entity that matches given conditions.
*/
async findOne(conditions: ObjectLiteral): Promise<Entity>;
async findOne(conditions: ObjectLiteral): Promise<Entity|undefined>;
/**
* Finds first entity that matches given find options.
*/
async findOne(options: FindOptions): Promise<Entity>;
async findOne(options: FindOptions): Promise<Entity|undefined>;
/**
* Finds first entity that matches given conditions and find options.
*/
async findOne(conditions: ObjectLiteral, options: FindOptions): Promise<Entity>;
async findOne(conditions: ObjectLiteral, options: FindOptions): Promise<Entity|undefined>;
/**
* Finds first entity that matches given conditions and/or find options.
*/
async findOne(conditionsOrFindOptions?: ObjectLiteral|FindOptions, options?: FindOptions): Promise<Entity> {
async findOne(conditionsOrFindOptions?: ObjectLiteral|FindOptions, options?: FindOptions): Promise<Entity|undefined> {
return this.createFindQueryBuilder(conditionsOrFindOptions, options)
.getSingleResult();
}
@ -281,7 +281,6 @@ export class Repository<Entity extends ObjectLiteral> {
/**
* Finds entities with ids.
* Optionally find options can be applied.
* todo: add this method into all other repositories and entity managers
*/
async findByIds(ids: any[], options?: FindOptions): Promise<Entity[]> {
const qb = this.createFindQueryBuilder(undefined, options);
@ -292,7 +291,7 @@ export class Repository<Entity extends ObjectLiteral> {
* Finds entity with given id.
* Optionally find options can be applied.
*/
async findOneById(id: any, options?: FindOptions): Promise<Entity> {
async findOneById(id: any, options?: FindOptions): Promise<Entity|undefined> {
const conditions: ObjectLiteral = {};
if (this.metadata.hasMultiplePrimaryKeys) {
this.metadata.primaryColumns.forEach(primaryColumn => {

View File

@ -425,22 +425,6 @@ export class SpecificRepository<Entity extends ObjectLiteral> {
.execute();
}
/**
* Converts entity or entities to id or ids map.
*/
private convertEntityOrEntitiesToIdOrIds(column: ColumnMetadata, entityOrEntities: Entity[]|Entity|any|any[]): any|any[] {
if (entityOrEntities instanceof Array) {
return entityOrEntities.map(entity => this.convertEntityOrEntitiesToIdOrIds(column, entity));
} else {
if (entityOrEntities instanceof Object) {
return entityOrEntities[column.propertyName];
} else {
return entityOrEntities;
}
}
}
/**
* Finds all relation ids in the given entities.
*/
@ -492,6 +476,22 @@ export class SpecificRepository<Entity extends ObjectLiteral> {
// Protected Methods
// -------------------------------------------------------------------------
/**
* Converts entity or entities to id or ids map.
*/
protected convertEntityOrEntitiesToIdOrIds(column: ColumnMetadata, entityOrEntities: Entity[]|Entity|any|any[]): any|any[] {
if (entityOrEntities instanceof Array) {
return entityOrEntities.map(entity => this.convertEntityOrEntitiesToIdOrIds(column, entity));
} else {
if (entityOrEntities instanceof Object) {
return entityOrEntities[column.propertyName];
} else {
return entityOrEntities;
}
}
}
/**
* Converts relation name, relation name in function into RelationMetadata.
*/

View File

@ -47,7 +47,7 @@ export class TreeRepository<Entity> extends Repository<Entity> {
/**
* Gets all children (descendants) of the given entity. Returns them in a tree - nested into each other.
*/
findDescendantsTree(entity: Entity): Promise<Entity> {
findDescendantsTree(entity: Entity): Promise<Entity|undefined> {
// todo: throw exception if there is no column of this relation?
return this
.createDescendantsQueryBuilder("treeEntity", "treeClosure", entity)
@ -90,7 +90,7 @@ export class TreeRepository<Entity> extends Repository<Entity> {
/**
* Gets all parents (ancestors) of the given entity. Returns them in a tree - nested into each other.
*/
findAncestorsTree(entity: Entity): Promise<Entity> {
findAncestorsTree(entity: Entity): Promise<Entity|undefined> {
// todo: throw exception if there is no column of this relation?
return this
.createAncestorsQueryBuilder("treeEntity", "treeClosure", entity)

View File

@ -4,7 +4,6 @@ import {createTestingConnectionOptions} from "../../utils/test-utils";
import {ConnectionOptions} from "../../../src/connection/ConnectionOptions";
import {ConnectionManager} from "../../../src/connection/ConnectionManager";
import {MysqlDriver} from "../../../src/driver/mysql/MysqlDriver";
import {PostgresDriver} from "../../../src/driver/postgres/PostgresDriver";
import {ConnectionNotFoundError} from "../../../src/connection/error/ConnectionNotFoundError";
import {PrimaryGeneratedColumn} from "../../../src/decorator/columns/PrimaryGeneratedColumn";
import {Column} from "../../../src/decorator/columns/Column";
@ -127,7 +126,7 @@ describe("ConnectionManager", () => {
// recreate connection and find previously saved post
connection = await connectionManager.createAndConnect(options);
const loadedPost = await connection.entityManager.findOneById(Post, 1);
const loadedPost = (await connection.entityManager.findOneById(Post, 1))!;
loadedPost.should.be.instanceof(Post);
loadedPost.should.be.eql({ id: 1, title: "Hello post" });
await connection.close();

View File

@ -27,7 +27,7 @@ describe("decorators > embedded", () => {
await postRepository.persist(post);
// now load it
const loadedPost = await postRepository.findOneById(1);
const loadedPost = (await postRepository.findOneById(1))!;
loadedPost.id.should.be.equal(1);
loadedPost.title.should.be.equal("Hello post");
loadedPost.text.should.be.equal("This is text about the post");

View File

@ -58,11 +58,11 @@ describe("QueryBuilder > relation-id", () => {
expect(post.categories[0].id).to.not.be.empty;
expect(post.categories[1].id).to.not.be.empty;
let loadedPost = await postRepository
let loadedPost = (await postRepository
.createQueryBuilder("post")
.leftJoinRelationId("post.categories")
.where("post.id = :id", { id: post.id })
.getSingleResult();
.getSingleResult())!;
expect(loadedPost.tagId).to.not.be.empty;
expect(loadedPost.tagId).to.be.equal(1);
@ -70,28 +70,28 @@ describe("QueryBuilder > relation-id", () => {
expect(loadedPost.categoryIds).to.contain(1);
expect(loadedPost.categoryIds).to.contain(2);
let loadedEmptyPost = await postRepository
let loadedEmptyPost = (await postRepository
.createQueryBuilder("post")
.leftJoinRelationId("post.categories")
.where("post.id = :id", { id: emptyPost.id })
.getSingleResult();
.getSingleResult())!;
should.not.exist(loadedEmptyPost.tagId);
should.not.exist(loadedEmptyPost.categoryIds);
loadedEmptyPost = await postRepository
loadedEmptyPost = (await postRepository
.createQueryBuilder("post")
.innerJoinRelationId("post.categories")
.where("post.id = :id", { id: emptyPost.id })
.getSingleResult();
.getSingleResult())!;
should.not.exist(loadedEmptyPost);
loadedPost = await postRepository
loadedPost = (await postRepository
.createQueryBuilder("post")
.leftJoinRelationIdAndMap("post.allCategoryIds", "post.categories")
.where("post.id = :id", { id: post.id })
.getSingleResult();
.getSingleResult())!;
loadedPost.allCategoryIds.should.contain(1);
loadedPost.allCategoryIds.should.contain(2);

View File

@ -54,7 +54,7 @@ describe("lazy-relations", () => {
savedPost.categories.should.eventually.be.eql([savedCategory1, savedCategory2, savedCategory3]);
const post = await postRepository.findOneById(1);
const post = (await postRepository.findOneById(1))!;
post.title.should.be.equal("Hello post");
post.text.should.be.equal("This is post about post");
@ -94,7 +94,7 @@ describe("lazy-relations", () => {
savedPost.twoSideCategories.should.eventually.be.eql([savedCategory1, savedCategory2, savedCategory3]);
const post = await postRepository.findOneById(1);
const post = (await postRepository.findOneById(1))!;
post.title.should.be.equal("Hello post");
post.text.should.be.equal("This is post about post");
@ -106,7 +106,7 @@ describe("lazy-relations", () => {
categories.should.contain(savedCategory2);
categories.should.contain(savedCategory3);
const category = await categoryRepository.findOneById(1);
const category = (await categoryRepository.findOneById(1))!;
category.name.should.be.equal("kids");
const twoSidePosts = await category.twoSidePosts;

View File

@ -70,7 +70,7 @@ describe("persistence > custom-column-names", function() {
before(function() {
return postRepository
.findOneById(1, { alias: "post", leftJoinAndSelect: { category: "post.category" } })
.then(post => loadedPost = post);
.then(post => loadedPost = post!);
});
it("should contain attached category", function () {
@ -105,7 +105,7 @@ describe("persistence > custom-column-names", function() {
before(function() {
return postRepository
.findOneById(1, { alias: "post", leftJoinAndSelect: { category: "post.category" } })
.then(post => loadedPost = post);
.then(post => loadedPost = post!);
});
it("should contain attached category", function () {
@ -135,7 +135,7 @@ describe("persistence > custom-column-names", function() {
before(function() {
return postRepository
.findOneById(1, { alias: "post", leftJoinAndSelect: { category: "post.category" } })
.then(post => loadedPost = post);
.then(post => loadedPost = post!);
});
it("should contain attached category", function () {
@ -183,7 +183,7 @@ describe("persistence > custom-column-names", function() {
before(function() {
return postRepository
.findOneById(1, { alias: "post", leftJoinAndSelect: { category: "post.category", metadata: "category.metadata" } })
.then(post => loadedPost = post);
.then(post => loadedPost = post!);
});
it("should contain attached category and metadata in the category", function () {
@ -228,7 +228,7 @@ describe("persistence > custom-column-names", function() {
before(function() {
return postRepository
.findOneById(1, { alias: "post", leftJoinAndSelect: { category: "post.category", metadata: "category.metadata" } })
.then(post => loadedPost = post);
.then(post => loadedPost = post!);
});
it("should contain attached category and metadata in the category", function () {

View File

@ -97,7 +97,7 @@ describe("persistence > many-to-many", function() {
before(function() {
return userRepository
.findOneById(1, { alias: "user", leftJoinAndSelect: { post: "user.post", categories: "post.categories" } })
.then(post => loadedUser = post);
.then(post => loadedUser = post!);
});
it("should contain a new category", function () {

View File

@ -46,7 +46,7 @@ describe("persistence > one-to-many", function() {
await postRepository.persist(newPost);
const findOptions: FindOptions = { alias: "post", innerJoinAndSelect: { categories: "post.categories" } };
const loadedPost = await postRepository.findOneById(1, findOptions);
const loadedPost = (await postRepository.findOneById(1, findOptions))!;
expect(loadedPost).not.to.be.empty;
expect(loadedPost.categories).not.to.be.empty;
expect(loadedPost.categories![0]).not.to.be.empty;
@ -72,8 +72,8 @@ describe("persistence > one-to-many", function() {
const findOptions: FindOptions = { alias: "post", innerJoinAndSelect: { categories: "post.categories" } };
const loadedPost = await postRepository.findOneById(1, findOptions);
expect(loadedPost).not.to.be.empty;
expect(loadedPost.categories).not.to.be.empty;
expect(loadedPost.categories![0]).not.to.be.empty;
expect(loadedPost!.categories).not.to.be.empty;
expect(loadedPost!.categories![0]).not.to.be.empty;
})));
});
@ -105,9 +105,9 @@ describe("persistence > one-to-many", function() {
const findOptions: FindOptions = { alias: "post", innerJoinAndSelect: { categories: "post.categories" } };
const loadedPost = await postRepository.findOneById(1, findOptions);
expect(loadedPost).not.to.be.empty;
expect(loadedPost.categories).not.to.be.empty;
expect(loadedPost.categories![0]).not.to.be.empty;
expect(loadedPost.categories![1]).to.be.empty;
expect(loadedPost!.categories).not.to.be.empty;
expect(loadedPost!.categories![0]).not.to.be.empty;
expect(loadedPost!.categories![1]).to.be.empty;
})));
});
@ -139,7 +139,7 @@ describe("persistence > one-to-many", function() {
const findOptions: FindOptions = { alias: "post", leftJoinAndSelect: { categories: "post.categories" } };
const loadedPost = await postRepository.findOneById(1, findOptions);
expect(loadedPost).not.to.be.empty;
expect(loadedPost.categories).to.be.empty;
expect(loadedPost!.categories).to.be.empty;
})));
});
@ -169,7 +169,7 @@ describe("persistence > one-to-many", function() {
await postRepository.persist(newPost);
const findOptions: FindOptions = { alias: "post", leftJoinAndSelect: { categories: "post.categories" } };
const loadedPost = await postRepository.findOneById(1, findOptions);
const loadedPost = (await postRepository.findOneById(1, findOptions))!;
expect(loadedPost).not.to.be.empty;
expect(loadedPost.categories).to.be.empty;
})));

View File

@ -235,7 +235,7 @@ describe("repository > find methods", () => {
const savedUsers = await Promise.all(promises);
savedUsers.length.should.be.equal(100); // check if they all are saved
const loadedUser = await userRepository.findOne({ alias: "user", orderBy: { "user.id": "ASC" }});
const loadedUser = (await userRepository.findOne({ alias: "user", orderBy: { "user.id": "ASC" }}))!;
loadedUser.id.should.be.equal(0);
loadedUser.firstName.should.be.equal("name #0");
loadedUser.secondName.should.be.equal("Doe");
@ -256,7 +256,7 @@ describe("repository > find methods", () => {
const savedUsers = await Promise.all(promises);
savedUsers.length.should.be.equal(100); // check if they all are saved
const loadedUser = await userRepository.findOne({ firstName: "name #1" }, { alias: "user", orderBy: { "user.id": "ASC" }});
const loadedUser = (await userRepository.findOne({ firstName: "name #1" }, { alias: "user", orderBy: { "user.id": "ASC" }}))!;
loadedUser.id.should.be.equal(1);
loadedUser.firstName.should.be.equal("name #1");
loadedUser.secondName.should.be.equal("Doe");
@ -285,7 +285,7 @@ describe("repository > find methods", () => {
secondName: "Doe"
}
};
const loadedUser = await userRepository.findOne(findOptions, { alias: "user", orderBy: { "user.id": "ASC" }});
const loadedUser = (await userRepository.findOne(findOptions, { alias: "user", orderBy: { "user.id": "ASC" }}))!;
loadedUser.id.should.be.equal(99);
loadedUser.firstName.should.be.equal("name #99");
loadedUser.secondName.should.be.equal("Doe");
@ -310,17 +310,17 @@ describe("repository > find methods", () => {
const savedUsers = await Promise.all(promises);
savedUsers.length.should.be.equal(100); // check if they all are saved
let loadedUser = await userRepository.findOneById(0);
let loadedUser = (await userRepository.findOneById(0))!;
loadedUser.id.should.be.equal(0);
loadedUser.firstName.should.be.equal("name #0");
loadedUser.secondName.should.be.equal("Doe");
loadedUser = await userRepository.findOneById(1);
loadedUser = (await userRepository.findOneById(1))!;
loadedUser.id.should.be.equal(1);
loadedUser.firstName.should.be.equal("name #1");
loadedUser.secondName.should.be.equal("Doe");
loadedUser = await userRepository.findOneById(99);
loadedUser = (await userRepository.findOneById(99))!;
loadedUser.id.should.be.equal(99);
loadedUser.firstName.should.be.equal("name #99");
loadedUser.secondName.should.be.equal("Doe");
@ -356,9 +356,9 @@ describe("repository > find methods", () => {
savedUsers.length.should.be.equal(100); // check if they all are saved
let loadedUser = await userRepository.findOneById(0, findOptions1);
loadedUser.id.should.be.equal(0);
loadedUser.firstName.should.be.equal("name #0");
loadedUser.secondName.should.be.equal("Doe");
loadedUser!.id.should.be.equal(0);
loadedUser!.firstName.should.be.equal("name #0");
loadedUser!.secondName.should.be.equal("Doe");
loadedUser = await userRepository.findOneById(1, findOptions2);
expect(loadedUser).to.be.undefined;

View File

@ -101,7 +101,7 @@ describe("repository > set/add/remove relation methods", function() {
before(function() {
return postRepository
.findOneById(1, { alias: "post", leftJoinAndSelect: { manyCategories: "post.manyCategories" } })
.then(post => loadedPost = post);
.then(post => loadedPost = post!);
});
it("should save successfully", function () {
@ -150,7 +150,7 @@ describe("repository > set/add/remove relation methods", function() {
before(function() {
return categoryRepository
.findOneById(1, { alias: "category", leftJoinAndSelect: { manyPosts: "category.manyPosts" } })
.then(category => loadedCategory = category);
.then(category => loadedCategory = category!);
});
it("should save successfully", function () {
@ -207,7 +207,7 @@ describe("repository > set/add/remove relation methods", function() {
before(function() {
return postRepository
.findOneById(1, { alias: "post", leftJoinAndSelect: { manyCategories: "post.manyCategories" } })
.then(post => loadedPost = post);
.then(post => loadedPost = post!);
});
it("should remove successfully", function () {
@ -264,7 +264,7 @@ describe("repository > set/add/remove relation methods", function() {
before(function() {
return categoryRepository
.findOneById(1, { alias: "category", leftJoinAndSelect: { manyPosts: "category.manyPosts" } })
.then(category => loadedCategory = category);
.then(category => loadedCategory = category!);
});
it("should remove successfully", function () {
@ -306,7 +306,7 @@ describe("repository > set/add/remove relation methods", function() {
before(function() {
return postRepository
.findOneById(1, { alias: "post", leftJoinAndSelect: { categories: "post.categories" } })
.then(post => loadedPost = post);
.then(post => loadedPost = post!);
});
it("should save successfully", function () {
@ -347,7 +347,7 @@ describe("repository > set/add/remove relation methods", function() {
before(function() {
return categoryRepository
.findOneById(1, { alias: "category", leftJoinAndSelect: { post: "category.post" } })
.then(category => loadedCategory = category);
.then(category => loadedCategory = category!);
});
it("should save successfully", function () {
@ -386,7 +386,7 @@ describe("repository > set/add/remove relation methods", function() {
before(function() {
return postRepository
.findOneById(1, { alias: "post", leftJoinAndSelect: { categories: "post.categories" } })
.then(post => loadedPost = post);
.then(post => loadedPost = post!);
});
it("should save successfully", function () {
@ -425,7 +425,7 @@ describe("repository > set/add/remove relation methods", function() {
before(function() {
return categoryRepository
.findOneById(1, { alias: "category", leftJoinAndSelect: { post: "category.post" } })
.then(category => loadedCategory = category);
.then(category => loadedCategory = category!);
});
it("should save successfully", function () {

View File

@ -34,7 +34,7 @@ describe("insertion", function() {
savedPost.should.be.equal(newPost);
expect(savedPost.id).not.to.be.empty;
const insertedPost = await postRepository.findOneById(savedPost.id);
const insertedPost = (await postRepository.findOneById(savedPost.id))!;
insertedPost.should.be.eql({
id: savedPost.id,
text: "Hello post",

View File

@ -265,8 +265,8 @@ describe("many-to-many", function() {
.where("p.id=:id", { id: savedPost.id })
.getSingleResult()
.then(loadedPost => {
loadedPost.categories.splice(0, 1);
return postRepository.persist(loadedPost);
loadedPost!.categories.splice(0, 1);
return postRepository.persist(loadedPost!);
}).then(updatedPost => {
return postCategoryRepository.find({ name : "technology" });
}).then(foundCategory => {
@ -355,10 +355,10 @@ describe("many-to-many", function() {
.leftJoinAndSelect("details.posts", "posts")
.where("details.id=:id")
.setParameter("id", details.id)
.getSingleResult();
.getSingleResult()!;
}).then(reloadedDetails => {
expect(reloadedDetails).not.to.be.empty;
expect(reloadedDetails.posts).to.be.empty;
expect(reloadedDetails!.posts).to.be.empty;
});
});
});

View File

@ -51,8 +51,8 @@ describe("github issues > #58 relations with multiple primary keys", () => {
.innerJoinAndSelect("postCategory.category", "category")
.getSingleResult();
expect(loadedPost).not.to.be.empty;
loadedPost.should.be.eql({
expect(loadedPost!).not.to.be.empty;
loadedPost!.should.be.eql({
id: 1,
title: "Hello Post #1",
categories: [{

View File

@ -36,14 +36,14 @@ describe("github issues > #70 cascade deleting works incorrect", () => {
const loadedPost = await connection.entityManager
.createQueryBuilder(Post, "post")
.innerJoinAndSelect("post.categories", "categories")
.getSingleResult();
.getSingleResult()!;
const loadedCategories = await connection.entityManager
.createQueryBuilder(Category, "category")
.getResults();
expect(loadedPost).not.to.be.empty;
loadedPost.should.be.eql({
expect(loadedPost!).not.to.be.empty;
loadedPost!.should.be.eql({
id: 1,
title: "Hello Post #1",
categories: [{

View File

@ -38,7 +38,7 @@ describe("github issues > #71 ManyToOne relation with custom column name persist
expect(kollektion).not.to.be.empty;
expect(loadedArtikel).not.to.be.empty;
loadedArtikel.should.be.eql({
loadedArtikel!.should.be.eql({
id: 1,
nummer: "1",
name: "artikel #1",