fixed broken tests used deprecated removed methods

This commit is contained in:
Umed Khudoiberdiev 2017-09-27 12:12:42 +05:00
parent 9d4f1cf049
commit e834336730
18 changed files with 60 additions and 60 deletions

View File

@ -333,7 +333,7 @@ createConnection(/*...*/).then(connection => {
photo.isPublished = true;
connection.manager
.persist(photo)
.save(photo)
.then(photo => {
console.log("Photo has been saved");
});
@ -358,7 +358,7 @@ createConnection(/*...*/).then(async connection => {
photo.views = 1;
photo.isPublished = true;
await connection.manager.persist(photo);
await connection.manager.save(photo);
console.log("Photo has been saved");
}).catch(error => console.log(error));
@ -403,7 +403,7 @@ createConnection(/*...*/).then(async connection => {
let photoRepository = connection.getRepository(Photo);
await photoRepository.persist(photo);
await photoRepository.save(photo);
console.log("Photo has been saved");
let savedPhotos = await photoRepository.find();
@ -458,7 +458,7 @@ createConnection(/*...*/).then(async connection => {
/*...*/
let photoToUpdate = await photoRepository.findOneById(1);
photoToUpdate.name = "Me, my friends and polar bears";
await photoRepository.persist(photoToUpdate);
await photoRepository.save(photoToUpdate);
}).catch(error => console.log(error));
```
@ -577,10 +577,10 @@ createConnection(/*...*/).then(async connection => {
let metadataRepository = connection.getRepository(PhotoMetadata);
// 先来把photo存到数据库
await photoRepository.persist(photo);
await photoRepository.save(photo);
// photo存完了再存下photo的元信息
await metadataRepository.persist(metadata);
await metadataRepository.save(metadata);
// 搞定
console.log("metadata is saved, and relation between metadata and photo is created in the database too");
@ -730,7 +730,7 @@ createConnection(options).then(async connection => {
let photoRepository = connection.getRepository(Photo);
// 存photo
await photoRepository.persist(photo);
await photoRepository.save(photo);
// photo metadata也自动存上了
console.log("Photo is saved, photo metadata is saved too.")
@ -903,8 +903,8 @@ photo2.albums = [album2];
let photoRepository = connection.getRepository(Photo);
// 依次存储photos由于cascadealbums也同样会自动存起来
await photoRepository.persist(photo1);
await photoRepository.persist(photo2);
await photoRepository.save(photo1);
await photoRepository.save(photo2);
console.log("Both photos have been saved");
```

View File

@ -40,7 +40,7 @@ typeorm.createConnection({
};
var postRepository = connection.getRepository("Post");
postRepository.persist(post)
postRepository.save(post)
.then(function(savedPost) {
console.log("Post has been saved: ", savedPost);
console.log("Now lets load all posts: ");

View File

@ -75,7 +75,7 @@ createConnection(options).then(connection => {
post.text = "Hello world of post#4";
post.categories = [category2, category1];
post.images.push(image);
return postRepository.persist(post);
return postRepository.save(post);
})
.then(() => qb.getSingleResult())
@ -173,7 +173,7 @@ createConnection(options).then(connection => {
//post.details = details;
postRepository
.persist(post)
.save(post)
.then(post => console.log("Post has been saved"))
.catch(error => console.log("Cannot save. Error: ", error));*/

View File

@ -64,7 +64,7 @@ createConnection(options).then(connection => {
// let secondPost = postRepository.create();
// secondPost.text = "Second post";
// secondPost.title = "About second post";
// return authorRepository.persist(author);
// return authorRepository.save(author);
}).then(post => {
console.log("Loaded posts: ", post);
@ -72,7 +72,7 @@ createConnection(options).then(connection => {
/* posts[0].title = "should be updated second post";
return author.posts.then(posts => {
return authorRepository.persist(author);
return authorRepository.save(author);
});
})
.then(updatedAuthor => {
@ -85,7 +85,7 @@ createConnection(options).then(connection => {
console.log("Now lets delete a post");
posts[0].author = Promise.resolve(null);
posts[1].author = Promise.resolve(null);
return postRepository.persist(posts[0]);
return postRepository.save(posts[0]);
})
.then(posts => {
console.log("Two post's author has been removed.");
@ -105,7 +105,7 @@ createConnection(options).then(connection => {
category2
]);
return postRepository.persist(post);
return postRepository.save(post);
})
.then(posts => {
console.log("Post has been saved with its categories. ");
@ -118,7 +118,7 @@ createConnection(options).then(connection => {
return posts[0].categories.then(categories => {
categories.splice(0, 1);
// console.log(posts[0]);
return postRepository.persist(posts[0]);
return postRepository.save(posts[0]);
});
})*/
.then(posts => {

View File

@ -71,7 +71,7 @@ createConnection(options).then(connection => {
/* posts[0].title = "should be updated second post";
return author.posts.then(posts => {
return authorRepository.persist(author);
return authorRepository.save(author);
});
})
.then(updatedAuthor => {
@ -84,7 +84,7 @@ createConnection(options).then(connection => {
console.log("Now lets delete a post");
posts[0].author = Promise.resolve(null);
posts[1].author = Promise.resolve(null);
return postRepository.persist(posts[0]);
return postRepository.save(posts[0]);
})
.then(posts => {
console.log("Two post's author has been removed.");
@ -104,7 +104,7 @@ createConnection(options).then(connection => {
category2
]);
return postRepository.persist(post);
return postRepository.save(post);
})
.then(posts => {
console.log("Post has been saved with its categories. ");
@ -117,7 +117,7 @@ createConnection(options).then(connection => {
return posts[0].categories.then(categories => {
categories.splice(0, 1);
// console.log(posts[0]);
return postRepository.persist(posts[0]);
return postRepository.save(posts[0]);
});
})*/
.then(posts => {

View File

@ -102,9 +102,9 @@ createConnection(options).then(connection => {
childChildCategory2.parentCategory = childCategory2;
return categoryRepository
.persist(childChildCategory1)
.save(childChildCategory1)
.then(category => {
return categoryRepository.persist(childChildCategory2);
return categoryRepository.save(childChildCategory2);
})
.then(category => {
console.log("Categories has been saved. Lets load them now.");

View File

@ -65,7 +65,7 @@ createConnection(options).then(async connection => {
homesitter.numberOfKids = 5;
console.log("saving the homesitter: ");
await homesitterRepository.persist(homesitter);
await homesitterRepository.save(homesitter);
console.log("homesitter has been saved: ", homesitter);
console.log("now loading the homesitter: ");
@ -82,7 +82,7 @@ createConnection(options).then(async connection => {
student.faculty = "computer science";
console.log("saving the student: ");
await studentRepository.persist(student);
await studentRepository.save(student);
console.log("student has been saved: ", student);
console.log("now loading the student: ");

View File

@ -295,7 +295,7 @@ export class EntityManager {
const metadata = this.connection.getMetadata(entityTarget);
const databaseEntityLoader = new SubjectBuilder(this.connection, queryRunner);
await databaseEntityLoader.persist(entity, metadata);
await databaseEntityLoader.save(entity, metadata);
const executor = new SubjectOperationExecutor(this.connection, transactionEntityManager, queryRunner, databaseEntityLoader.operateSubjects);
executors.push(executor);
@ -306,7 +306,7 @@ export class EntityManager {
const metadata = this.connection.getMetadata(finalTarget);
const databaseEntityLoader = new SubjectBuilder(this.connection, queryRunner);
await databaseEntityLoader.persist(entity, metadata);
await databaseEntityLoader.save(entity, metadata);
const executor = new SubjectOperationExecutor(this.connection, transactionEntityManager, queryRunner, databaseEntityLoader.operateSubjects);
executors.push(executor);

View File

@ -168,7 +168,7 @@ describe("ConnectionManager", () => {
// create connection, save post and close connection
let connection = await connectionManager.createAndConnect(options);
const post = new Post(1, "Hello post");
await connection.manager.persist(post);
await connection.manager.save(post);
await connection.close();
// recreate connection and find previously saved post
@ -191,7 +191,7 @@ describe("ConnectionManager", () => {
// create connection, save post and close connection
let connection = await connectionManager.createAndConnect(options);
const post = new Post(1, "Hello post");
await connection.manager.persist(post);
await connection.manager.save(post);
await connection.close();
// recreate connection and find previously saved post

View File

@ -27,7 +27,7 @@ describe("database schema > mssql-parameters", () => {
post1.name = "Post #1";
post1.category = "posts";
post1.text = "This is post";
await postRepository.persist(post1);
await postRepository.save(post1);
let loadedPost1 = (await postRepository.findOneById(1))!;
@ -38,7 +38,7 @@ describe("database schema > mssql-parameters", () => {
loadedPost1.name = "Updated Post #1";
loadedPost1.text = "This is updated post";
await postRepository.persist(loadedPost1);
await postRepository.save(loadedPost1);
loadedPost1 = (await postRepository.findOneById(1))!;
loadedPost1.name.should.be.equal("Updated Post #1");

View File

@ -67,7 +67,7 @@ describe("persistence > cascade operations", () => {
await connection.manager.remove(post1);
// await connection.manager.persist(post1);
// await connection.manager.save(post1);
console.log("********************************************************");
@ -84,25 +84,25 @@ describe("persistence > cascade operations", () => {
// posts[0].category = null; // todo: uncomment to check remove
console.log("removing post's category: ", posts[0]);
await connection.manager.persist(posts[0]);*/
await connection.manager.save(posts[0]);*/
/* await connection.manager.persist([photo1, photo2]);
/* await connection.manager.save([photo1, photo2]);
post1.photos = [photo1];
await connection.manager.persist(post1);
await connection.manager.save(post1);
console.log("********************************************************");
console.log("********************************************************");
post1.photos = [photo1, photo2];
await connection.manager.persist(post1);
await connection.manager.save(post1);
console.log("********************************************************");
console.log("********************************************************");
post1.title = "Updated Post";
await connection.manager.persist(post1);*/
await connection.manager.save(post1);*/
})));

View File

@ -58,25 +58,25 @@ describe.skip("persistence > insert operations", () => {
// posts[0].category = null; // todo: uncomment to check remove
console.log("removing post's category: ", posts[0]);
await connection.manager.persist(posts[0]);*/
await connection.manager.save(posts[0]);*/
/* await connection.manager.persist([photo1, photo2]);
/* await connection.manager.save([photo1, photo2]);
post1.photos = [photo1];
await connection.manager.persist(post1);
await connection.manager.save(post1);
console.log("********************************************************");
console.log("********************************************************");
post1.photos = [photo1, photo2];
await connection.manager.persist(post1);
await connection.manager.save(post1);
console.log("********************************************************");
console.log("********************************************************");
post1.title = "Updated Post";
await connection.manager.persist(post1);*/
await connection.manager.save(post1);*/
})));

View File

@ -25,36 +25,36 @@ describe.skip("table-inheritance > class-table > basic-functionality", () => {
const student1 = new Student();
student1.name = "Alice";
student1.faculty = "Economics";
await connection.getRepository(Student).persist(student1);
await connection.getRepository(Student).save(student1);
const student2 = new Student();
student2.name = "Bob";
student2.faculty = "Programming";
await connection.getRepository(Student).persist(student2);
await connection.getRepository(Student).save(student2);
const teacher1 = new Teacher();
teacher1.name = "Mr. Garrison";
teacher1.specialization = "Geography";
teacher1.salary = 2000;
await connection.getRepository(Teacher).persist(teacher1);
await connection.getRepository(Teacher).save(teacher1);
const teacher2 = new Teacher();
teacher2.name = "Mr. Adler";
teacher2.specialization = "Mathematics";
teacher2.salary = 4000;
await connection.getRepository(Teacher).persist(teacher2);
await connection.getRepository(Teacher).save(teacher2);
const accountant1 = new Accountant();
accountant1.name = "Mr. Burns";
accountant1.department = "Bookkeeping";
accountant1.salary = 3000;
await connection.getRepository(Accountant).persist(accountant1);
await connection.getRepository(Accountant).save(accountant1);
const accountant2 = new Accountant();
accountant2.name = "Mr. Trump";
accountant2.department = "Director";
accountant2.salary = 5000;
await connection.getRepository(Accountant).persist(accountant2);
await connection.getRepository(Accountant).save(accountant2);
// -------------------------------------------------------------------------
// Select
@ -116,7 +116,7 @@ describe.skip("table-inheritance > class-table > basic-functionality", () => {
console.log(loadedStudent);
loadedStudent!.faculty = "Chemistry";
await connection.getRepository(Student).persist(loadedStudent!);
await connection.getRepository(Student).save(loadedStudent!);
loadedStudent = await connection.manager
.createQueryBuilder(Student, "student")
@ -134,7 +134,7 @@ describe.skip("table-inheritance > class-table > basic-functionality", () => {
.getOne();
loadedTeacher!.salary = 1000;
await connection.getRepository(Teacher).persist(loadedTeacher!);
await connection.getRepository(Teacher).save(loadedTeacher!);
loadedTeacher = await connection.manager
.createQueryBuilder(Teacher, "teacher")
@ -153,7 +153,7 @@ describe.skip("table-inheritance > class-table > basic-functionality", () => {
.getOne();
loadedAccountant!.salary = 1000;
await connection.getRepository(Accountant).persist(loadedAccountant!);
await connection.getRepository(Accountant).save(loadedAccountant!);
loadedAccountant = await connection.manager
.createQueryBuilder(Accountant, "accountant")

View File

@ -115,7 +115,7 @@ describe.skip("table-inheritance > single-table > basic-functionality", () => {
.getOne();
loadedStudent!.faculty = "Chemistry";
await connection.getRepository(Student).persist(loadedStudent!);
await connection.getRepository(Student).save(loadedStudent!);
loadedStudent = await connection.manager
.createQueryBuilder(Student, "student")
@ -133,7 +133,7 @@ describe.skip("table-inheritance > single-table > basic-functionality", () => {
.getOne();
loadedTeacher!.salary = 1000;
await connection.getRepository(Teacher).persist(loadedTeacher!);
await connection.getRepository(Teacher).save(loadedTeacher!);
loadedTeacher = await connection.manager
.createQueryBuilder(Teacher, "teacher")
@ -152,7 +152,7 @@ describe.skip("table-inheritance > single-table > basic-functionality", () => {
.getOne();
loadedAccountant!.salary = 1000;
await connection.getRepository(Accountant).persist(loadedAccountant!);
await connection.getRepository(Accountant).save(loadedAccountant!);
loadedAccountant = await connection.manager
.createQueryBuilder(Accountant, "accountant")

View File

@ -110,8 +110,8 @@ describe("closure-table", () => {
c1.childCategories.push(c12);
await categoryRepository.save(c1);
// await categoryRepository.persist(c11);
// await categoryRepository.persist(c12);
// await categoryRepository.save(c11);
// await categoryRepository.save(c12);
const roots = await categoryRepository.findRoots();
roots.should.be.eql([

View File

@ -4,7 +4,7 @@ import {Connection} from "../../../src/connection/Connection";
import {Post} from "./entity/Post";
import {expect} from "chai";
describe("github issues > #80 repository.persist fails when empty array is sent to the method", () => {
describe("github issues > #80 repository.save fails when empty array is sent to the method", () => {
let connections: Connection[];
before(async () => connections = await createTestingConnections({

View File

@ -4,7 +4,7 @@ import {Connection} from "../../../src/connection/Connection";
import {User} from "./entity/User";
import {UserCredential} from "./entity/UserCredential";
describe("github issues > #836 .persist won't update entity when it contains OneToOne relationship", () => {
describe("github issues > #836 .save won't update entity when it contains OneToOne relationship", () => {
let connections: Connection[];
before(async () => connections = await createTestingConnections({

View File

@ -103,8 +103,8 @@ describe("github issues > #904 Using closure tables without @TreeLevelColumn wil
c1.childCategories.push(c12);
await categoryRepository.save(c1);
// await categoryRepository.persist(c11);
// await categoryRepository.persist(c12);
// await categoryRepository.save(c11);
// await categoryRepository.save(c12);
const roots = await categoryRepository.findRoots();
roots.should.be.eql([