diff --git a/types/lib/model.d.ts b/types/lib/model.d.ts index 137632f5237c..d6a0862f5138 100644 --- a/types/lib/model.d.ts +++ b/types/lib/model.d.ts @@ -146,18 +146,18 @@ export interface WhereOperators { */ /** Example: `[Op.eq]: 6,` becomes `= 6` */ - [Op.eq]?: null | boolean | string | number | Literal | WhereOperators; + [Op.eq]?: null | boolean | string | number | Literal | WhereOperators | Col; [Op.any]?: readonly (string | number | Literal)[] | Literal; /** Example: `[Op.gte]: 6,` becomes `>= 6` */ - [Op.gte]?: number | string | Date | Literal; + [Op.gte]?: number | string | Date | Literal | Col; /** Example: `[Op.lt]: 10,` becomes `< 10` */ - [Op.lt]?: number | string | Date | Literal; + [Op.lt]?: number | string | Date | Literal | Col; /** Example: `[Op.lte]: 10,` becomes `<= 10` */ - [Op.lte]?: number | string | Date | Literal; + [Op.lte]?: number | string | Date | Literal | Col; /** Example: `[Op.match]: Sequelize.fn('to_tsquery', 'fat & rat')` becomes `@@ to_tsquery('fat & rat')` */ [Op.match]?: Fn; @@ -225,7 +225,7 @@ export interface WhereOperators { [Op.contained]?: readonly (string | number)[] | Rangable; /** Example: `[Op.gt]: 6,` becomes `> 6` */ - [Op.gt]?: number | string | Date | Literal; + [Op.gt]?: number | string | Date | Literal | Col; /** * PG only diff --git a/types/test/where.ts b/types/test/where.ts index cd178333f205..c52467a895be 100644 --- a/types/test/where.ts +++ b/types/test/where.ts @@ -45,10 +45,15 @@ expectTypeOf({ expectTypeOf({ [Op.eq]: 6, // = 6 + [Op.eq]: Sequelize.col('SOME_COL'), // = [Op.gt]: 6, // > 6 + [Op.gt]: Sequelize.col('SOME_COL'), // > [Op.gte]: 6, // >= 6 + [Op.gte]: Sequelize.col('SOME_COL'), // >= [Op.lt]: 10, // < 10 + [Op.lt]: Sequelize.col('SOME_COL'), // < [Op.lte]: 10, // <= 10 + [Op.lte]: Sequelize.col('SOME_COL'), // <= [Op.ne]: 20, // != 20 [Op.not]: true, // IS NOT TRUE [Op.is]: null, // IS NULL @@ -222,12 +227,18 @@ MyModel.findAll({ where: { id: { // casting here to check a missing operator is not accepted as field name + [Op.eq]: 6, // id = 6 + [Op.eq]: Sequelize.col('SOME_COL'), // id = [Op.and]: { a: 5 }, // AND (a = 5) [Op.or]: [{ a: 5 }, { a: 6 }], // (a = 5 OR a = 6) [Op.gt]: 6, // id > 6 + [Op.gt]: Sequelize.col('SOME_COL'), // id > [Op.gte]: 6, // id >= 6 + [Op.gte]: Sequelize.col('SOME_COL'), // id >= [Op.lt]: 10, // id < 10 + [Op.lt]: Sequelize.col('SOME_COL'), // id < [Op.lte]: 10, // id <= 10 + [Op.lte]: Sequelize.col('SOME_COL'), // id <= [Op.ne]: 20, // id != 20 [Op.between]: [6, 10] || [new Date(), new Date()] || ["2020-01-01", "2020-12-31"], // BETWEEN 6 AND 10 [Op.notBetween]: [11, 15], // NOT BETWEEN 11 AND 15