From e2d28ef5511a73dee9616877425a77487fd719f3 Mon Sep 17 00:00:00 2001 From: Jordan Pollard Date: Wed, 28 Aug 2019 13:47:58 -0400 Subject: [PATCH 1/5] fix(types): change raw query return type to [unknown[],unknown] --- types/lib/sequelize.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/lib/sequelize.d.ts b/types/lib/sequelize.d.ts index e86d456fc089..86646c27e238 100644 --- a/types/lib/sequelize.d.ts +++ b/types/lib/sequelize.d.ts @@ -1185,7 +1185,7 @@ export class Sequelize extends Hooks { options: QueryOptionsWithModel ): Promise; public query(sql: string | { query: string; values: unknown[] }, options: QueryOptionsWithType): Promise; - public query(sql: string | { query: string; values: unknown[] }, options?: QueryOptions | QueryOptionsWithType): Promise; + public query(sql: string | { query: string; values: unknown[] }, options?: QueryOptions | QueryOptionsWithType): Promise<[unknown[], unknown]>; /** * Get the fn for random based on the dialect From 9686e17bf4cc005fa9b5f99923f80ad9d8338b2b Mon Sep 17 00:00:00 2001 From: Jordan Pollard Date: Wed, 28 Aug 2019 18:48:51 -0400 Subject: [PATCH 2/5] fix(types): increase test coverage for raw query return type --- types/test/sequelize.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/types/test/sequelize.ts b/types/test/sequelize.ts index 216db5b181cc..efee9b5b033c 100644 --- a/types/test/sequelize.ts +++ b/types/test/sequelize.ts @@ -6,7 +6,7 @@ Sequelize.useCLS({ export const sequelize = new Sequelize({ hooks: { - afterConnect: (connection, config: Config) => { + afterConnect: async (connection:, config: Config) => { // noop } }, @@ -53,4 +53,9 @@ class Model1 extends Model{} class Model2 extends Model{} const myModel: typeof Model1 = sequelize.models.asd; myModel.hasOne(Model2) -myModel.findAll(); \ No newline at end of file +myModel.findAll(); + +const result = await sequelize.query('SELECT * FROM `user`'); +const data = result[0]; +const arraysOnly = (a: any[]) => a; +arraysOnly(data); From 613779022341f7d01f472e50b4b5382ecb6a08b9 Mon Sep 17 00:00:00 2001 From: Jordan Pollard Date: Wed, 28 Aug 2019 18:50:44 -0400 Subject: [PATCH 3/5] fix(types): removed unecessary test code --- types/test/sequelize.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/test/sequelize.ts b/types/test/sequelize.ts index efee9b5b033c..8bbc516d2723 100644 --- a/types/test/sequelize.ts +++ b/types/test/sequelize.ts @@ -6,7 +6,7 @@ Sequelize.useCLS({ export const sequelize = new Sequelize({ hooks: { - afterConnect: async (connection:, config: Config) => { + afterConnect: (connection, config: Config) => { // noop } }, From 861530a2534543d96ef520101e00a787c801294a Mon Sep 17 00:00:00 2001 From: Jordan Pollard Date: Wed, 28 Aug 2019 19:23:10 -0400 Subject: [PATCH 4/5] fix(types): fixed test code --- types/test/sequelize.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/types/test/sequelize.ts b/types/test/sequelize.ts index 8bbc516d2723..767d51ce3d3d 100644 --- a/types/test/sequelize.ts +++ b/types/test/sequelize.ts @@ -55,7 +55,8 @@ const myModel: typeof Model1 = sequelize.models.asd; myModel.hasOne(Model2) myModel.findAll(); -const result = await sequelize.query('SELECT * FROM `user`'); -const data = result[0]; -const arraysOnly = (a: any[]) => a; -arraysOnly(data); +sequelize.query('SELECT * FROM `user`').then(result => { + const data = result[0]; + const arraysOnly = (a: any[]) => a; + arraysOnly(data); +}); From 9314d070bc65e31c13925bb94f61f844fad5c971 Mon Sep 17 00:00:00 2001 From: Jordan Pollard Date: Thu, 29 Aug 2019 16:38:46 -0400 Subject: [PATCH 5/5] fix(types): making test more explicit --- types/test/sequelize.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/test/sequelize.ts b/types/test/sequelize.ts index 767d51ce3d3d..4d7a4bfd5a3d 100644 --- a/types/test/sequelize.ts +++ b/types/test/sequelize.ts @@ -1,4 +1,4 @@ -import { Config, Sequelize, Model } from 'sequelize'; +import { Config, Sequelize, Model, QueryTypes } from 'sequelize'; import { Fn } from '../lib/utils'; Sequelize.useCLS({ @@ -55,7 +55,7 @@ const myModel: typeof Model1 = sequelize.models.asd; myModel.hasOne(Model2) myModel.findAll(); -sequelize.query('SELECT * FROM `user`').then(result => { +sequelize.query('SELECT * FROM `user`', { type: QueryTypes.RAW }).then(result => { const data = result[0]; const arraysOnly = (a: any[]) => a; arraysOnly(data);