Skip to content

Commit 6fe784c

Browse files
yeshamavanisamarpanB
authored andcommitted
fix(sequelize): add support for extended operators in sequelize
postgres supports extended operators but missing in sequelize fix #10272 Signed-off-by: Yesha Mavani <[email protected]>
1 parent 89cccab commit 6fe784c

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

extensions/sequelize/src/sequelize/operator-translation.ts

+2
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ export const operatorTranslations: {
2929
regexp: Op.regexp,
3030
and: Op.and,
3131
or: Op.or,
32+
match: Op.match,
33+
contains: Op.contains,
3234
};

extensions/sequelize/src/sequelize/sequelize.repository.base.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,14 @@ export class SequelizeCrudRepository<
914914
['Array', 'array'].includes(definition[propName].type.toString())
915915
) {
916916
// Postgres only
917-
dataType = DataTypes.ARRAY(DataTypes.INTEGER);
917+
const stringTypeArray =
918+
definition[propName].itemType === String ||
919+
['String', 'string'].includes(
920+
definition[propName].itemType?.toString() || '',
921+
);
922+
dataType = stringTypeArray
923+
? DataTypes.ARRAY(DataTypes.STRING)
924+
: DataTypes.ARRAY(DataTypes.INTEGER);
918925
}
919926

920927
if (

packages/filter/src/query.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ export type Operators =
3939
| 'nlike' // NOT LIKE
4040
| 'ilike' // ILIKE'
4141
| 'nilike' // NOT ILIKE
42-
| 'regexp'; // REGEXP'
42+
| 'regexp' // REGEXP'
43+
| 'match' // match
44+
| 'contains'; // for array
4345

4446
/**
4547
* Matching predicate comparison

0 commit comments

Comments
 (0)