relq 1.0.55 → 1.0.57
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/dist/cjs/condition/array-condition-builder.cjs +24 -0
- package/dist/cjs/condition/condition-collector.cjs +160 -16
- package/dist/cjs/condition/geometric-condition-builder.cjs +33 -13
- package/dist/cjs/condition/index.cjs +4 -1
- package/dist/cjs/condition/network-condition-builder.cjs +13 -6
- package/dist/cjs/condition/postgis-condition-builder.cjs +188 -0
- package/dist/cjs/condition/range-condition-builder.cjs +21 -5
- package/dist/cjs/config/config.cjs +6 -0
- package/dist/cjs/core/relq-client.cjs +4 -0
- package/dist/cjs/select/select-builder.cjs +5 -6
- package/dist/config.d.ts +69 -0
- package/dist/esm/condition/array-condition-builder.js +24 -0
- package/dist/esm/condition/condition-collector.js +160 -16
- package/dist/esm/condition/geometric-condition-builder.js +33 -13
- package/dist/esm/condition/index.js +1 -0
- package/dist/esm/condition/network-condition-builder.js +13 -6
- package/dist/esm/condition/postgis-condition-builder.js +180 -0
- package/dist/esm/condition/range-condition-builder.js +21 -5
- package/dist/esm/config/config.js +6 -0
- package/dist/esm/core/relq-client.js +4 -0
- package/dist/esm/select/select-builder.js +5 -6
- package/dist/index.d.ts +469 -413
- package/package.json +1 -1
|
@@ -92,6 +92,22 @@ class ArrayConditionCollector {
|
|
|
92
92
|
});
|
|
93
93
|
return this.parent;
|
|
94
94
|
}
|
|
95
|
+
slice(column, start, end, values) {
|
|
96
|
+
this.parent.conditions.push({
|
|
97
|
+
method: 'array_slice',
|
|
98
|
+
column,
|
|
99
|
+
values: { start, end, values }
|
|
100
|
+
});
|
|
101
|
+
return this.parent;
|
|
102
|
+
}
|
|
103
|
+
atIndex(column, index, value) {
|
|
104
|
+
this.parent.conditions.push({
|
|
105
|
+
method: 'array_at_index',
|
|
106
|
+
column,
|
|
107
|
+
values: { index, value }
|
|
108
|
+
});
|
|
109
|
+
return this.parent;
|
|
110
|
+
}
|
|
95
111
|
containsPattern(column, pattern, matchType = 'prefix') {
|
|
96
112
|
this.parent.conditions.push({
|
|
97
113
|
method: 'array_contains_pattern',
|
|
@@ -237,6 +253,14 @@ function buildArrayConditionSQL(condition) {
|
|
|
237
253
|
}
|
|
238
254
|
case 'array_length':
|
|
239
255
|
return (0, pg_format_1.default)('array_length(%I, 1) = %L', column, values);
|
|
256
|
+
case 'array_slice': {
|
|
257
|
+
const { start, end, values: sliceValues } = values;
|
|
258
|
+
return (0, pg_format_1.default)('%I[%s:%s] = ARRAY[%s]', column, start, end, sliceValues.map(v => (0, pg_format_1.default)('%L', v)).join(','));
|
|
259
|
+
}
|
|
260
|
+
case 'array_at_index': {
|
|
261
|
+
const { index, value } = values;
|
|
262
|
+
return (0, pg_format_1.default)('%I[%s] = %L', column, index, value);
|
|
263
|
+
}
|
|
240
264
|
case 'array_contains_pattern': {
|
|
241
265
|
const { pattern, matchType } = values;
|
|
242
266
|
const likePattern = formatLikePattern(pattern, matchType);
|
|
@@ -13,6 +13,7 @@ const fulltext_condition_builder_1 = require("./fulltext-condition-builder.cjs")
|
|
|
13
13
|
const range_condition_builder_1 = require("./range-condition-builder.cjs");
|
|
14
14
|
const geometric_condition_builder_1 = require("./geometric-condition-builder.cjs");
|
|
15
15
|
const network_condition_builder_1 = require("./network-condition-builder.cjs");
|
|
16
|
+
const postgis_condition_builder_1 = require("./postgis-condition-builder.cjs");
|
|
16
17
|
class ConditionCollector {
|
|
17
18
|
conditions = [];
|
|
18
19
|
_jsonb;
|
|
@@ -21,12 +22,16 @@ class ConditionCollector {
|
|
|
21
22
|
_range;
|
|
22
23
|
_geometric;
|
|
23
24
|
_network;
|
|
25
|
+
_postgis;
|
|
24
26
|
get jsonb() {
|
|
25
27
|
if (!this._jsonb) {
|
|
26
28
|
this._jsonb = new jsonb_condition_builder_1.JsonbConditionCollector(this);
|
|
27
29
|
}
|
|
28
30
|
return this._jsonb;
|
|
29
31
|
}
|
|
32
|
+
get json() {
|
|
33
|
+
return this.jsonb;
|
|
34
|
+
}
|
|
30
35
|
get array() {
|
|
31
36
|
if (!this._array) {
|
|
32
37
|
this._array = new array_condition_builder_1.ArrayConditionCollector(this);
|
|
@@ -57,6 +62,12 @@ class ConditionCollector {
|
|
|
57
62
|
}
|
|
58
63
|
return this._network;
|
|
59
64
|
}
|
|
65
|
+
get postgis() {
|
|
66
|
+
if (!this._postgis) {
|
|
67
|
+
this._postgis = new postgis_condition_builder_1.PostgisConditionCollector(this);
|
|
68
|
+
}
|
|
69
|
+
return this._postgis;
|
|
70
|
+
}
|
|
60
71
|
equal(column, value) {
|
|
61
72
|
this.conditions.push({ method: 'equal', column, values: value });
|
|
62
73
|
return this;
|
|
@@ -97,28 +108,52 @@ class ConditionCollector {
|
|
|
97
108
|
this.conditions.push({ method: 'notBetween', column, values: [start, end] });
|
|
98
109
|
return this;
|
|
99
110
|
}
|
|
100
|
-
startsWith(column, value) {
|
|
101
|
-
this.conditions.push({
|
|
111
|
+
startsWith(column, value, caseInsensitive) {
|
|
112
|
+
this.conditions.push({
|
|
113
|
+
method: caseInsensitive ? 'startsWithI' : 'startsWith',
|
|
114
|
+
column,
|
|
115
|
+
values: value
|
|
116
|
+
});
|
|
102
117
|
return this;
|
|
103
118
|
}
|
|
104
|
-
notStartsWith(column, value) {
|
|
105
|
-
this.conditions.push({
|
|
119
|
+
notStartsWith(column, value, caseInsensitive) {
|
|
120
|
+
this.conditions.push({
|
|
121
|
+
method: caseInsensitive ? 'notStartsWithI' : 'notStartsWith',
|
|
122
|
+
column,
|
|
123
|
+
values: value
|
|
124
|
+
});
|
|
106
125
|
return this;
|
|
107
126
|
}
|
|
108
|
-
endsWith(column, value) {
|
|
109
|
-
this.conditions.push({
|
|
127
|
+
endsWith(column, value, caseInsensitive) {
|
|
128
|
+
this.conditions.push({
|
|
129
|
+
method: caseInsensitive ? 'endsWithI' : 'endsWith',
|
|
130
|
+
column,
|
|
131
|
+
values: value
|
|
132
|
+
});
|
|
110
133
|
return this;
|
|
111
134
|
}
|
|
112
|
-
notEndsWith(column, value) {
|
|
113
|
-
this.conditions.push({
|
|
135
|
+
notEndsWith(column, value, caseInsensitive) {
|
|
136
|
+
this.conditions.push({
|
|
137
|
+
method: caseInsensitive ? 'notEndsWithI' : 'notEndsWith',
|
|
138
|
+
column,
|
|
139
|
+
values: value
|
|
140
|
+
});
|
|
114
141
|
return this;
|
|
115
142
|
}
|
|
116
|
-
contains(column, value) {
|
|
117
|
-
this.conditions.push({
|
|
143
|
+
contains(column, value, caseInsensitive) {
|
|
144
|
+
this.conditions.push({
|
|
145
|
+
method: caseInsensitive ? 'containsI' : 'contains',
|
|
146
|
+
column,
|
|
147
|
+
values: value
|
|
148
|
+
});
|
|
118
149
|
return this;
|
|
119
150
|
}
|
|
120
|
-
notContains(column, value) {
|
|
121
|
-
this.conditions.push({
|
|
151
|
+
notContains(column, value, caseInsensitive) {
|
|
152
|
+
this.conditions.push({
|
|
153
|
+
method: caseInsensitive ? 'notContainsI' : 'notContains',
|
|
154
|
+
column,
|
|
155
|
+
values: value
|
|
156
|
+
});
|
|
122
157
|
return this;
|
|
123
158
|
}
|
|
124
159
|
like(column, pattern) {
|
|
@@ -133,6 +168,66 @@ class ConditionCollector {
|
|
|
133
168
|
this.conditions.push({ method: 'ilike', column, values: pattern });
|
|
134
169
|
return this;
|
|
135
170
|
}
|
|
171
|
+
notIlike(column, pattern) {
|
|
172
|
+
this.conditions.push({ method: 'notIlike', column, values: pattern });
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
regex(column, pattern) {
|
|
176
|
+
this.conditions.push({ method: 'regex', column, values: pattern });
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
iregex(column, pattern) {
|
|
180
|
+
this.conditions.push({ method: 'iregex', column, values: pattern });
|
|
181
|
+
return this;
|
|
182
|
+
}
|
|
183
|
+
notRegex(column, pattern) {
|
|
184
|
+
this.conditions.push({ method: 'notRegex', column, values: pattern });
|
|
185
|
+
return this;
|
|
186
|
+
}
|
|
187
|
+
notIregex(column, pattern) {
|
|
188
|
+
this.conditions.push({ method: 'notIregex', column, values: pattern });
|
|
189
|
+
return this;
|
|
190
|
+
}
|
|
191
|
+
similarTo(column, pattern) {
|
|
192
|
+
this.conditions.push({ method: 'similarTo', column, values: pattern });
|
|
193
|
+
return this;
|
|
194
|
+
}
|
|
195
|
+
notSimilarTo(column, pattern) {
|
|
196
|
+
this.conditions.push({ method: 'notSimilarTo', column, values: pattern });
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
isTrue(column) {
|
|
200
|
+
this.conditions.push({ method: 'isTrue', column });
|
|
201
|
+
return this;
|
|
202
|
+
}
|
|
203
|
+
isFalse(column) {
|
|
204
|
+
this.conditions.push({ method: 'isFalse', column });
|
|
205
|
+
return this;
|
|
206
|
+
}
|
|
207
|
+
distinctFrom(column, value) {
|
|
208
|
+
this.conditions.push({ method: 'distinctFrom', column, values: value });
|
|
209
|
+
return this;
|
|
210
|
+
}
|
|
211
|
+
notDistinctFrom(column, value) {
|
|
212
|
+
this.conditions.push({ method: 'notDistinctFrom', column, values: value });
|
|
213
|
+
return this;
|
|
214
|
+
}
|
|
215
|
+
overlaps(start, end) {
|
|
216
|
+
this.conditions.push({
|
|
217
|
+
method: 'overlaps',
|
|
218
|
+
values: { startColumn: start[0], startValue: start[1], endColumn: end[0], endValue: end[1] }
|
|
219
|
+
});
|
|
220
|
+
return this;
|
|
221
|
+
}
|
|
222
|
+
greaterThanOrEqual(column, value) {
|
|
223
|
+
return this.greaterThanEqual(column, value);
|
|
224
|
+
}
|
|
225
|
+
lessThanOrEqual(column, value) {
|
|
226
|
+
return this.lessThanEqual(column, value);
|
|
227
|
+
}
|
|
228
|
+
notNull(column) {
|
|
229
|
+
return this.isNotNull(column);
|
|
230
|
+
}
|
|
136
231
|
in(column, values) {
|
|
137
232
|
this.conditions.push({ method: 'in', column, values });
|
|
138
233
|
return this;
|
|
@@ -169,8 +264,10 @@ class ConditionCollector {
|
|
|
169
264
|
this.conditions.push({ method: 'and', values: subBuilder.getConditions() });
|
|
170
265
|
return this;
|
|
171
266
|
}
|
|
172
|
-
|
|
173
|
-
|
|
267
|
+
not(callback) {
|
|
268
|
+
const subBuilder = new ConditionCollector();
|
|
269
|
+
callback(subBuilder);
|
|
270
|
+
this.conditions.push({ method: 'not', values: subBuilder.getConditions() });
|
|
174
271
|
return this;
|
|
175
272
|
}
|
|
176
273
|
getConditions() {
|
|
@@ -205,6 +302,9 @@ function buildConditionSQL(condition) {
|
|
|
205
302
|
if (method.startsWith('network_')) {
|
|
206
303
|
return (0, network_condition_builder_1.buildNetworkConditionSQL)(condition);
|
|
207
304
|
}
|
|
305
|
+
if (method.startsWith('postgis_')) {
|
|
306
|
+
return (0, postgis_condition_builder_1.buildPostgisConditionSQL)(condition);
|
|
307
|
+
}
|
|
208
308
|
const col = column ? formatColumn(column) : '';
|
|
209
309
|
switch (method) {
|
|
210
310
|
case 'equal':
|
|
@@ -239,22 +339,64 @@ function buildConditionSQL(condition) {
|
|
|
239
339
|
}
|
|
240
340
|
case 'startsWith':
|
|
241
341
|
return `${col} LIKE ${(0, pg_format_1.default)('%L', `${values}%`)}`;
|
|
342
|
+
case 'startsWithI':
|
|
343
|
+
return `${col} ILIKE ${(0, pg_format_1.default)('%L', `${values}%`)}`;
|
|
242
344
|
case 'notStartsWith':
|
|
243
345
|
return `${col} NOT LIKE ${(0, pg_format_1.default)('%L', `${values}%`)}`;
|
|
346
|
+
case 'notStartsWithI':
|
|
347
|
+
return `${col} NOT ILIKE ${(0, pg_format_1.default)('%L', `${values}%`)}`;
|
|
244
348
|
case 'endsWith':
|
|
245
349
|
return `${col} LIKE ${(0, pg_format_1.default)('%L', `%${values}`)}`;
|
|
350
|
+
case 'endsWithI':
|
|
351
|
+
return `${col} ILIKE ${(0, pg_format_1.default)('%L', `%${values}`)}`;
|
|
246
352
|
case 'notEndsWith':
|
|
247
353
|
return `${col} NOT LIKE ${(0, pg_format_1.default)('%L', `%${values}`)}`;
|
|
354
|
+
case 'notEndsWithI':
|
|
355
|
+
return `${col} NOT ILIKE ${(0, pg_format_1.default)('%L', `%${values}`)}`;
|
|
248
356
|
case 'contains':
|
|
249
357
|
return `${col} LIKE ${(0, pg_format_1.default)('%L', `%${values}%`)}`;
|
|
358
|
+
case 'containsI':
|
|
359
|
+
return `${col} ILIKE ${(0, pg_format_1.default)('%L', `%${values}%`)}`;
|
|
250
360
|
case 'notContains':
|
|
251
361
|
return `${col} NOT LIKE ${(0, pg_format_1.default)('%L', `%${values}%`)}`;
|
|
362
|
+
case 'notContainsI':
|
|
363
|
+
return `${col} NOT ILIKE ${(0, pg_format_1.default)('%L', `%${values}%`)}`;
|
|
252
364
|
case 'like':
|
|
253
365
|
return `${col} LIKE ${(0, pg_format_1.default)('%L', values)}`;
|
|
254
366
|
case 'notLike':
|
|
255
367
|
return `${col} NOT LIKE ${(0, pg_format_1.default)('%L', values)}`;
|
|
256
368
|
case 'ilike':
|
|
257
369
|
return `${col} ILIKE ${(0, pg_format_1.default)('%L', values)}`;
|
|
370
|
+
case 'notIlike':
|
|
371
|
+
return `${col} NOT ILIKE ${(0, pg_format_1.default)('%L', values)}`;
|
|
372
|
+
case 'regex':
|
|
373
|
+
return `${col} ~ ${(0, pg_format_1.default)('%L', values)}`;
|
|
374
|
+
case 'iregex':
|
|
375
|
+
return `${col} ~* ${(0, pg_format_1.default)('%L', values)}`;
|
|
376
|
+
case 'notRegex':
|
|
377
|
+
return `${col} !~ ${(0, pg_format_1.default)('%L', values)}`;
|
|
378
|
+
case 'notIregex':
|
|
379
|
+
return `${col} !~* ${(0, pg_format_1.default)('%L', values)}`;
|
|
380
|
+
case 'similarTo':
|
|
381
|
+
return `${col} SIMILAR TO ${(0, pg_format_1.default)('%L', values)}`;
|
|
382
|
+
case 'notSimilarTo':
|
|
383
|
+
return `${col} NOT SIMILAR TO ${(0, pg_format_1.default)('%L', values)}`;
|
|
384
|
+
case 'isTrue':
|
|
385
|
+
return `${col} IS TRUE`;
|
|
386
|
+
case 'isFalse':
|
|
387
|
+
return `${col} IS FALSE`;
|
|
388
|
+
case 'distinctFrom':
|
|
389
|
+
return `${col} IS DISTINCT FROM ${(0, pg_format_1.default)('%L', values)}`;
|
|
390
|
+
case 'notDistinctFrom':
|
|
391
|
+
return `${col} IS NOT DISTINCT FROM ${(0, pg_format_1.default)('%L', values)}`;
|
|
392
|
+
case 'overlaps': {
|
|
393
|
+
const { startColumn, startValue, endColumn, endValue } = values;
|
|
394
|
+
const startCol = formatColumn(startColumn);
|
|
395
|
+
const endCol = formatColumn(endColumn);
|
|
396
|
+
const startVal = startValue instanceof Date ? startValue.toISOString() : startValue;
|
|
397
|
+
const endVal = endValue instanceof Date ? endValue.toISOString() : endValue;
|
|
398
|
+
return `(${startCol}, ${endCol}) OVERLAPS (${(0, pg_format_1.default)('%L', startVal)}, ${(0, pg_format_1.default)('%L', endVal)})`;
|
|
399
|
+
}
|
|
258
400
|
case 'in': {
|
|
259
401
|
const valueList = Array.isArray(values) ? values : [values];
|
|
260
402
|
const formattedValues = valueList.map(v => (0, pg_format_1.default)('%L', v)).join(', ');
|
|
@@ -281,8 +423,10 @@ function buildConditionSQL(condition) {
|
|
|
281
423
|
const andConditions = values;
|
|
282
424
|
return `(${andConditions.map(c => buildConditionSQL(c)).join(' AND ')})`;
|
|
283
425
|
}
|
|
284
|
-
case '
|
|
285
|
-
|
|
426
|
+
case 'not': {
|
|
427
|
+
const notConditions = values;
|
|
428
|
+
return `NOT (${notConditions.map(c => buildConditionSQL(c)).join(' AND ')})`;
|
|
429
|
+
}
|
|
286
430
|
default:
|
|
287
431
|
return '';
|
|
288
432
|
}
|
|
@@ -6,6 +6,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.GeometricConditionCollector = void 0;
|
|
7
7
|
exports.buildGeometricConditionSQL = buildGeometricConditionSQL;
|
|
8
8
|
const pg_format_1 = __importDefault(require("../addon/pg-format/index.cjs"));
|
|
9
|
+
function geometricToSQL(input) {
|
|
10
|
+
if (typeof input === 'string')
|
|
11
|
+
return input;
|
|
12
|
+
if (Array.isArray(input) && input.length === 2 && typeof input[0] === 'number' && typeof input[1] === 'number') {
|
|
13
|
+
return `(${input[0]},${input[1]})`;
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(input) && input.length === 2 && Array.isArray(input[0]) && typeof input[1] === 'number') {
|
|
16
|
+
const [center, radius] = input;
|
|
17
|
+
return `<(${center[0]},${center[1]}),${radius}>`;
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(input) && input.length === 2 && Array.isArray(input[0]) && Array.isArray(input[1])) {
|
|
20
|
+
const [p1, p2] = input;
|
|
21
|
+
return `((${p1[0]},${p1[1]}),(${p2[0]},${p2[1]}))`;
|
|
22
|
+
}
|
|
23
|
+
if (Array.isArray(input) && input.length > 2) {
|
|
24
|
+
const points = input;
|
|
25
|
+
return `(${points.map(p => `(${p[0]},${p[1]})`).join(',')})`;
|
|
26
|
+
}
|
|
27
|
+
return String(input);
|
|
28
|
+
}
|
|
9
29
|
class GeometricConditionCollector {
|
|
10
30
|
parent;
|
|
11
31
|
constructor(parent) {
|
|
@@ -15,7 +35,7 @@ class GeometricConditionCollector {
|
|
|
15
35
|
this.parent.conditions.push({
|
|
16
36
|
method: 'geometric_contains',
|
|
17
37
|
column,
|
|
18
|
-
values: value
|
|
38
|
+
values: geometricToSQL(value)
|
|
19
39
|
});
|
|
20
40
|
return this.parent;
|
|
21
41
|
}
|
|
@@ -23,7 +43,7 @@ class GeometricConditionCollector {
|
|
|
23
43
|
this.parent.conditions.push({
|
|
24
44
|
method: 'geometric_contained_by',
|
|
25
45
|
column,
|
|
26
|
-
values: value
|
|
46
|
+
values: geometricToSQL(value)
|
|
27
47
|
});
|
|
28
48
|
return this.parent;
|
|
29
49
|
}
|
|
@@ -31,7 +51,7 @@ class GeometricConditionCollector {
|
|
|
31
51
|
this.parent.conditions.push({
|
|
32
52
|
method: 'geometric_overlaps',
|
|
33
53
|
column,
|
|
34
|
-
values: value
|
|
54
|
+
values: geometricToSQL(value)
|
|
35
55
|
});
|
|
36
56
|
return this.parent;
|
|
37
57
|
}
|
|
@@ -39,7 +59,7 @@ class GeometricConditionCollector {
|
|
|
39
59
|
this.parent.conditions.push({
|
|
40
60
|
method: 'geometric_strictly_left',
|
|
41
61
|
column,
|
|
42
|
-
values: value
|
|
62
|
+
values: geometricToSQL(value)
|
|
43
63
|
});
|
|
44
64
|
return this.parent;
|
|
45
65
|
}
|
|
@@ -47,7 +67,7 @@ class GeometricConditionCollector {
|
|
|
47
67
|
this.parent.conditions.push({
|
|
48
68
|
method: 'geometric_strictly_right',
|
|
49
69
|
column,
|
|
50
|
-
values: value
|
|
70
|
+
values: geometricToSQL(value)
|
|
51
71
|
});
|
|
52
72
|
return this.parent;
|
|
53
73
|
}
|
|
@@ -55,7 +75,7 @@ class GeometricConditionCollector {
|
|
|
55
75
|
this.parent.conditions.push({
|
|
56
76
|
method: 'geometric_below',
|
|
57
77
|
column,
|
|
58
|
-
values: value
|
|
78
|
+
values: geometricToSQL(value)
|
|
59
79
|
});
|
|
60
80
|
return this.parent;
|
|
61
81
|
}
|
|
@@ -63,7 +83,7 @@ class GeometricConditionCollector {
|
|
|
63
83
|
this.parent.conditions.push({
|
|
64
84
|
method: 'geometric_above',
|
|
65
85
|
column,
|
|
66
|
-
values: value
|
|
86
|
+
values: geometricToSQL(value)
|
|
67
87
|
});
|
|
68
88
|
return this.parent;
|
|
69
89
|
}
|
|
@@ -71,7 +91,7 @@ class GeometricConditionCollector {
|
|
|
71
91
|
this.parent.conditions.push({
|
|
72
92
|
method: 'geometric_intersects',
|
|
73
93
|
column,
|
|
74
|
-
values: value
|
|
94
|
+
values: geometricToSQL(value)
|
|
75
95
|
});
|
|
76
96
|
return this.parent;
|
|
77
97
|
}
|
|
@@ -109,7 +129,7 @@ class GeometricConditionCollector {
|
|
|
109
129
|
this.parent.conditions.push({
|
|
110
130
|
method: 'geometric_same_as',
|
|
111
131
|
column,
|
|
112
|
-
values: value
|
|
132
|
+
values: geometricToSQL(value)
|
|
113
133
|
});
|
|
114
134
|
return this.parent;
|
|
115
135
|
}
|
|
@@ -117,7 +137,7 @@ class GeometricConditionCollector {
|
|
|
117
137
|
this.parent.conditions.push({
|
|
118
138
|
method: 'geometric_distance_lt',
|
|
119
139
|
column,
|
|
120
|
-
values: { value, threshold: maxDistance }
|
|
140
|
+
values: { value: geometricToSQL(value), threshold: maxDistance }
|
|
121
141
|
});
|
|
122
142
|
return this.parent;
|
|
123
143
|
}
|
|
@@ -125,7 +145,7 @@ class GeometricConditionCollector {
|
|
|
125
145
|
this.parent.conditions.push({
|
|
126
146
|
method: 'geometric_distance_lte',
|
|
127
147
|
column,
|
|
128
|
-
values: { value, threshold: maxDistance }
|
|
148
|
+
values: { value: geometricToSQL(value), threshold: maxDistance }
|
|
129
149
|
});
|
|
130
150
|
return this.parent;
|
|
131
151
|
}
|
|
@@ -133,7 +153,7 @@ class GeometricConditionCollector {
|
|
|
133
153
|
this.parent.conditions.push({
|
|
134
154
|
method: 'geometric_distance_gt',
|
|
135
155
|
column,
|
|
136
|
-
values: { value, threshold: minDistance }
|
|
156
|
+
values: { value: geometricToSQL(value), threshold: minDistance }
|
|
137
157
|
});
|
|
138
158
|
return this.parent;
|
|
139
159
|
}
|
|
@@ -141,7 +161,7 @@ class GeometricConditionCollector {
|
|
|
141
161
|
this.parent.conditions.push({
|
|
142
162
|
method: 'geometric_distance_between',
|
|
143
163
|
column,
|
|
144
|
-
values: { value, min: minDistance, max: maxDistance }
|
|
164
|
+
values: { value: geometricToSQL(value), min: minDistance, max: maxDistance }
|
|
145
165
|
});
|
|
146
166
|
return this.parent;
|
|
147
167
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildNetworkConditionSQL = exports.NetworkConditionCollector = exports.buildGeometricConditionSQL = exports.GeometricConditionCollector = exports.buildRangeConditionSQL = exports.RangeConditionCollector = exports.buildFulltextConditionSQL = exports.FulltextConditionCollector = exports.buildArrayConditionSQL = exports.ArrayConditionCollector = exports.buildJsonbConditionSQL = exports.JsonbConditionCollector = exports.buildConditionsSQL = exports.buildConditionSQL = exports.ConditionCollector = void 0;
|
|
3
|
+
exports.buildPostgisConditionSQL = exports.PostgisConditionCollector = exports.buildNetworkConditionSQL = exports.NetworkConditionCollector = exports.buildGeometricConditionSQL = exports.GeometricConditionCollector = exports.buildRangeConditionSQL = exports.RangeConditionCollector = exports.buildFulltextConditionSQL = exports.FulltextConditionCollector = exports.buildArrayConditionSQL = exports.ArrayConditionCollector = exports.buildJsonbConditionSQL = exports.JsonbConditionCollector = exports.buildConditionsSQL = exports.buildConditionSQL = exports.ConditionCollector = void 0;
|
|
4
4
|
var condition_collector_1 = require("./condition-collector.cjs");
|
|
5
5
|
Object.defineProperty(exports, "ConditionCollector", { enumerable: true, get: function () { return condition_collector_1.ConditionCollector; } });
|
|
6
6
|
Object.defineProperty(exports, "buildConditionSQL", { enumerable: true, get: function () { return condition_collector_1.buildConditionSQL; } });
|
|
@@ -23,3 +23,6 @@ Object.defineProperty(exports, "buildGeometricConditionSQL", { enumerable: true,
|
|
|
23
23
|
var network_condition_builder_1 = require("./network-condition-builder.cjs");
|
|
24
24
|
Object.defineProperty(exports, "NetworkConditionCollector", { enumerable: true, get: function () { return network_condition_builder_1.NetworkConditionCollector; } });
|
|
25
25
|
Object.defineProperty(exports, "buildNetworkConditionSQL", { enumerable: true, get: function () { return network_condition_builder_1.buildNetworkConditionSQL; } });
|
|
26
|
+
var postgis_condition_builder_1 = require("./postgis-condition-builder.cjs");
|
|
27
|
+
Object.defineProperty(exports, "PostgisConditionCollector", { enumerable: true, get: function () { return postgis_condition_builder_1.PostgisConditionCollector; } });
|
|
28
|
+
Object.defineProperty(exports, "buildPostgisConditionSQL", { enumerable: true, get: function () { return postgis_condition_builder_1.buildPostgisConditionSQL; } });
|
|
@@ -6,6 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.NetworkConditionCollector = void 0;
|
|
7
7
|
exports.buildNetworkConditionSQL = buildNetworkConditionSQL;
|
|
8
8
|
const pg_format_1 = __importDefault(require("../addon/pg-format/index.cjs"));
|
|
9
|
+
function networkToSQL(address) {
|
|
10
|
+
if (typeof address === 'string')
|
|
11
|
+
return address;
|
|
12
|
+
const { octets, mask } = address;
|
|
13
|
+
const ip = octets.join('.');
|
|
14
|
+
return mask !== undefined ? `${ip}/${mask}` : ip;
|
|
15
|
+
}
|
|
9
16
|
class NetworkConditionCollector {
|
|
10
17
|
parent;
|
|
11
18
|
constructor(parent) {
|
|
@@ -15,7 +22,7 @@ class NetworkConditionCollector {
|
|
|
15
22
|
this.parent.conditions.push({
|
|
16
23
|
method: 'network_contained_by_strict',
|
|
17
24
|
column,
|
|
18
|
-
values: value
|
|
25
|
+
values: networkToSQL(value)
|
|
19
26
|
});
|
|
20
27
|
return this.parent;
|
|
21
28
|
}
|
|
@@ -23,7 +30,7 @@ class NetworkConditionCollector {
|
|
|
23
30
|
this.parent.conditions.push({
|
|
24
31
|
method: 'network_contained_by_or_equal',
|
|
25
32
|
column,
|
|
26
|
-
values: value
|
|
33
|
+
values: networkToSQL(value)
|
|
27
34
|
});
|
|
28
35
|
return this.parent;
|
|
29
36
|
}
|
|
@@ -31,7 +38,7 @@ class NetworkConditionCollector {
|
|
|
31
38
|
this.parent.conditions.push({
|
|
32
39
|
method: 'network_contains_strict',
|
|
33
40
|
column,
|
|
34
|
-
values: value
|
|
41
|
+
values: networkToSQL(value)
|
|
35
42
|
});
|
|
36
43
|
return this.parent;
|
|
37
44
|
}
|
|
@@ -39,7 +46,7 @@ class NetworkConditionCollector {
|
|
|
39
46
|
this.parent.conditions.push({
|
|
40
47
|
method: 'network_contains_or_equal',
|
|
41
48
|
column,
|
|
42
|
-
values: value
|
|
49
|
+
values: networkToSQL(value)
|
|
43
50
|
});
|
|
44
51
|
return this.parent;
|
|
45
52
|
}
|
|
@@ -47,7 +54,7 @@ class NetworkConditionCollector {
|
|
|
47
54
|
this.parent.conditions.push({
|
|
48
55
|
method: 'network_overlaps',
|
|
49
56
|
column,
|
|
50
|
-
values: value
|
|
57
|
+
values: networkToSQL(value)
|
|
51
58
|
});
|
|
52
59
|
return this.parent;
|
|
53
60
|
}
|
|
@@ -55,7 +62,7 @@ class NetworkConditionCollector {
|
|
|
55
62
|
this.parent.conditions.push({
|
|
56
63
|
method: 'network_same_family',
|
|
57
64
|
column,
|
|
58
|
-
values: value
|
|
65
|
+
values: networkToSQL(value)
|
|
59
66
|
});
|
|
60
67
|
return this.parent;
|
|
61
68
|
}
|