不要怂,就是干,撸起袖子干!

Commit 93e80750 by milkwalk Committed by Sushant

fix(types): allow string and number arrays for contains operator (#11520)

1 parent 4ee3a27b
......@@ -535,6 +535,28 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
}, {
postgres: '"muscles" @> ARRAY[2,5]::INTEGER[]'
});
testsql('muscles', {
[Op.contains]: ['stringValue1', 'stringValue2', 'stringValue3']
}, {
postgres: '"muscles" @> ARRAY[\'stringValue1\',\'stringValue2\',\'stringValue3\']'
});
testsql('muscles', {
[Op.contained]: ['stringValue1', 'stringValue2', 'stringValue3']
}, {
postgres: '"muscles" <@ ARRAY[\'stringValue1\',\'stringValue2\',\'stringValue3\']'
});
testsql('muscles', {
[Op.contains]: ['stringValue1', 'stringValue2']
}, {
field: {
type: DataTypes.ARRAY(DataTypes.STRING)
}
}, {
postgres: '"muscles" @> ARRAY[\'stringValue1\',\'stringValue2\']::VARCHAR(255)[]'
});
});
describe('Op.overlap', () => {
......
......@@ -211,14 +211,14 @@ export interface WhereOperators {
*
* Example: `[Op.contains]: [1, 2]` becomes `@> [1, 2]`
*/
[Op.contains]?: Rangable;
[Op.contains]?: (string | number)[] | Rangable;
/**
* PG array contained by operator
*
* Example: `[Op.contained]: [1, 2]` becomes `<@ [1, 2]`
*/
[Op.contained]?: Rangable;
[Op.contained]?: (string | number)[] | Rangable;
/** Example: `[Op.gt]: 6,` becomes `> 6` */
[Op.gt]?: number | string | Date | Literal;
......
......@@ -114,6 +114,12 @@ where = {
},
},
},
meta2: {
[Op.contains]: ['stringValue1', 'stringValue2', 'stringValue3']
},
meta3: {
[Op.contains]: [1, 2, 3, 4]
},
};
// Relations / Associations
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!