[Sequelize] Fix types error with UpsertOptions requiring the returning option if they are defined at all (#25240)

* upsert should compile with options that dont include returning

* fix parens

* bump version for bugfix
This commit is contained in:
Nick Schultz
2018-04-24 16:17:23 -07:00
committed by Wesley Wigham
parent 959c2e2e35
commit 73619f74ff
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for Sequelize 4.27.9
// Type definitions for Sequelize 4.27.10
// Project: http://sequelizejs.com
// Definitions by: samuelneff <https://github.com/samuelneff>
// Peter Harris <https://github.com/codeanimal>
@@ -4006,7 +4006,7 @@ declare namespace sequelize {
* because SQLite always runs INSERT OR IGNORE + UPDATE, in a single query, so there is no way to know
* whether the row was inserted or not.
*/
upsert(values: TAttributes, options?: UpsertOptions & { returning: false | undefined }): Promise<boolean>;
upsert(values: TAttributes, options?: UpsertOptions & { returning?: false | undefined }): Promise<boolean>;
upsert(values: TAttributes, options?: UpsertOptions & { returning: true }): Promise<[TInstance, boolean]>;
insertOrUpdate(values: TAttributes, options?: UpsertOptions & { returning: false | undefined }): Promise<boolean>;
insertOrUpdate(values: TAttributes, options?: UpsertOptions & { returning: true }): Promise<[TInstance, boolean]>;
+1
View File
@@ -1055,6 +1055,7 @@ findOrRetVal = User.findOrCreate( { where : { email : 'unique.email.@d.com', com
findOrRetVal = User.findOrCreate( { where : { objectId : 1 }, defaults : { bool : false } } );
let upsertPromiseNoOptions: Bluebird<boolean> = User.upsert( { id : 42, username : 'doe', foo : s.fn( 'upper', 'mixedCase2' ) } );
let upsertPromiseWithNonReturningOptions: Bluebird<boolean> = User.upsert( { id : 42, username : 'doe', foo : s.fn( 'upper', 'mixedCase2' ) }, { logging: true } );
let upsertPromiseReturning: Bluebird<[AnyInstance, boolean]> = User.upsert( { id : 42, username : 'doe', foo : s.fn( 'upper', 'mixedCase2' ) }, { returning: true } );
let upsertPromiseNotReturning: Bluebird<boolean> = User.upsert( { id : 42, username : 'doe', foo : s.fn( 'upper', 'mixedCase2' ) }, { returning: false } );