array_type_field_filter: Add new contains filter to search on Array type field by shubhisood · Pull Request #460 · loopbackio/loopback-connector-postgresql · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 72 additions & 7 deletions README.md
3 changes: 3 additions & 0 deletions lib/postgresql.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ PostgreSQL.prototype.buildExpression = function(columnName, operator,
const regexOperator = operatorValue.ignoreCase ? ' ~* ?' : ' ~ ?';
return new ParameterizedSQL(columnName + regexOperator,
[operatorValue.source]);
case 'contains':
return new ParameterizedSQL(columnName + ' @> array[' + operatorValue.map((v) => `'${v}'`) + ']::'
+ propertyDefinition.postgresql.dataType);
default:
// invoke the base implementation of `buildExpression`
return this.invokeSuper('buildExpression', columnName, operator,
Expand Down
28 changes: 23 additions & 5 deletions test/postgresql.test.js