Skip to content

Commit

Permalink
UIPQB-55: Regular expressions are incorrect for contains and starts_w…
Browse files Browse the repository at this point in the history
…ith operators (#63)
  • Loading branch information
UladzislauKutarkin authored Oct 12, 2023
1 parent 252a6eb commit 7ea3823
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@
* [UIPQB-48](https://issues.folio.org/browse/UIPQB-48) "Show columns" dropdown doesn't fit in the screen.
* [UIPQB-47](https://issues.folio.org/browse/UIPQB-47) 400 error blocks save or further action in query builder.
* [UIPQB-51](https://issues.folio.org/browse/UIPQB-51) Dropdown typeahead should use contains not starts with.
* [UIPQB-55](https://issues.folio.org/browse/UIPQB-55) Regular expressions are incorrect for contains and starts_with operators
2 changes: 1 addition & 1 deletion src/QueryBuilder/QueryBuilder/helpers/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const sourceToMongoQuery = (source) => {
const escapeRegex = (value) => {
const escapedValue = value.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&');

return `^${escapedValue}`;
return `${escapedValue}`;
};

source.forEach((item) => {
Expand Down
10 changes: 1 addition & 9 deletions src/QueryBuilder/QueryBuilder/helpers/query.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ describe('mongoQueryToSource()', () => {
operator: { options: expect.any(Array), current: OPERATORS.CONTAINS },
value: { current: 'abc' },
},
{
boolean: { options: booleanOptions, current: 'AND' },
field: { options: fieldOptions, current: 'user_full_name' },
operator: { options: expect.any(Array), current: OPERATORS.CONTAINS },
value: { current: 'abc' },
},
{
boolean: { options: booleanOptions, current: 'AND' },
field: { options: fieldOptions, current: 'languages' },
Expand All @@ -82,7 +76,6 @@ describe('mongoQueryToSource()', () => {
{ user_last_name: { $gte: 'value' } },
{ languages: { $in: ['value', 'value2'] } },
{ user_full_name: { $regex: 'abc' } },
{ user_full_name: { $regex: 'abc' } },
{ languages: { $nin: ['value', 'value2'] } },
],
};
Expand Down Expand Up @@ -122,8 +115,7 @@ describe('mongoQueryToSource()', () => {
{ user_last_name: { $lt: 10 } },
{ user_last_name: { $gte: 'value' } },
{ languages: { $in: ['value', 'value2'] } },
{ user_full_name: { $regex: '^abc' } },
{ user_full_name: { $regex: '^abc' } },
{ user_full_name: { $regex: 'abc' } },
{ languages: { $nin: ['value', 'value2'] } },
],
};
Expand Down

0 comments on commit 7ea3823

Please sign in to comment.