Skip to content

Commit

Permalink
Merge pull request #3888 from rustamwin/remove-unused-parameters
Browse files Browse the repository at this point in the history
Removed unused declarations from insert/update/delete methods
  • Loading branch information
pleerock committed Mar 24, 2019
2 parents 6363d8b + 2a8c0b1 commit b91a725
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ however since API is already quite stable we don't expect too much breaking chan
If we missed a note on some change or you have a questions on migrating from old version,
feel free to ask us and community.

## 0.2.15
## 0.2.16 (under development)

### Bug fixes

* removed unused parameters from `insert`, `update`, `delete` methods ([#3888](https://github.com/typeorm/typeorm/pull/3888))

### Features

## 0.2.15 (2019-03-14)

### Bug fixes

Expand Down
6 changes: 3 additions & 3 deletions src/entity-manager/EntityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ export class EntityManager {
* Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.
* You can execute bulk inserts using this method.
*/
async insert<Entity>(target: ObjectType<Entity>|EntitySchema<Entity>|string, entity: QueryDeepPartialEntity<Entity>|(QueryDeepPartialEntity<Entity>[]), options?: SaveOptions): Promise<InsertResult> {
async insert<Entity>(target: ObjectType<Entity>|EntitySchema<Entity>|string, entity: QueryDeepPartialEntity<Entity>|(QueryDeepPartialEntity<Entity>[])): Promise<InsertResult> {

// TODO: Oracle does not support multiple values. Need to create another nice solution.
if (this.connection.driver instanceof OracleDriver && entity instanceof Array) {
Expand All @@ -495,7 +495,7 @@ export class EntityManager {
* Does not check if entity exist in the database.
* Condition(s) cannot be empty.
*/
update<Entity>(target: ObjectType<Entity>|EntitySchema<Entity>|string, criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|any, partialEntity: QueryDeepPartialEntity<Entity>, options?: SaveOptions): Promise<UpdateResult> {
update<Entity>(target: ObjectType<Entity>|EntitySchema<Entity>|string, criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|any, partialEntity: QueryDeepPartialEntity<Entity>): Promise<UpdateResult> {

// if user passed empty criteria or empty list of criterias, then throw an error
if (criteria === undefined ||
Expand Down Expand Up @@ -533,7 +533,7 @@ export class EntityManager {
* Does not check if entity exist in the database.
* Condition(s) cannot be empty.
*/
delete<Entity>(targetOrEntity: ObjectType<Entity>|EntitySchema<Entity>|string, criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|any, options?: RemoveOptions): Promise<DeleteResult> {
delete<Entity>(targetOrEntity: ObjectType<Entity>|EntitySchema<Entity>|string, criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|any): Promise<DeleteResult> {

// if user passed empty criteria or empty list of criterias, then throw an error
if (criteria === undefined ||
Expand Down
8 changes: 3 additions & 5 deletions src/entity-manager/MongoEntityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ import { FindOneOptions } from "../find-options/FindOneOptions";
import { PlatformTools } from "../platform/PlatformTools";
import { DeepPartial } from "../common/DeepPartial";
import { QueryDeepPartialEntity } from "../query-builder/QueryPartialEntity";
import { SaveOptions } from "../repository/SaveOptions";
import { InsertResult } from "../query-builder/result/InsertResult";
import { UpdateResult } from "../query-builder/result/UpdateResult";
import { RemoveOptions } from "../repository/RemoveOptions";
import { DeleteResult } from "../query-builder/result/DeleteResult";
import { EntityMetadata } from "../metadata/EntityMetadata";
import { EntitySchema, FindConditions } from "../index";
Expand Down Expand Up @@ -196,7 +194,7 @@ export class MongoEntityManager extends EntityManager {
* Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.
* You can execute bulk inserts using this method.
*/
async insert<Entity>(target: ObjectType<Entity> | EntitySchema<Entity> | string, entity: QueryDeepPartialEntity<Entity> | QueryDeepPartialEntity<Entity>[], options?: SaveOptions): Promise<InsertResult> {
async insert<Entity>(target: ObjectType<Entity> | EntitySchema<Entity> | string, entity: QueryDeepPartialEntity<Entity> | QueryDeepPartialEntity<Entity>[]): Promise<InsertResult> {
// todo: convert entity to its database name
const result = new InsertResult();
if (entity instanceof Array) {
Expand All @@ -222,7 +220,7 @@ export class MongoEntityManager extends EntityManager {
* Executes fast and efficient UPDATE query.
* Does not check if entity exist in the database.
*/
async update<Entity>(target: ObjectType<Entity> | EntitySchema<Entity> | string, criteria: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | FindConditions<Entity>, partialEntity: QueryDeepPartialEntity<Entity>, options?: SaveOptions): Promise<UpdateResult> {
async update<Entity>(target: ObjectType<Entity> | EntitySchema<Entity> | string, criteria: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | FindConditions<Entity>, partialEntity: QueryDeepPartialEntity<Entity>): Promise<UpdateResult> {
if (criteria instanceof Array) {
await Promise.all((criteria as any[]).map(criteriaItem => {
return this.update(target, criteriaItem, partialEntity);
Expand All @@ -242,7 +240,7 @@ export class MongoEntityManager extends EntityManager {
* Executes fast and efficient DELETE query.
* Does not check if entity exist in the database.
*/
async delete<Entity>(target: ObjectType<Entity> | EntitySchema<Entity> | string, criteria: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | FindConditions<Entity>, options?: RemoveOptions): Promise<DeleteResult> {
async delete<Entity>(target: ObjectType<Entity> | EntitySchema<Entity> | string, criteria: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | FindConditions<Entity>): Promise<DeleteResult> {
if (criteria instanceof Array) {
await Promise.all((criteria as any[]).map(criteriaItem => {
return this.delete(target, criteriaItem);
Expand Down
12 changes: 6 additions & 6 deletions src/repository/Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ export class Repository<Entity extends ObjectLiteral> {
* Executes fast and efficient INSERT query.
* Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.
*/
insert(entity: QueryDeepPartialEntity<Entity>|(QueryDeepPartialEntity<Entity>[]), options?: SaveOptions): Promise<InsertResult> {
return this.manager.insert(this.metadata.target as any, entity, options);
insert(entity: QueryDeepPartialEntity<Entity>|(QueryDeepPartialEntity<Entity>[])): Promise<InsertResult> {
return this.manager.insert(this.metadata.target as any, entity);
}

/**
Expand All @@ -183,8 +183,8 @@ export class Repository<Entity extends ObjectLiteral> {
* Executes fast and efficient UPDATE query.
* Does not check if entity exist in the database.
*/
update(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>, partialEntity: QueryDeepPartialEntity<Entity>, options?: SaveOptions): Promise<UpdateResult> {
return this.manager.update(this.metadata.target as any, criteria as any, partialEntity, options);
update(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>, partialEntity: QueryDeepPartialEntity<Entity>): Promise<UpdateResult> {
return this.manager.update(this.metadata.target as any, criteria as any, partialEntity);
}

/**
Expand All @@ -193,8 +193,8 @@ export class Repository<Entity extends ObjectLiteral> {
* Executes fast and efficient DELETE query.
* Does not check if entity exist in the database.
*/
delete(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>, options?: RemoveOptions): Promise<DeleteResult> {
return this.manager.delete(this.metadata.target as any, criteria as any, options);
delete(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<DeleteResult> {
return this.manager.delete(this.metadata.target as any, criteria as any);
}

/**
Expand Down

0 comments on commit b91a725

Please sign in to comment.