From e64381c9e8db384f4b3f3b5dc0d5edd09162a80a Mon Sep 17 00:00:00 2001 From: Meykel Gruel Date: Wed, 16 Aug 2017 11:16:32 +0200 Subject: [PATCH] merged changes for Nick Mueller from v3 to v4 Tickets: * https://github.com/DefinitelyTyped/DefinitelyTyped/issues/19014 --- types/sequelize/index.d.ts | 3 ++- types/sequelize/sequelize-tests.ts | 34 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index 7524162a1b..952b3a7aea 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -5,6 +5,7 @@ // Ivan Drinchev // Brendan Abolivier // Patsakol Tangjitcharoenchai +// Nick Mueller // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -4868,7 +4869,7 @@ declare namespace sequelize { * (field name), `length` (create a prefix index of length chars), `order` (the direction the column * should be sorted in), `collate` (the collation (sort order) for the column) */ - fields?: Array; + fields?: Array; /** * Method the index should use, for example 'gin' index. diff --git a/types/sequelize/sequelize-tests.ts b/types/sequelize/sequelize-tests.ts index aa14079e9d..4423ed9246 100644 --- a/types/sequelize/sequelize-tests.ts +++ b/types/sequelize/sequelize-tests.ts @@ -1627,6 +1627,40 @@ s.define( 'TriggerTest', { hasTrigger : true } ); +s.define('DefineOptionsIndexesTest', { + id: { + type: Sequelize.INTEGER, + autoIncrement: true, + primaryKey: true, + validate: { + min: 1 + } + }, + email: { + allowNull: false, + type: Sequelize.STRING(255), + set: function (val) { + if (typeof val === "string") { + val = val.toLowerCase(); + } else { + throw new Error("email must be a string"); + } + this.setDataValue("email", val); + } + } +}, { + timestamps: false, + indexes: [ + { + name: "DefineOptionsIndexesTest_lower_email", + unique: true, + fields: [ + Sequelize.fn("LOWER", Sequelize.col("email")) + ] + } + ] +} ); + // // Transaction // ~~~~~~~~~~~~~