@balena/abstract-sql-compiler 11.0.0-build-11-x-45529f014aa1c181f338c0f7348767f2990a9084-1 → 11.0.0-build-11-x-7511b8ebe5a9461f20add0ed97d0670ed3b5a479-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/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,360 +0,0 @@
|
|
1
|
-
import { stripIndent } from 'common-tags';
|
2
|
-
import test from './test.js';
|
3
|
-
|
4
|
-
describe('Between', () => {
|
5
|
-
test(
|
6
|
-
[
|
7
|
-
'SelectQuery',
|
8
|
-
['Select', [['Between', ['Number', 5], ['Number', 3], ['Number', 8]]]],
|
9
|
-
],
|
10
|
-
(result, sqlEquals) => {
|
11
|
-
it('should produce a valid Between statement', () => {
|
12
|
-
sqlEquals(result, 'SELECT 5 BETWEEN 3 AND (8)');
|
13
|
-
});
|
14
|
-
},
|
15
|
-
);
|
16
|
-
});
|
17
|
-
|
18
|
-
describe('Equals Any', () => {
|
19
|
-
test(
|
20
|
-
['SelectQuery', ['Select', [['EqualsAny', ['Number', 5], ['Bind', 0]]]]],
|
21
|
-
[['Bind', 0]],
|
22
|
-
(result, sqlEquals) => {
|
23
|
-
it('should produce a valid EqualsAny statement', () => {
|
24
|
-
sqlEquals(result, 'SELECT 5 = ANY($1)');
|
25
|
-
});
|
26
|
-
},
|
27
|
-
);
|
28
|
-
});
|
29
|
-
|
30
|
-
describe('Comparison Operator Precedence', () => {
|
31
|
-
// Different precedence
|
32
|
-
test(
|
33
|
-
[
|
34
|
-
'SelectQuery',
|
35
|
-
[
|
36
|
-
'Select',
|
37
|
-
[
|
38
|
-
[
|
39
|
-
'Equals',
|
40
|
-
['Boolean', true],
|
41
|
-
['Equals', ['Boolean', true], ['Boolean', true]],
|
42
|
-
],
|
43
|
-
],
|
44
|
-
],
|
45
|
-
],
|
46
|
-
(result, sqlEquals) => {
|
47
|
-
it('should produce a valid Equals statement when the second operand is also an Equals', () => {
|
48
|
-
sqlEquals(result, 'SELECT TRUE = (TRUE = TRUE)');
|
49
|
-
});
|
50
|
-
},
|
51
|
-
);
|
52
|
-
|
53
|
-
test(
|
54
|
-
[
|
55
|
-
'SelectQuery',
|
56
|
-
[
|
57
|
-
'Select',
|
58
|
-
[
|
59
|
-
[
|
60
|
-
'NotEquals',
|
61
|
-
['Equals', ['Boolean', false], ['Boolean', false]],
|
62
|
-
['Equals', ['Boolean', true], ['Boolean', true]],
|
63
|
-
],
|
64
|
-
],
|
65
|
-
],
|
66
|
-
],
|
67
|
-
(result, sqlEquals) => {
|
68
|
-
it('should produce a valid NotEquals statement when both operands are Equals comparisons', () => {
|
69
|
-
sqlEquals(result, 'SELECT (FALSE = FALSE) != (TRUE = TRUE)');
|
70
|
-
});
|
71
|
-
},
|
72
|
-
);
|
73
|
-
|
74
|
-
test(
|
75
|
-
[
|
76
|
-
'SelectQuery',
|
77
|
-
[
|
78
|
-
'Select',
|
79
|
-
[
|
80
|
-
[
|
81
|
-
'NotEquals',
|
82
|
-
[
|
83
|
-
'Add',
|
84
|
-
['Integer', 1],
|
85
|
-
[
|
86
|
-
'Add',
|
87
|
-
['Integer', 2],
|
88
|
-
['Multiply', ['Integer', 3], ['Integer', 4]],
|
89
|
-
],
|
90
|
-
],
|
91
|
-
['Add', ['Integer', 1], ['Integer', 0]],
|
92
|
-
],
|
93
|
-
],
|
94
|
-
],
|
95
|
-
],
|
96
|
-
(result, sqlEquals) => {
|
97
|
-
it('should produce a valid NotEquals statement when the operands are math expressions with nested parenthesis', () => {
|
98
|
-
sqlEquals(
|
99
|
-
result,
|
100
|
-
stripIndent`
|
101
|
-
SELECT 1 + (2 + (3 * 4)) != 1 + 0
|
102
|
-
`,
|
103
|
-
);
|
104
|
-
});
|
105
|
-
},
|
106
|
-
);
|
107
|
-
|
108
|
-
test(
|
109
|
-
[
|
110
|
-
'SelectQuery',
|
111
|
-
[
|
112
|
-
'Select',
|
113
|
-
[
|
114
|
-
[
|
115
|
-
'GreaterThanOrEqual',
|
116
|
-
[
|
117
|
-
'Multiply',
|
118
|
-
['Add', ['Integer', 1], ['Integer', 2]],
|
119
|
-
['Integer', 5],
|
120
|
-
],
|
121
|
-
['Add', ['Integer', 12], ['Integer', 2]],
|
122
|
-
],
|
123
|
-
],
|
124
|
-
],
|
125
|
-
],
|
126
|
-
(result, sqlEquals) => {
|
127
|
-
// Evaluating this would match the expression w/o parenthesis
|
128
|
-
it('should produce a valid NotEquals statement when the operands are math expressions with left sided parenthesis', () => {
|
129
|
-
sqlEquals(
|
130
|
-
result,
|
131
|
-
stripIndent`
|
132
|
-
SELECT (1 + 2) * 5 >= 12 + 2
|
133
|
-
`,
|
134
|
-
);
|
135
|
-
});
|
136
|
-
},
|
137
|
-
);
|
138
|
-
|
139
|
-
test(
|
140
|
-
[
|
141
|
-
'SelectQuery',
|
142
|
-
[
|
143
|
-
'Select',
|
144
|
-
[
|
145
|
-
[
|
146
|
-
'GreaterThanOrEqual',
|
147
|
-
[
|
148
|
-
'Add',
|
149
|
-
['Integer', 1],
|
150
|
-
['Multiply', ['Integer', 2], ['Integer', 5]],
|
151
|
-
],
|
152
|
-
['Add', ['Integer', 12], ['Integer', 2]],
|
153
|
-
],
|
154
|
-
],
|
155
|
-
],
|
156
|
-
],
|
157
|
-
(result, sqlEquals) => {
|
158
|
-
// Evaluating this would give a different result than if it was w/o parenthesis
|
159
|
-
it('should produce a valid NotEquals statement when the operands are math expressions with right sided parenthesis', () => {
|
160
|
-
sqlEquals(
|
161
|
-
result,
|
162
|
-
stripIndent`
|
163
|
-
SELECT 1 + (2 * 5) >= 12 + 2
|
164
|
-
`,
|
165
|
-
);
|
166
|
-
});
|
167
|
-
},
|
168
|
-
);
|
169
|
-
|
170
|
-
test(
|
171
|
-
[
|
172
|
-
'SelectQuery',
|
173
|
-
[
|
174
|
-
'Select',
|
175
|
-
[
|
176
|
-
[
|
177
|
-
'And',
|
178
|
-
[
|
179
|
-
'Or',
|
180
|
-
['GreaterThan', ['Integer', 1], ['Integer', 0]],
|
181
|
-
['LessThan', ['Integer', 1], ['Integer', 0]],
|
182
|
-
],
|
183
|
-
['GreaterThan', ['Integer', 1], ['Integer', 0]],
|
184
|
-
],
|
185
|
-
],
|
186
|
-
],
|
187
|
-
],
|
188
|
-
(result, sqlEquals) => {
|
189
|
-
it('should produce a valid And statement when the operands are composite boolean expressions', () => {
|
190
|
-
sqlEquals(
|
191
|
-
result,
|
192
|
-
stripIndent`
|
193
|
-
SELECT (1 > 0
|
194
|
-
OR 1 < 0)
|
195
|
-
AND 1 > 0
|
196
|
-
`,
|
197
|
-
);
|
198
|
-
});
|
199
|
-
},
|
200
|
-
);
|
201
|
-
|
202
|
-
test(
|
203
|
-
[
|
204
|
-
'SelectQuery',
|
205
|
-
[
|
206
|
-
'Select',
|
207
|
-
[
|
208
|
-
[
|
209
|
-
'Or',
|
210
|
-
[
|
211
|
-
'And',
|
212
|
-
['GreaterThan', ['Integer', 0], ['Integer', 1]],
|
213
|
-
['Equals', ['Integer', 0], ['Integer', 1]],
|
214
|
-
],
|
215
|
-
['GreaterThan', ['Integer', 1], ['Integer', 0]],
|
216
|
-
],
|
217
|
-
],
|
218
|
-
],
|
219
|
-
],
|
220
|
-
(result, sqlEquals) => {
|
221
|
-
// Even though the parenthesis are not added around the AND, the expression is correct b/c of precedence.
|
222
|
-
it('should produce a valid Or statement when the first operand is a composite boolean expression', () => {
|
223
|
-
sqlEquals(
|
224
|
-
result,
|
225
|
-
stripIndent`
|
226
|
-
SELECT (0 > 1
|
227
|
-
AND 0 = 1
|
228
|
-
OR 1 > 0)
|
229
|
-
`,
|
230
|
-
);
|
231
|
-
});
|
232
|
-
},
|
233
|
-
);
|
234
|
-
|
235
|
-
test(
|
236
|
-
[
|
237
|
-
'SelectQuery',
|
238
|
-
[
|
239
|
-
'Select',
|
240
|
-
[
|
241
|
-
[
|
242
|
-
'Or',
|
243
|
-
['GreaterThan', ['Integer', 1], ['Integer', 0]],
|
244
|
-
[
|
245
|
-
'And',
|
246
|
-
['Equals', ['Integer', 0], ['Integer', 1]],
|
247
|
-
['GreaterThan', ['Integer', 0], ['Integer', 1]],
|
248
|
-
],
|
249
|
-
],
|
250
|
-
],
|
251
|
-
],
|
252
|
-
],
|
253
|
-
(result, sqlEquals) => {
|
254
|
-
// Even though the parenthesis are not added around the AND, the expression is correct b/c of precedence.
|
255
|
-
it('should produce a valid Or statement when the second operand is a composite boolean expression', () => {
|
256
|
-
sqlEquals(
|
257
|
-
result,
|
258
|
-
stripIndent`
|
259
|
-
SELECT (1 > 0
|
260
|
-
OR 0 = 1
|
261
|
-
AND 0 > 1)
|
262
|
-
`,
|
263
|
-
);
|
264
|
-
});
|
265
|
-
},
|
266
|
-
);
|
267
|
-
|
268
|
-
test(
|
269
|
-
[
|
270
|
-
'SelectQuery',
|
271
|
-
[
|
272
|
-
'Select',
|
273
|
-
[
|
274
|
-
[
|
275
|
-
'And',
|
276
|
-
[
|
277
|
-
'Or',
|
278
|
-
['GreaterThan', ['Integer', 1], ['Integer', 0]],
|
279
|
-
['Equals', ['Integer', 0], ['Integer', 1]],
|
280
|
-
],
|
281
|
-
['GreaterThan', ['Integer', 0], ['Integer', 1]],
|
282
|
-
],
|
283
|
-
],
|
284
|
-
],
|
285
|
-
],
|
286
|
-
(result, sqlEquals) => {
|
287
|
-
// If it was w/o parenthesis, evaluating this would give a different result
|
288
|
-
it('should produce a valid And statement when the first operand is an Or boolean expressions', () => {
|
289
|
-
sqlEquals(
|
290
|
-
result,
|
291
|
-
stripIndent`
|
292
|
-
SELECT (1 > 0
|
293
|
-
OR 0 = 1)
|
294
|
-
AND 0 > 1
|
295
|
-
`,
|
296
|
-
);
|
297
|
-
});
|
298
|
-
},
|
299
|
-
);
|
300
|
-
|
301
|
-
test(
|
302
|
-
[
|
303
|
-
'SelectQuery',
|
304
|
-
[
|
305
|
-
'Select',
|
306
|
-
[
|
307
|
-
[
|
308
|
-
'And',
|
309
|
-
['GreaterThan', ['Integer', 0], ['Integer', 1]],
|
310
|
-
[
|
311
|
-
'Or',
|
312
|
-
['Equals', ['Integer', 0], ['Integer', 1]],
|
313
|
-
['GreaterThan', ['Integer', 1], ['Integer', 0]],
|
314
|
-
],
|
315
|
-
],
|
316
|
-
],
|
317
|
-
],
|
318
|
-
],
|
319
|
-
(result, sqlEquals) => {
|
320
|
-
// If it was w/o parenthesis, evaluating this would give a different result
|
321
|
-
it('should produce a valid And statement when the second operand is an Or boolean expressions', () => {
|
322
|
-
sqlEquals(
|
323
|
-
result,
|
324
|
-
stripIndent`
|
325
|
-
SELECT 0 > 1
|
326
|
-
AND (0 = 1
|
327
|
-
OR 1 > 0)
|
328
|
-
`,
|
329
|
-
);
|
330
|
-
});
|
331
|
-
},
|
332
|
-
);
|
333
|
-
|
334
|
-
test(
|
335
|
-
[
|
336
|
-
'SelectQuery',
|
337
|
-
[
|
338
|
-
'Select',
|
339
|
-
[
|
340
|
-
[
|
341
|
-
'Between',
|
342
|
-
['Add', ['Integer', 1], ['Integer', 0]],
|
343
|
-
['Add', ['Integer', 1], ['Integer', 0]],
|
344
|
-
['Add', ['Integer', 1], ['Integer', 0]],
|
345
|
-
],
|
346
|
-
],
|
347
|
-
],
|
348
|
-
],
|
349
|
-
(result, sqlEquals) => {
|
350
|
-
it('should produce a valid Between statement when the operands are math expressions', () => {
|
351
|
-
sqlEquals(
|
352
|
-
result,
|
353
|
-
stripIndent`
|
354
|
-
SELECT 1 + 0 BETWEEN 1 + 0 AND (1 + 0)
|
355
|
-
`,
|
356
|
-
);
|
357
|
-
});
|
358
|
-
},
|
359
|
-
);
|
360
|
-
});
|