@narrative.io/data-collaboration-sdk-ts 0.0.64 → 0.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/nql/NQLParser.js +5 -4
- package/package.json +1 -1
package/build/nql/NQLParser.js
CHANGED
|
@@ -52,7 +52,7 @@ export function getFrom(nql) {
|
|
|
52
52
|
* @returns {NqlBooleanExpression[]} - An array of parsed NqlBooleanExpression objects representing the boolean expressions.
|
|
53
53
|
*/
|
|
54
54
|
function getBooleanExpressionsFromWhere(where) {
|
|
55
|
-
const booleanRegex = /\
|
|
55
|
+
const booleanRegex = /\s(OR|AND)\s/ig;
|
|
56
56
|
const matches = [];
|
|
57
57
|
let boolMatch;
|
|
58
58
|
while ((boolMatch = booleanRegex.exec(where)) !== null) {
|
|
@@ -68,12 +68,12 @@ function getBooleanExpressionsFromWhere(where) {
|
|
|
68
68
|
*/
|
|
69
69
|
function getFilterExpressionsFromWhere(where) {
|
|
70
70
|
let matches = [];
|
|
71
|
-
const hasBoolean = /\
|
|
71
|
+
const hasBoolean = /\s(?:OR|AND)\s/ig.test(where);
|
|
72
72
|
if (!hasBoolean) {
|
|
73
73
|
matches.push(getFilterExpressionFromString(where));
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
|
-
const expressions = where.split(/\
|
|
76
|
+
const expressions = where.split(/\s(?:OR|AND)\s/ig).map((t) => t.trim());
|
|
77
77
|
matches = matches.concat(expressions.map((e) => getFilterExpressionFromString(e)));
|
|
78
78
|
}
|
|
79
79
|
return NqlFilterExpressionObj.array().parse(matches);
|
|
@@ -128,6 +128,7 @@ function parseString(value) {
|
|
|
128
128
|
* @returns {NqlField | string} - The parsed NqlField object or the original field string if parsing fails.
|
|
129
129
|
*/
|
|
130
130
|
export function getFilterExpressionFromString(str) {
|
|
131
|
+
console.log(str);
|
|
131
132
|
const comparison = ['<=', '>=', '!=', '=', '>', '<'];
|
|
132
133
|
const containsComparison = comparison.find((character) => str.includes(character));
|
|
133
134
|
if (containsComparison !== undefined) {
|
|
@@ -165,7 +166,7 @@ export function getFilterExpressionFromString(str) {
|
|
|
165
166
|
operator
|
|
166
167
|
});
|
|
167
168
|
}
|
|
168
|
-
throw new Error(
|
|
169
|
+
throw new Error(`Invalid filter expression: ${str}`);
|
|
169
170
|
}
|
|
170
171
|
/**
|
|
171
172
|
* Parses the pre-select expression from the given NQL (Natural Query Language) string.
|