From 95c52686af5c737b0ac0ab0f1817eaefe0b2f572 Mon Sep 17 00:00:00 2001 From: arafato Date: Wed, 14 Mar 2018 20:35:41 +0100 Subject: [PATCH] implementation #132 --- lib/model/table/AzuriteTableRequest.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/model/table/AzuriteTableRequest.js b/lib/model/table/AzuriteTableRequest.js index 80a25b2..b46ae2e 100644 --- a/lib/model/table/AzuriteTableRequest.js +++ b/lib/model/table/AzuriteTableRequest.js @@ -90,17 +90,22 @@ class AzuriteTableRequest { .replace(/\bne\b/g, '!==') .replace(/\band\b/g, '&&') .replace(/\bor\b/g, '||') - .replace(/\bnot\b/g, '!'); + .replace(/\(/g, ' ( ') + .replace(/\)/g, ' ) ') + .replace(/\bnot\b/g, ' ! '); // If a token is neither a number, nor a boolean, nor a string enclosed with quotation marks it is an operand. // Operands are attributes of the object used within the where clause of LokiJS, thus we need to prepend each // attribute with an object identifier 'item.attribs'. let transformedQuery = ''; for (const token of filter.split(' ')) { + if (token === '') { + continue; + } if (!token.match(/\d+/) && token !== 'true' && token !== 'false' && !token.includes('`') && - !['===', '>', '>=', '<', '<=', '!==', '&&', '||', '!'].includes(token)) { + !['===', '>', '>=', '<', '<=', '!==', '&&', '||', '!', '(', ')'].includes(token)) { if (token === 'PartitionKey' || token === 'RowKey') { transformedQuery += `item.${token} `; } else {