Permalink
Browse files

fix(v2): remove the implicit wildcards

  • Loading branch information...
j-white committed Jun 26, 2017
1 parent 5a10ec8 commit 49400106290806b844ac6d0c2b9f279c3a4cf9f7
Showing with 9 additions and 11 deletions.
  1. +0 −2 src/dao/V2FilterProcessor.ts
  2. +9 −9 test/dao/V2FilterProcessor.spec.ts
@@ -59,8 +59,6 @@ export class V2FilterProcessor implements IFilterProcessor {
case Comparators.NULL:
case Comparators.NOTNULL:
return restriction.value === undefined ? V2FilterProcessor.NULL_VALUE : restriction.value;
case Comparators.LIKE:
return '*' + restriction.value + '*';
default:
return restriction.value;
}
@@ -70,25 +70,25 @@ describe('V2FilterProcessor', () => {
filter.withOrRestriction(new Restriction('id', Comparators.NE, 0));
expect(toSearch(filter)).toEqual('severity==5,id!=0');
});
it('alarm filter: uei like somethingWentWrong', () => {
it('alarm filter: uei like *somethingWentWrong', () => {
const filter = new Filter<OnmsAlarm>();
filter.withOrRestriction(new Restriction('uei', Comparators.LIKE, 'somethingWentWrong'));
expect(toSearch(filter)).toEqual('uei==*somethingWentWrong*');
filter.withOrRestriction(new Restriction('uei', Comparators.LIKE, '*somethingWentWrong'));
expect(toSearch(filter)).toEqual('uei==*somethingWentWrong');
});
it('alarm filter: severity=OnmsSeverity.MINOR AND id!=0 OR uei like somethingWentWrong', () => {
it('alarm filter: severity=OnmsSeverity.MINOR AND id!=0 OR uei like *somethingWentWrong', () => {
const filter = new Filter<OnmsAlarm>();
filter.withOrRestriction(new Restriction('severity', Comparators.EQ, Severities.MINOR));
filter.withAndRestriction(new Restriction('id', Comparators.NE, 0));
filter.withOrRestriction(new Restriction('uei', Comparators.LIKE, 'somethingWentWrong'));
expect(toSearch(filter)).toEqual('severity==5;id!=0,uei==*somethingWentWrong*');
filter.withOrRestriction(new Restriction('uei', Comparators.LIKE, '*somethingWentWrong'));
expect(toSearch(filter)).toEqual('severity==5;id!=0,uei==*somethingWentWrong');
});
it('alarm filter: id!=0 AND (severity=OnmsSeverity.MINOR OR uei like somethingWentWrong)', () => {
it('alarm filter: id!=0 AND (severity=OnmsSeverity.MINOR OR uei like *somethingWentWrong)', () => {
const filter = new Filter<OnmsAlarm>()
.withOrRestriction(new Restriction('id', Comparators.NE, 0))
.withAndRestriction(new NestedRestriction()
.withOrRestriction(new Restriction('severity', Comparators.EQ, Severities.MINOR))
.withOrRestriction(new Restriction('uei', Comparators.LIKE, 'somethingWentWrong')),
.withOrRestriction(new Restriction('uei', Comparators.LIKE, '*somethingWentWrong')),
);
expect(toSearch(filter)).toEqual('id!=0;(severity==5,uei==*somethingWentWrong*)');
expect(toSearch(filter)).toEqual('id!=0;(severity==5,uei==*somethingWentWrong)');
});
});

0 comments on commit 4940010

Please sign in to comment.