dbgate-filterparser 5.1.0 → 5.1.1
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/lib/datetimeParser.js +12 -1
- package/package.json +3 -3
package/lib/datetimeParser.js
CHANGED
|
@@ -154,9 +154,20 @@ const binaryCondition = operator => value => ({
|
|
|
154
154
|
value,
|
|
155
155
|
},
|
|
156
156
|
});
|
|
157
|
+
const unaryCondition = conditionType => () => {
|
|
158
|
+
return {
|
|
159
|
+
conditionType,
|
|
160
|
+
expr: {
|
|
161
|
+
exprType: 'placeholder',
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
};
|
|
157
165
|
const createParser = () => {
|
|
158
166
|
const langDef = {
|
|
159
167
|
comma: () => (0, common_1.word)(','),
|
|
168
|
+
not: () => (0, common_1.word)('NOT'),
|
|
169
|
+
notNull: r => r.not.then(r.null).map(unaryCondition('isNotNull')),
|
|
170
|
+
null: () => (0, common_1.word)('NULL').map(unaryCondition('isNull')),
|
|
160
171
|
yearNum: () => parsimmon_1.default.regexp(/\d\d\d\d/).map(yearCondition()),
|
|
161
172
|
yearMonthNum: () => parsimmon_1.default.regexp(/\d\d\d\d-\d\d?/).map(yearMonthCondition()),
|
|
162
173
|
yearMonthDayNum: () => parsimmon_1.default.regexp(/\d\d\d\d-\d\d?-\d\d?/).map(yearMonthDayCondition()),
|
|
@@ -196,7 +207,7 @@ const createParser = () => {
|
|
|
196
207
|
ge: r => (0, common_1.word)('>=').then(r.valueStart).map(binaryCondition('>=')),
|
|
197
208
|
lt: r => (0, common_1.word)('<').then(r.valueStart).map(binaryCondition('<')),
|
|
198
209
|
gt: r => (0, common_1.word)('>').then(r.valueEnd).map(binaryCondition('>')),
|
|
199
|
-
element: r => parsimmon_1.default.alt(r.yearMonthDaySecond, r.yearMonthDayMinute, r.yearMonthDayNum, r.yearMonthNum, r.yearNum, r.yesterday, r.today, r.tomorrow, r.lastWeek, r.thisWeek, r.nextWeek, r.lastMonth, r.thisMonth, r.nextMonth, r.lastYear, r.thisYear, r.nextYear, r.le, r.lt, r.ge, r.gt).trim(common_1.whitespace),
|
|
210
|
+
element: r => parsimmon_1.default.alt(r.yearMonthDaySecond, r.yearMonthDayMinute, r.yearMonthDayNum, r.yearMonthNum, r.yearNum, r.yesterday, r.today, r.tomorrow, r.lastWeek, r.thisWeek, r.nextWeek, r.lastMonth, r.thisMonth, r.nextMonth, r.lastYear, r.thisYear, r.nextYear, r.null, r.notNull, r.le, r.lt, r.ge, r.gt).trim(common_1.whitespace),
|
|
200
211
|
factor: r => r.element.sepBy(common_1.whitespace).map(compoudCondition('$and')),
|
|
201
212
|
list: r => r.factor.sepBy(r.comma).map(compoudCondition('$or')),
|
|
202
213
|
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.1.
|
|
2
|
+
"version": "5.1.1",
|
|
3
3
|
"name": "dbgate-filterparser",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"typings": "lib/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"lib"
|
|
14
14
|
],
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"dbgate-types": "^5.1.
|
|
16
|
+
"dbgate-types": "^5.1.1",
|
|
17
17
|
"@types/jest": "^25.1.4",
|
|
18
18
|
"@types/node": "^13.7.0",
|
|
19
19
|
"jest": "^28.1.3",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@types/parsimmon": "^1.10.1",
|
|
25
|
-
"dbgate-tools": "^5.1.
|
|
25
|
+
"dbgate-tools": "^5.1.1",
|
|
26
26
|
"lodash": "^4.17.21",
|
|
27
27
|
"moment": "^2.24.0",
|
|
28
28
|
"parsimmon": "^1.13.0"
|