@balena/abstract-sql-compiler 11.0.0-build-11-x-45529f014aa1c181f338c0f7348767f2990a9084-1 → 11.0.0
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/package.json +5 -2
- package/.github/workflows/flowzone.yml +0 -21
- package/.husky/pre-commit +0 -2
- package/.versionbot/CHANGELOG.yml +0 -10729
- package/CHANGELOG.md +0 -3515
- package/repo.yml +0 -12
- package/src/abstract-sql-compiler.ts +0 -1138
- package/src/abstract-sql-optimizer.ts +0 -1632
- package/src/abstract-sql-rules-to-sql.ts +0 -1730
- package/src/abstract-sql-schema-optimizer.ts +0 -172
- package/src/referenced-fields.ts +0 -600
- package/test/abstract-sql/aggregate-json.ts +0 -49
- package/test/abstract-sql/aggregate.ts +0 -161
- package/test/abstract-sql/and-or-boolean-optimisations.ts +0 -115
- package/test/abstract-sql/case-when-else.ts +0 -48
- package/test/abstract-sql/cast.ts +0 -25
- package/test/abstract-sql/coalesce.ts +0 -24
- package/test/abstract-sql/comparisons.ts +0 -360
- package/test/abstract-sql/dates.ts +0 -512
- package/test/abstract-sql/duration.ts +0 -56
- package/test/abstract-sql/empty-query-optimisations.ts +0 -54
- package/test/abstract-sql/functions-wrapper.ts +0 -70
- package/test/abstract-sql/get-referenced-fields.ts +0 -674
- package/test/abstract-sql/get-rule-referenced-fields.ts +0 -345
- package/test/abstract-sql/insert-query.ts +0 -22
- package/test/abstract-sql/is-distinct.ts +0 -102
- package/test/abstract-sql/joins.ts +0 -84
- package/test/abstract-sql/json.ts +0 -58
- package/test/abstract-sql/math.ts +0 -467
- package/test/abstract-sql/nested-in-optimisations.ts +0 -200
- package/test/abstract-sql/not-not-optimisations.ts +0 -15
- package/test/abstract-sql/schema-checks.ts +0 -168
- package/test/abstract-sql/schema-informative-reference.ts +0 -420
- package/test/abstract-sql/schema-rule-optimization.ts +0 -120
- package/test/abstract-sql/schema-rule-to-check.ts +0 -393
- package/test/abstract-sql/schema-views.ts +0 -73
- package/test/abstract-sql/test.ts +0 -192
- package/test/abstract-sql/text.ts +0 -168
- package/test/model.sbvr +0 -60
- package/test/odata/expand.ts +0 -674
- package/test/odata/fields.ts +0 -59
- package/test/odata/filterby.ts +0 -1517
- package/test/odata/orderby.ts +0 -96
- package/test/odata/paging.ts +0 -48
- package/test/odata/resource-parsing.ts +0 -568
- package/test/odata/select.ts +0 -119
- package/test/odata/stress.ts +0 -93
- package/test/odata/test.ts +0 -297
- package/test/sbvr/pilots.ts +0 -1097
- package/test/sbvr/reference-type.ts +0 -211
- package/test/sbvr/test.ts +0 -101
- package/tsconfig.build.json +0 -6
- package/tsconfig.json +0 -25
@@ -1,467 +0,0 @@
|
|
1
|
-
import test from './test.js';
|
2
|
-
|
3
|
-
describe('Add', () => {
|
4
|
-
test(
|
5
|
-
['SelectQuery', ['Select', [['Add', ['Number', 5], ['Number', 3]]]]],
|
6
|
-
(result, sqlEquals) => {
|
7
|
-
it('should produce a valid Add statement', () => {
|
8
|
-
sqlEquals(result, 'SELECT 5 + 3');
|
9
|
-
});
|
10
|
-
},
|
11
|
-
);
|
12
|
-
});
|
13
|
-
|
14
|
-
describe('Subtract', () => {
|
15
|
-
test(
|
16
|
-
['SelectQuery', ['Select', [['Subtract', ['Number', 5], ['Number', 3]]]]],
|
17
|
-
(result, sqlEquals) => {
|
18
|
-
it('should produce a valid Subtract statement', () => {
|
19
|
-
sqlEquals(result, 'SELECT 5 - 3');
|
20
|
-
});
|
21
|
-
},
|
22
|
-
);
|
23
|
-
});
|
24
|
-
|
25
|
-
describe('Multiply', () => {
|
26
|
-
test(
|
27
|
-
['SelectQuery', ['Select', [['Multiply', ['Number', 5], ['Number', 3]]]]],
|
28
|
-
(result, sqlEquals) => {
|
29
|
-
it('should produce a valid Multiply statement', () => {
|
30
|
-
sqlEquals(result, 'SELECT 5 * 3');
|
31
|
-
});
|
32
|
-
},
|
33
|
-
);
|
34
|
-
});
|
35
|
-
|
36
|
-
describe('Divide', () => {
|
37
|
-
test(
|
38
|
-
['SelectQuery', ['Select', [['Divide', ['Number', 10], ['Number', 5]]]]],
|
39
|
-
(result, sqlEquals) => {
|
40
|
-
it('should produce a valid Divide statement', () => {
|
41
|
-
sqlEquals(result, 'SELECT 10 / 5');
|
42
|
-
});
|
43
|
-
},
|
44
|
-
);
|
45
|
-
});
|
46
|
-
|
47
|
-
describe('BitwiseAnd', () => {
|
48
|
-
test(
|
49
|
-
[
|
50
|
-
'SelectQuery',
|
51
|
-
['Select', [['BitwiseAnd', ['Number', 10], ['Number', 5]]]],
|
52
|
-
],
|
53
|
-
(result, sqlEquals) => {
|
54
|
-
it('should produce a valid BitwiseAnd statement', () => {
|
55
|
-
sqlEquals(result, 'SELECT 10 & 5');
|
56
|
-
});
|
57
|
-
},
|
58
|
-
);
|
59
|
-
});
|
60
|
-
|
61
|
-
describe('BitwiseShiftRight', () => {
|
62
|
-
test(
|
63
|
-
[
|
64
|
-
'SelectQuery',
|
65
|
-
['Select', [['BitwiseShiftRight', ['Number', 10], ['Number', 5]]]],
|
66
|
-
],
|
67
|
-
(result, sqlEquals) => {
|
68
|
-
it('should produce a valid BitwiseShiftRight statement', () => {
|
69
|
-
sqlEquals(result, 'SELECT 10 >> 5');
|
70
|
-
});
|
71
|
-
},
|
72
|
-
);
|
73
|
-
});
|
74
|
-
|
75
|
-
describe('Round', () => {
|
76
|
-
test(
|
77
|
-
['SelectQuery', ['Select', [['Round', ['Number', 10.4]]]]],
|
78
|
-
(result, sqlEquals) => {
|
79
|
-
it('should produce a valid Round statement', () => {
|
80
|
-
sqlEquals(result, `SELECT ROUND(10.4)`);
|
81
|
-
});
|
82
|
-
},
|
83
|
-
);
|
84
|
-
});
|
85
|
-
|
86
|
-
describe('Floor', () => {
|
87
|
-
test(
|
88
|
-
['SelectQuery', ['Select', [['Floor', ['Number', 10.4]]]]],
|
89
|
-
(result, sqlEquals) => {
|
90
|
-
it('should produce a valid Floor statement', () => {
|
91
|
-
sqlEquals(result, `SELECT FLOOR(10.4)`);
|
92
|
-
});
|
93
|
-
},
|
94
|
-
);
|
95
|
-
});
|
96
|
-
|
97
|
-
describe('Ceiling', () => {
|
98
|
-
test(
|
99
|
-
['SelectQuery', ['Select', [['Ceiling', ['Number', 10.4]]]]],
|
100
|
-
(result, sqlEquals) => {
|
101
|
-
it('should produce a valid Ceiling statement', () => {
|
102
|
-
sqlEquals(result, `SELECT CEILING(10.4)`);
|
103
|
-
});
|
104
|
-
},
|
105
|
-
);
|
106
|
-
});
|
107
|
-
|
108
|
-
describe('Math Operator Precedence', () => {
|
109
|
-
// Different precedence
|
110
|
-
test(
|
111
|
-
[
|
112
|
-
'SelectQuery',
|
113
|
-
[
|
114
|
-
'Select',
|
115
|
-
[['Add', ['Multiply', ['Number', 2], ['Number', 3]], ['Number', 4]]],
|
116
|
-
],
|
117
|
-
],
|
118
|
-
(result, sqlEquals) => {
|
119
|
-
it('should produce a valid Add statement when the first operand is a Multiply', () => {
|
120
|
-
sqlEquals(result, 'SELECT (2 * 3) + 4');
|
121
|
-
});
|
122
|
-
},
|
123
|
-
);
|
124
|
-
|
125
|
-
test(
|
126
|
-
[
|
127
|
-
'SelectQuery',
|
128
|
-
[
|
129
|
-
'Select',
|
130
|
-
[['Add', ['Number', 2], ['Multiply', ['Number', 3], ['Number', 4]]]],
|
131
|
-
],
|
132
|
-
],
|
133
|
-
(result, sqlEquals) => {
|
134
|
-
it('should produce a valid Add statement when the second operand is a Multiply', () => {
|
135
|
-
sqlEquals(result, 'SELECT 2 + (3 * 4)');
|
136
|
-
});
|
137
|
-
},
|
138
|
-
);
|
139
|
-
|
140
|
-
test(
|
141
|
-
[
|
142
|
-
'SelectQuery',
|
143
|
-
[
|
144
|
-
'Select',
|
145
|
-
[
|
146
|
-
[
|
147
|
-
'Add',
|
148
|
-
['Multiply', ['Number', 2], ['Number', 3]],
|
149
|
-
['Multiply', ['Number', 4], ['Number', 5]],
|
150
|
-
],
|
151
|
-
],
|
152
|
-
],
|
153
|
-
],
|
154
|
-
(result, sqlEquals) => {
|
155
|
-
it('should produce a valid Add statement of two Multiplications', () => {
|
156
|
-
sqlEquals(result, 'SELECT (2 * 3) + (4 * 5)');
|
157
|
-
});
|
158
|
-
},
|
159
|
-
);
|
160
|
-
|
161
|
-
test(
|
162
|
-
[
|
163
|
-
'SelectQuery',
|
164
|
-
[
|
165
|
-
'Select',
|
166
|
-
[['Multiply', ['Add', ['Number', 2], ['Number', 3]], ['Number', 4]]],
|
167
|
-
],
|
168
|
-
],
|
169
|
-
(result, sqlEquals) => {
|
170
|
-
it('should produce a valid Multiply statement when the first operand is an Add', () => {
|
171
|
-
sqlEquals(result, 'SELECT (2 + 3) * 4');
|
172
|
-
});
|
173
|
-
},
|
174
|
-
);
|
175
|
-
|
176
|
-
test(
|
177
|
-
[
|
178
|
-
'SelectQuery',
|
179
|
-
[
|
180
|
-
'Select',
|
181
|
-
[['Multiply', ['Number', 2], ['Add', ['Number', 3], ['Number', 4]]]],
|
182
|
-
],
|
183
|
-
],
|
184
|
-
(result, sqlEquals) => {
|
185
|
-
it('should produce a valid Multiply statement when the second operand is an Add', () => {
|
186
|
-
sqlEquals(result, 'SELECT 2 * (3 + 4)');
|
187
|
-
});
|
188
|
-
},
|
189
|
-
);
|
190
|
-
|
191
|
-
test(
|
192
|
-
[
|
193
|
-
'SelectQuery',
|
194
|
-
[
|
195
|
-
'Select',
|
196
|
-
[
|
197
|
-
[
|
198
|
-
'Multiply',
|
199
|
-
['Add', ['Number', 2], ['Number', 3]],
|
200
|
-
['Add', ['Number', 4], ['Number', 5]],
|
201
|
-
],
|
202
|
-
],
|
203
|
-
],
|
204
|
-
],
|
205
|
-
(result, sqlEquals) => {
|
206
|
-
it('should produce a valid Multiply statement of two Additions', () => {
|
207
|
-
sqlEquals(result, 'SELECT (2 + 3) * (4 + 5)');
|
208
|
-
});
|
209
|
-
},
|
210
|
-
);
|
211
|
-
|
212
|
-
test(
|
213
|
-
[
|
214
|
-
'SelectQuery',
|
215
|
-
[
|
216
|
-
'Select',
|
217
|
-
[
|
218
|
-
[
|
219
|
-
'Subtract',
|
220
|
-
['Multiply', ['Number', 2], ['Number', 3]],
|
221
|
-
['Multiply', ['Number', 4], ['Number', 5]],
|
222
|
-
],
|
223
|
-
],
|
224
|
-
],
|
225
|
-
],
|
226
|
-
(result, sqlEquals) => {
|
227
|
-
it('should produce a valid Subtract statement of two Multiplications', () => {
|
228
|
-
sqlEquals(result, 'SELECT (2 * 3) - (4 * 5)');
|
229
|
-
});
|
230
|
-
},
|
231
|
-
);
|
232
|
-
|
233
|
-
test(
|
234
|
-
[
|
235
|
-
'SelectQuery',
|
236
|
-
[
|
237
|
-
'Select',
|
238
|
-
[
|
239
|
-
[
|
240
|
-
'Subtract',
|
241
|
-
['Divide', ['Number', 2], ['Number', 3]],
|
242
|
-
['Divide', ['Number', 4], ['Number', 5]],
|
243
|
-
],
|
244
|
-
],
|
245
|
-
],
|
246
|
-
],
|
247
|
-
(result, sqlEquals) => {
|
248
|
-
it('should produce a valid Subtract statement of two Divisions', () => {
|
249
|
-
sqlEquals(result, 'SELECT (2 / 3) - (4 / 5)');
|
250
|
-
});
|
251
|
-
},
|
252
|
-
);
|
253
|
-
|
254
|
-
test(
|
255
|
-
[
|
256
|
-
'SelectQuery',
|
257
|
-
[
|
258
|
-
'Select',
|
259
|
-
[
|
260
|
-
[
|
261
|
-
'Divide',
|
262
|
-
['Add', ['Number', 2], ['Number', 3]],
|
263
|
-
['Add', ['Number', 4], ['Number', 5]],
|
264
|
-
],
|
265
|
-
],
|
266
|
-
],
|
267
|
-
],
|
268
|
-
(result, sqlEquals) => {
|
269
|
-
it('should produce a valid Divide statement of two Additions', () => {
|
270
|
-
sqlEquals(result, 'SELECT (2 + 3) / (4 + 5)');
|
271
|
-
});
|
272
|
-
},
|
273
|
-
);
|
274
|
-
|
275
|
-
test(
|
276
|
-
[
|
277
|
-
'SelectQuery',
|
278
|
-
[
|
279
|
-
'Select',
|
280
|
-
[
|
281
|
-
[
|
282
|
-
'Divide',
|
283
|
-
['Subtract', ['Number', 2], ['Number', 3]],
|
284
|
-
['Subtract', ['Number', 4], ['Number', 5]],
|
285
|
-
],
|
286
|
-
],
|
287
|
-
],
|
288
|
-
],
|
289
|
-
(result, sqlEquals) => {
|
290
|
-
it('should produce a valid Divide statement of two Subtractions', () => {
|
291
|
-
sqlEquals(result, 'SELECT (2 - 3) / (4 - 5)');
|
292
|
-
});
|
293
|
-
},
|
294
|
-
);
|
295
|
-
|
296
|
-
// Same Precedence Add/Subtract
|
297
|
-
|
298
|
-
test(
|
299
|
-
[
|
300
|
-
'SelectQuery',
|
301
|
-
[
|
302
|
-
'Select',
|
303
|
-
[
|
304
|
-
[
|
305
|
-
'Add',
|
306
|
-
['Add', ['Number', 2], ['Number', 3]],
|
307
|
-
['Add', ['Number', 4], ['Number', 5]],
|
308
|
-
],
|
309
|
-
],
|
310
|
-
],
|
311
|
-
],
|
312
|
-
(result, sqlEquals) => {
|
313
|
-
it('should produce a valid Add statement when there are nested Additions', () => {
|
314
|
-
sqlEquals(result, 'SELECT (2 + 3) + (4 + 5)');
|
315
|
-
});
|
316
|
-
},
|
317
|
-
);
|
318
|
-
|
319
|
-
test(
|
320
|
-
[
|
321
|
-
'SelectQuery',
|
322
|
-
[
|
323
|
-
'Select',
|
324
|
-
[
|
325
|
-
[
|
326
|
-
'Add',
|
327
|
-
['Subtract', ['Number', 2], ['Number', 3]],
|
328
|
-
['Subtract', ['Number', 4], ['Number', 5]],
|
329
|
-
],
|
330
|
-
],
|
331
|
-
],
|
332
|
-
],
|
333
|
-
(result, sqlEquals) => {
|
334
|
-
it('should produce a valid Add statement when there are nested Subtractions', () => {
|
335
|
-
sqlEquals(result, 'SELECT (2 - 3) + (4 - 5)');
|
336
|
-
});
|
337
|
-
},
|
338
|
-
);
|
339
|
-
|
340
|
-
test(
|
341
|
-
[
|
342
|
-
'SelectQuery',
|
343
|
-
[
|
344
|
-
'Select',
|
345
|
-
[
|
346
|
-
[
|
347
|
-
'Subtract',
|
348
|
-
['Add', ['Number', 2], ['Number', 3]],
|
349
|
-
['Add', ['Number', 4], ['Number', 5]],
|
350
|
-
],
|
351
|
-
],
|
352
|
-
],
|
353
|
-
],
|
354
|
-
(result, sqlEquals) => {
|
355
|
-
it('should produce a valid Subtract statement when there are nested Additions', () => {
|
356
|
-
sqlEquals(result, 'SELECT (2 + 3) - (4 + 5)');
|
357
|
-
});
|
358
|
-
},
|
359
|
-
);
|
360
|
-
|
361
|
-
test(
|
362
|
-
[
|
363
|
-
'SelectQuery',
|
364
|
-
[
|
365
|
-
'Select',
|
366
|
-
[
|
367
|
-
[
|
368
|
-
'Subtract',
|
369
|
-
['Subtract', ['Number', 2], ['Number', 3]],
|
370
|
-
['Subtract', ['Number', 4], ['Number', 5]],
|
371
|
-
],
|
372
|
-
],
|
373
|
-
],
|
374
|
-
],
|
375
|
-
(result, sqlEquals) => {
|
376
|
-
it('should produce a valid Add statement when there are nested Subtractions', () => {
|
377
|
-
sqlEquals(result, 'SELECT (2 - 3) - (4 - 5)');
|
378
|
-
});
|
379
|
-
},
|
380
|
-
);
|
381
|
-
|
382
|
-
// Same Precedence Multiply/Divide
|
383
|
-
|
384
|
-
test(
|
385
|
-
[
|
386
|
-
'SelectQuery',
|
387
|
-
[
|
388
|
-
'Select',
|
389
|
-
[
|
390
|
-
[
|
391
|
-
'Multiply',
|
392
|
-
['Multiply', ['Number', 2], ['Number', 3]],
|
393
|
-
['Multiply', ['Number', 4], ['Number', 5]],
|
394
|
-
],
|
395
|
-
],
|
396
|
-
],
|
397
|
-
],
|
398
|
-
(result, sqlEquals) => {
|
399
|
-
it('should produce a valid Multiply statement when there are nested Multiplications', () => {
|
400
|
-
sqlEquals(result, 'SELECT (2 * 3) * (4 * 5)');
|
401
|
-
});
|
402
|
-
},
|
403
|
-
);
|
404
|
-
|
405
|
-
test(
|
406
|
-
[
|
407
|
-
'SelectQuery',
|
408
|
-
[
|
409
|
-
'Select',
|
410
|
-
[
|
411
|
-
[
|
412
|
-
'Multiply',
|
413
|
-
['Divide', ['Number', 2], ['Number', 3]],
|
414
|
-
['Divide', ['Number', 4], ['Number', 5]],
|
415
|
-
],
|
416
|
-
],
|
417
|
-
],
|
418
|
-
],
|
419
|
-
(result, sqlEquals) => {
|
420
|
-
it('should produce a valid Multiply statement when there are nested Divisions', () => {
|
421
|
-
sqlEquals(result, 'SELECT (2 / 3) * (4 / 5)');
|
422
|
-
});
|
423
|
-
},
|
424
|
-
);
|
425
|
-
|
426
|
-
test(
|
427
|
-
[
|
428
|
-
'SelectQuery',
|
429
|
-
[
|
430
|
-
'Select',
|
431
|
-
[
|
432
|
-
[
|
433
|
-
'Divide',
|
434
|
-
['Multiply', ['Number', 2], ['Number', 3]],
|
435
|
-
['Multiply', ['Number', 4], ['Number', 5]],
|
436
|
-
],
|
437
|
-
],
|
438
|
-
],
|
439
|
-
],
|
440
|
-
(result, sqlEquals) => {
|
441
|
-
it('should produce a valid Divide statement when there are nested Multiplications', () => {
|
442
|
-
sqlEquals(result, 'SELECT (2 * 3) / (4 * 5)');
|
443
|
-
});
|
444
|
-
},
|
445
|
-
);
|
446
|
-
|
447
|
-
test(
|
448
|
-
[
|
449
|
-
'SelectQuery',
|
450
|
-
[
|
451
|
-
'Select',
|
452
|
-
[
|
453
|
-
[
|
454
|
-
'Divide',
|
455
|
-
['Divide', ['Number', 2], ['Number', 3]],
|
456
|
-
['Divide', ['Number', 4], ['Number', 5]],
|
457
|
-
],
|
458
|
-
],
|
459
|
-
],
|
460
|
-
],
|
461
|
-
(result, sqlEquals) => {
|
462
|
-
it('should produce a valid Multiply statement when there are nested Divisions', () => {
|
463
|
-
sqlEquals(result, 'SELECT (2 / 3) / (4 / 5)');
|
464
|
-
});
|
465
|
-
},
|
466
|
-
);
|
467
|
-
});
|
@@ -1,200 +0,0 @@
|
|
1
|
-
import { stripIndent } from 'common-tags';
|
2
|
-
import test from './test.js';
|
3
|
-
|
4
|
-
describe('Nested OR EQUALs should create a single IN statement', () => {
|
5
|
-
test(
|
6
|
-
[
|
7
|
-
'SelectQuery',
|
8
|
-
['Select', []],
|
9
|
-
['From', ['Table', 'table']],
|
10
|
-
[
|
11
|
-
'Where',
|
12
|
-
[
|
13
|
-
'Or',
|
14
|
-
['Equals', ['ReferencedField', 'table', 'field1'], ['Text', 'a']],
|
15
|
-
[
|
16
|
-
'Or',
|
17
|
-
['Equals', ['ReferencedField', 'table', 'field1'], ['Text', 'b']],
|
18
|
-
[
|
19
|
-
'Or',
|
20
|
-
['Equals', ['ReferencedField', 'table', 'field1'], ['Text', 'c']],
|
21
|
-
['Equals', ['ReferencedField', 'table', 'field1'], ['Text', 'd']],
|
22
|
-
],
|
23
|
-
],
|
24
|
-
],
|
25
|
-
],
|
26
|
-
],
|
27
|
-
[
|
28
|
-
['Text', 'a'],
|
29
|
-
['Text', 'b'],
|
30
|
-
['Text', 'c'],
|
31
|
-
['Text', 'd'],
|
32
|
-
],
|
33
|
-
(result, sqlEquals) => {
|
34
|
-
it('should produce a single IN statement', () => {
|
35
|
-
sqlEquals(
|
36
|
-
result,
|
37
|
-
stripIndent`
|
38
|
-
SELECT 1
|
39
|
-
FROM "table"
|
40
|
-
WHERE "table"."field1" IN ($1, $2, $3, $4)
|
41
|
-
`,
|
42
|
-
);
|
43
|
-
});
|
44
|
-
},
|
45
|
-
);
|
46
|
-
});
|
47
|
-
|
48
|
-
describe('Nested AND NOT EQUALs should create a single NOT IN statement', () => {
|
49
|
-
test(
|
50
|
-
[
|
51
|
-
'SelectQuery',
|
52
|
-
['Select', []],
|
53
|
-
['From', ['Table', 'table']],
|
54
|
-
[
|
55
|
-
'Where',
|
56
|
-
[
|
57
|
-
'And',
|
58
|
-
['NotEquals', ['ReferencedField', 'table', 'field1'], ['Text', 'a']],
|
59
|
-
[
|
60
|
-
'And',
|
61
|
-
[
|
62
|
-
'NotEquals',
|
63
|
-
['ReferencedField', 'table', 'field1'],
|
64
|
-
['Text', 'b'],
|
65
|
-
],
|
66
|
-
[
|
67
|
-
'And',
|
68
|
-
[
|
69
|
-
'NotEquals',
|
70
|
-
['ReferencedField', 'table', 'field1'],
|
71
|
-
['Text', 'c'],
|
72
|
-
],
|
73
|
-
[
|
74
|
-
'NotEquals',
|
75
|
-
['ReferencedField', 'table', 'field1'],
|
76
|
-
['Text', 'd'],
|
77
|
-
],
|
78
|
-
],
|
79
|
-
],
|
80
|
-
],
|
81
|
-
],
|
82
|
-
],
|
83
|
-
[
|
84
|
-
['Text', 'a'],
|
85
|
-
['Text', 'b'],
|
86
|
-
['Text', 'c'],
|
87
|
-
['Text', 'd'],
|
88
|
-
],
|
89
|
-
(result, sqlEquals) => {
|
90
|
-
it('should produce a single IN statement', () => {
|
91
|
-
sqlEquals(
|
92
|
-
result,
|
93
|
-
stripIndent`
|
94
|
-
SELECT 1
|
95
|
-
FROM "table"
|
96
|
-
WHERE "table"."field1" NOT IN ($1, $2, $3, $4)
|
97
|
-
`,
|
98
|
-
);
|
99
|
-
});
|
100
|
-
},
|
101
|
-
);
|
102
|
-
});
|
103
|
-
|
104
|
-
describe('OR IN/EQUALs should create a single IN statement', () => {
|
105
|
-
test(
|
106
|
-
[
|
107
|
-
'SelectQuery',
|
108
|
-
['Select', []],
|
109
|
-
['From', ['Table', 'table']],
|
110
|
-
[
|
111
|
-
'Where',
|
112
|
-
[
|
113
|
-
'Or',
|
114
|
-
[
|
115
|
-
'In',
|
116
|
-
['ReferencedField', 'table', 'field1'],
|
117
|
-
['Text', 'a'],
|
118
|
-
['Text', 'b'],
|
119
|
-
],
|
120
|
-
[
|
121
|
-
'Or',
|
122
|
-
['Equals', ['ReferencedField', 'table', 'field1'], ['Text', 'c']],
|
123
|
-
['Equals', ['ReferencedField', 'table', 'field1'], ['Text', 'd']],
|
124
|
-
],
|
125
|
-
],
|
126
|
-
],
|
127
|
-
],
|
128
|
-
[
|
129
|
-
['Text', 'a'],
|
130
|
-
['Text', 'b'],
|
131
|
-
['Text', 'c'],
|
132
|
-
['Text', 'd'],
|
133
|
-
],
|
134
|
-
(result, sqlEquals) => {
|
135
|
-
it('should produce a single in statement', () => {
|
136
|
-
sqlEquals(
|
137
|
-
result,
|
138
|
-
stripIndent`
|
139
|
-
SELECT 1
|
140
|
-
FROM "table"
|
141
|
-
WHERE "table"."field1" IN ($1, $2, $3, $4)
|
142
|
-
`,
|
143
|
-
);
|
144
|
-
});
|
145
|
-
},
|
146
|
-
);
|
147
|
-
});
|
148
|
-
|
149
|
-
describe('AND NOT IN/NOT EQUALs should create a single NOT IN statement', () => {
|
150
|
-
test(
|
151
|
-
[
|
152
|
-
'SelectQuery',
|
153
|
-
['Select', []],
|
154
|
-
['From', ['Table', 'table']],
|
155
|
-
[
|
156
|
-
'Where',
|
157
|
-
[
|
158
|
-
'And',
|
159
|
-
[
|
160
|
-
'NotIn',
|
161
|
-
['ReferencedField', 'table', 'field1'],
|
162
|
-
['Text', 'a'],
|
163
|
-
['Text', 'b'],
|
164
|
-
],
|
165
|
-
[
|
166
|
-
'And',
|
167
|
-
[
|
168
|
-
'NotEquals',
|
169
|
-
['ReferencedField', 'table', 'field1'],
|
170
|
-
['Text', 'c'],
|
171
|
-
],
|
172
|
-
[
|
173
|
-
'NotEquals',
|
174
|
-
['ReferencedField', 'table', 'field1'],
|
175
|
-
['Text', 'd'],
|
176
|
-
],
|
177
|
-
],
|
178
|
-
],
|
179
|
-
],
|
180
|
-
],
|
181
|
-
[
|
182
|
-
['Text', 'a'],
|
183
|
-
['Text', 'b'],
|
184
|
-
['Text', 'c'],
|
185
|
-
['Text', 'd'],
|
186
|
-
],
|
187
|
-
(result, sqlEquals) => {
|
188
|
-
it('should produce a single not in statement', () => {
|
189
|
-
sqlEquals(
|
190
|
-
result,
|
191
|
-
stripIndent`
|
192
|
-
SELECT 1
|
193
|
-
FROM "table"
|
194
|
-
WHERE "table"."field1" NOT IN ($1, $2, $3, $4)
|
195
|
-
`,
|
196
|
-
);
|
197
|
-
});
|
198
|
-
},
|
199
|
-
);
|
200
|
-
});
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import { stripIndent } from 'common-tags';
|
2
|
-
import test from './test.js';
|
3
|
-
|
4
|
-
describe('NOT(NOT(...)) should cancel each other out', () => {
|
5
|
-
test(['Not', ['Not', ['Boolean', true]]], [], (result, sqlEquals) => {
|
6
|
-
it('should produce a query using the boolean directly', () => {
|
7
|
-
sqlEquals(
|
8
|
-
result,
|
9
|
-
stripIndent`
|
10
|
-
SELECT TRUE AS "result";
|
11
|
-
`,
|
12
|
-
);
|
13
|
-
});
|
14
|
-
});
|
15
|
-
});
|