diff --git a/package-lock.json b/package-lock.json index b455df3..a5917e3 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "spring-filter-query-builder", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "spring-filter-query-builder", - "version": "1.0.0", + "version": "1.0.1", "hasInstallScript": true, "license": "MIT", "devDependencies": { diff --git a/package.json b/package.json index abbc26b..aad3c3e 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "spring-filter-query-builder", - "version": "1.0.0", + "version": "1.0.1", "description": "", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", diff --git a/src/operators.ts b/src/operators.ts index 874cc63..2ad8f7b 100755 --- a/src/operators.ts +++ b/src/operators.ts @@ -26,7 +26,10 @@ export class Not extends Operator { } public toString(): string { - return `${this.operatorKeyWord} ${this.items[0].toString()}`; + if (this.items[0] instanceof Operator) { + return `${this.operatorKeyWord}${this.items[0].toString()}`; + } + return `${this.operatorKeyWord}(${this.items[0].toString()})`; } } diff --git a/test/operators.test.ts b/test/operators.test.ts index d953931..4bf4298 100644 --- a/test/operators.test.ts +++ b/test/operators.test.ts @@ -9,5 +9,9 @@ test('or', () => { }); test('not', () => { - expect(sfNot(sfOr([sfGt('id', 100), sfIsNull('category.order')])).toString()).toBe('not (id > 100 or category.order is null)'); + expect(sfNot(sfOr([sfGt('id', 100), sfIsNull('category.order')])).toString()).toBe('not(id > 100 or category.order is null)'); +}); + +test('not', () => { + expect(sfNot(sfGt('id', 100)).toString()).toBe('not(id > 100)'); });