Skip to content

Commit

Permalink
fix: array contains fail when postgres because add cardinality (#986)
Browse files Browse the repository at this point in the history
  • Loading branch information
fpnuseis authored Sep 20, 2024
1 parent 1883c2d commit 5b9fdd3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ export function addWhereCondition<T>(qb: SelectQueryBuilder<T>, column: string,
const parameters = fixQueryParam(alias, columnNamePerIteration, columnFilter, condition, {
[columnNamePerIteration]: columnFilter.findOperator.value,
})
if (isArray && condition.parameters?.length && !['not', 'isNull'].includes(condition.operator)) {
if (
isArray &&
condition.parameters?.length &&
!['not', 'isNull', 'arrayContains'].includes(condition.operator)
) {
condition.parameters[0] = `cardinality(${condition.parameters[0]})`
}
if (columnFilter.comparator === FilterComparator.OR) {
Expand Down
1 change: 1 addition & 0 deletions src/paginate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3005,6 +3005,7 @@ describe('paginate', () => {
${'$btw'} | ${'1,2'} | ${[1, 2]}
${'$gte'} | ${2} | ${[0, 1]}
${'$gt'} | ${2} | ${[0]}
${'$contains'} | ${'brown'} | ${[0, 1]}
`('with $operator operator', async ({ operator, data, expectedIndexes }) => {
const config: PaginateConfig<CatHairEntity> = {
sortableColumns: ['id'],
Expand Down

0 comments on commit 5b9fdd3

Please sign in to comment.