From 73619f74ffedb15ca332a4a934c58f75f5fd7310 Mon Sep 17 00:00:00 2001 From: Nick Schultz Date: Tue, 24 Apr 2018 19:17:23 -0400 Subject: [PATCH] [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 --- types/sequelize/index.d.ts | 4 ++-- types/sequelize/sequelize-tests.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index b6d1da1e55..37a0b46829 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -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 // Peter Harris @@ -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; + upsert(values: TAttributes, options?: UpsertOptions & { returning?: false | undefined }): Promise; upsert(values: TAttributes, options?: UpsertOptions & { returning: true }): Promise<[TInstance, boolean]>; insertOrUpdate(values: TAttributes, options?: UpsertOptions & { returning: false | undefined }): Promise; insertOrUpdate(values: TAttributes, options?: UpsertOptions & { returning: true }): Promise<[TInstance, boolean]>; diff --git a/types/sequelize/sequelize-tests.ts b/types/sequelize/sequelize-tests.ts index 1572b91c00..9c5eb13708 100644 --- a/types/sequelize/sequelize-tests.ts +++ b/types/sequelize/sequelize-tests.ts @@ -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 = User.upsert( { id : 42, username : 'doe', foo : s.fn( 'upper', 'mixedCase2' ) } ); +let upsertPromiseWithNonReturningOptions: Bluebird = 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 = User.upsert( { id : 42, username : 'doe', foo : s.fn( 'upper', 'mixedCase2' ) }, { returning: false } );