Skip to content

Commit 5b9fdd3

Browse files
authored
fix: array contains fail when postgres because add cardinality (#986)
1 parent 1883c2d commit 5b9fdd3

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/filter.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,11 @@ export function addWhereCondition<T>(qb: SelectQueryBuilder<T>, column: string,
178178
const parameters = fixQueryParam(alias, columnNamePerIteration, columnFilter, condition, {
179179
[columnNamePerIteration]: columnFilter.findOperator.value,
180180
})
181-
if (isArray && condition.parameters?.length && !['not', 'isNull'].includes(condition.operator)) {
181+
if (
182+
isArray &&
183+
condition.parameters?.length &&
184+
!['not', 'isNull', 'arrayContains'].includes(condition.operator)
185+
) {
182186
condition.parameters[0] = `cardinality(${condition.parameters[0]})`
183187
}
184188
if (columnFilter.comparator === FilterComparator.OR) {

src/paginate.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,6 +3005,7 @@ describe('paginate', () => {
30053005
${'$btw'} | ${'1,2'} | ${[1, 2]}
30063006
${'$gte'} | ${2} | ${[0, 1]}
30073007
${'$gt'} | ${2} | ${[0]}
3008+
${'$contains'} | ${'brown'} | ${[0, 1]}
30083009
`('with $operator operator', async ({ operator, data, expectedIndexes }) => {
30093010
const config: PaginateConfig<CatHairEntity> = {
30103011
sortableColumns: ['id'],

0 commit comments

Comments
 (0)