@powersync/service-sync-rules 0.0.0-dev-20240708103353
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/LICENSE +67 -0
- package/README.md +129 -0
- package/dist/DartSchemaGenerator.d.ts +12 -0
- package/dist/DartSchemaGenerator.js +39 -0
- package/dist/DartSchemaGenerator.js.map +1 -0
- package/dist/ExpressionType.d.ts +33 -0
- package/dist/ExpressionType.js +61 -0
- package/dist/ExpressionType.js.map +1 -0
- package/dist/IdSequence.d.ts +4 -0
- package/dist/IdSequence.js +9 -0
- package/dist/IdSequence.js.map +1 -0
- package/dist/JsSchemaGenerator.d.ts +12 -0
- package/dist/JsSchemaGenerator.js +42 -0
- package/dist/JsSchemaGenerator.js.map +1 -0
- package/dist/SchemaGenerator.d.ts +14 -0
- package/dist/SchemaGenerator.js +26 -0
- package/dist/SchemaGenerator.js.map +1 -0
- package/dist/SourceTableInterface.d.ts +5 -0
- package/dist/SourceTableInterface.js +2 -0
- package/dist/SourceTableInterface.js.map +1 -0
- package/dist/SqlBucketDescriptor.d.ts +37 -0
- package/dist/SqlBucketDescriptor.js +111 -0
- package/dist/SqlBucketDescriptor.js.map +1 -0
- package/dist/SqlDataQuery.d.ts +39 -0
- package/dist/SqlDataQuery.js +239 -0
- package/dist/SqlDataQuery.js.map +1 -0
- package/dist/SqlParameterQuery.d.ts +85 -0
- package/dist/SqlParameterQuery.js +311 -0
- package/dist/SqlParameterQuery.js.map +1 -0
- package/dist/SqlSyncRules.d.ts +52 -0
- package/dist/SqlSyncRules.js +264 -0
- package/dist/SqlSyncRules.js.map +1 -0
- package/dist/StaticSchema.d.ts +26 -0
- package/dist/StaticSchema.js +61 -0
- package/dist/StaticSchema.js.map +1 -0
- package/dist/StaticSqlParameterQuery.d.ts +27 -0
- package/dist/StaticSqlParameterQuery.js +96 -0
- package/dist/StaticSqlParameterQuery.js.map +1 -0
- package/dist/TablePattern.d.ts +17 -0
- package/dist/TablePattern.js +56 -0
- package/dist/TablePattern.js.map +1 -0
- package/dist/TableQuerySchema.d.ts +9 -0
- package/dist/TableQuerySchema.js +34 -0
- package/dist/TableQuerySchema.js.map +1 -0
- package/dist/errors.d.ts +22 -0
- package/dist/errors.js +58 -0
- package/dist/errors.js.map +1 -0
- package/dist/generators.d.ts +6 -0
- package/dist/generators.js +7 -0
- package/dist/generators.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/json_schema.d.ts +3 -0
- package/dist/json_schema.js +52 -0
- package/dist/json_schema.js.map +1 -0
- package/dist/request_functions.d.ts +17 -0
- package/dist/request_functions.js +41 -0
- package/dist/request_functions.js.map +1 -0
- package/dist/sql_filters.d.ts +125 -0
- package/dist/sql_filters.js +599 -0
- package/dist/sql_filters.js.map +1 -0
- package/dist/sql_functions.d.ts +61 -0
- package/dist/sql_functions.js +863 -0
- package/dist/sql_functions.js.map +1 -0
- package/dist/sql_support.d.ts +25 -0
- package/dist/sql_support.js +254 -0
- package/dist/sql_support.js.map +1 -0
- package/dist/types.d.ts +262 -0
- package/dist/types.js +28 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +44 -0
- package/dist/utils.js +167 -0
- package/dist/utils.js.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,599 @@
|
|
|
1
|
+
import { ExpressionType, TYPE_NONE } from './ExpressionType.js';
|
|
2
|
+
import { SqlRuleError } from './errors.js';
|
|
3
|
+
import { BASIC_OPERATORS, OPERATOR_IS_NOT_NULL, OPERATOR_IS_NULL, OPERATOR_JSON_EXTRACT_JSON, OPERATOR_JSON_EXTRACT_SQL, OPERATOR_NOT, SQL_FUNCTIONS, castOperator, sqliteTypeOf } from './sql_functions.js';
|
|
4
|
+
import { SQLITE_FALSE, SQLITE_TRUE, andFilters, compileStaticOperator, getOperatorFunction, isClauseError, isParameterMatchClause, isParameterValueClause, isRowValueClause, isStaticValueClause, orFilters, toBooleanParameterSetClause } from './sql_support.js';
|
|
5
|
+
import { isJsonValue } from './utils.js';
|
|
6
|
+
import { JSONBig } from '@powersync/service-jsonbig';
|
|
7
|
+
import { REQUEST_FUNCTIONS } from './request_functions.js';
|
|
8
|
+
export const MATCH_CONST_FALSE = [];
|
|
9
|
+
export const MATCH_CONST_TRUE = [{}];
|
|
10
|
+
Object.freeze(MATCH_CONST_TRUE);
|
|
11
|
+
Object.freeze(MATCH_CONST_FALSE);
|
|
12
|
+
export class SqlTools {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.errors = [];
|
|
15
|
+
this.default_table = options.table;
|
|
16
|
+
this.schema = options.schema;
|
|
17
|
+
if (options.value_tables) {
|
|
18
|
+
this.value_tables = options.value_tables;
|
|
19
|
+
}
|
|
20
|
+
else if (this.default_table) {
|
|
21
|
+
this.value_tables = [this.default_table];
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this.value_tables = [];
|
|
25
|
+
}
|
|
26
|
+
this.parameter_tables = options.parameter_tables ?? [];
|
|
27
|
+
this.sql = options.sql;
|
|
28
|
+
this.supports_expanding_parameters = options.supports_expanding_parameters ?? false;
|
|
29
|
+
this.supports_parameter_expressions = options.supports_parameter_expressions ?? false;
|
|
30
|
+
}
|
|
31
|
+
error(message, expr) {
|
|
32
|
+
this.errors.push(new SqlRuleError(message, this.sql, expr));
|
|
33
|
+
return { error: true };
|
|
34
|
+
}
|
|
35
|
+
warn(message, expr) {
|
|
36
|
+
const error = new SqlRuleError(message, this.sql, expr);
|
|
37
|
+
error.type = 'warning';
|
|
38
|
+
this.errors.push(error);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Compile the where clause into a ParameterMatchClause.
|
|
42
|
+
*
|
|
43
|
+
* A ParameterMatchClause takes a data row, and returns filter values that
|
|
44
|
+
* would make the expression true for the row.
|
|
45
|
+
*/
|
|
46
|
+
compileWhereClause(where) {
|
|
47
|
+
const base = this.compileClause(where);
|
|
48
|
+
return toBooleanParameterSetClause(base);
|
|
49
|
+
}
|
|
50
|
+
compileRowValueExtractor(expr) {
|
|
51
|
+
const clause = this.compileClause(expr);
|
|
52
|
+
if (!isRowValueClause(clause) && !isClauseError(clause)) {
|
|
53
|
+
return this.error('Parameter match expression is not allowed here', expr ?? undefined);
|
|
54
|
+
}
|
|
55
|
+
return clause;
|
|
56
|
+
}
|
|
57
|
+
compileParameterValueExtractor(expr) {
|
|
58
|
+
const clause = this.compileClause(expr);
|
|
59
|
+
if (isClauseError(clause) || isStaticValueClause(clause) || isParameterValueClause(clause)) {
|
|
60
|
+
return clause;
|
|
61
|
+
}
|
|
62
|
+
return this.error('Parameter match expression is not allowed here', expr ?? undefined);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Given an expression, return a compiled clause.
|
|
66
|
+
*/
|
|
67
|
+
compileClause(expr) {
|
|
68
|
+
if (expr == null) {
|
|
69
|
+
return staticValueClause(SQLITE_TRUE);
|
|
70
|
+
}
|
|
71
|
+
else if (isStatic(expr)) {
|
|
72
|
+
const value = staticValue(expr);
|
|
73
|
+
return staticValueClause(value);
|
|
74
|
+
}
|
|
75
|
+
else if (expr.type == 'ref') {
|
|
76
|
+
const column = expr.name;
|
|
77
|
+
if (column == '*') {
|
|
78
|
+
return this.error('* not supported here', expr);
|
|
79
|
+
}
|
|
80
|
+
if (this.refHasSchema(expr)) {
|
|
81
|
+
return this.error(`Schema is not supported in column references`, expr);
|
|
82
|
+
}
|
|
83
|
+
if (this.isParameterRef(expr)) {
|
|
84
|
+
return this.getParameterRefClause(expr);
|
|
85
|
+
}
|
|
86
|
+
else if (this.isTableRef(expr)) {
|
|
87
|
+
const table = this.getTableName(expr);
|
|
88
|
+
this.checkRef(table, expr);
|
|
89
|
+
return {
|
|
90
|
+
evaluate(tables) {
|
|
91
|
+
return tables[table]?.[column];
|
|
92
|
+
},
|
|
93
|
+
getType(schema) {
|
|
94
|
+
return schema.getType(table, column);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
const ref = [expr.table?.schema, expr.table?.name, expr.name]
|
|
100
|
+
.filter((e) => e != null)
|
|
101
|
+
.join('.');
|
|
102
|
+
return this.error(`Undefined reference: ${ref}`, expr);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else if (expr.type == 'binary') {
|
|
106
|
+
const { left, right, op } = expr;
|
|
107
|
+
const leftFilter = this.compileClause(left);
|
|
108
|
+
const rightFilter = this.compileClause(right);
|
|
109
|
+
if (isClauseError(leftFilter) || isClauseError(rightFilter)) {
|
|
110
|
+
return { error: true };
|
|
111
|
+
}
|
|
112
|
+
if (op == 'AND') {
|
|
113
|
+
try {
|
|
114
|
+
return andFilters(leftFilter, rightFilter);
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
return this.error(e.message, expr);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else if (op == 'OR') {
|
|
121
|
+
try {
|
|
122
|
+
return orFilters(leftFilter, rightFilter);
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
return this.error(e.message, expr);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else if (op == '=') {
|
|
129
|
+
// Options:
|
|
130
|
+
// 1. row value, row value
|
|
131
|
+
// 2. row value, parameter value
|
|
132
|
+
// 3. static true, parameterMatch - not supported yet
|
|
133
|
+
// 4. parameter value, parameter value
|
|
134
|
+
let staticFilter1;
|
|
135
|
+
let otherFilter1;
|
|
136
|
+
if (this.supports_parameter_expressions &&
|
|
137
|
+
isParameterValueClause(leftFilter) &&
|
|
138
|
+
isParameterValueClause(rightFilter)) {
|
|
139
|
+
// 4. parameterValue, parameterValue
|
|
140
|
+
// This includes (static value, parameter value)
|
|
141
|
+
// Not applicable to data queries (composeFunction will error).
|
|
142
|
+
// Some of those cases can still be handled with case (2),
|
|
143
|
+
// so we filter for supports_parameter_expressions above.
|
|
144
|
+
const fnImpl = getOperatorFunction('=');
|
|
145
|
+
return this.composeFunction(fnImpl, [leftFilter, rightFilter], [left, right]);
|
|
146
|
+
}
|
|
147
|
+
if (!isRowValueClause(leftFilter) && !isRowValueClause(rightFilter)) {
|
|
148
|
+
return this.error(`Cannot have bucket parameters on both sides of = operator`, expr);
|
|
149
|
+
}
|
|
150
|
+
else if (isRowValueClause(leftFilter)) {
|
|
151
|
+
staticFilter1 = leftFilter;
|
|
152
|
+
otherFilter1 = rightFilter;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
staticFilter1 = rightFilter;
|
|
156
|
+
otherFilter1 = leftFilter;
|
|
157
|
+
}
|
|
158
|
+
const staticFilter = staticFilter1;
|
|
159
|
+
const otherFilter = otherFilter1;
|
|
160
|
+
if (isRowValueClause(otherFilter)) {
|
|
161
|
+
// 1. row value = row value
|
|
162
|
+
return compileStaticOperator(op, leftFilter, rightFilter);
|
|
163
|
+
}
|
|
164
|
+
else if (isParameterValueClause(otherFilter)) {
|
|
165
|
+
// 2. row value = parameter value
|
|
166
|
+
const inputParam = basicInputParameter(otherFilter);
|
|
167
|
+
return {
|
|
168
|
+
error: false,
|
|
169
|
+
inputParameters: [inputParam],
|
|
170
|
+
unbounded: false,
|
|
171
|
+
filterRow(tables) {
|
|
172
|
+
const value = staticFilter.evaluate(tables);
|
|
173
|
+
if (value == null) {
|
|
174
|
+
// null never matches on =
|
|
175
|
+
// Should technically return null, but "false" is sufficient here
|
|
176
|
+
return MATCH_CONST_FALSE;
|
|
177
|
+
}
|
|
178
|
+
if (!isJsonValue(value)) {
|
|
179
|
+
// Cannot persist this, e.g. BLOB
|
|
180
|
+
return MATCH_CONST_FALSE;
|
|
181
|
+
}
|
|
182
|
+
return [{ [inputParam.key]: value }];
|
|
183
|
+
},
|
|
184
|
+
usesAuthenticatedRequestParameters: otherFilter.usesAuthenticatedRequestParameters,
|
|
185
|
+
usesUnauthenticatedRequestParameters: otherFilter.usesUnauthenticatedRequestParameters
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
else if (isParameterMatchClause(otherFilter)) {
|
|
189
|
+
// 3. row value = parameterMatch
|
|
190
|
+
// (bucket.param = 'something') = staticValue
|
|
191
|
+
// To implement this, we need to ensure the static value here can only be true.
|
|
192
|
+
return this.error(`Parameter match clauses cannot be used here`, expr);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
throw new Error('Unexpected');
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else if (op == 'IN') {
|
|
199
|
+
// Options:
|
|
200
|
+
// static IN static
|
|
201
|
+
// parameterValue IN static
|
|
202
|
+
if (isRowValueClause(leftFilter) && isRowValueClause(rightFilter)) {
|
|
203
|
+
// static1 IN static2
|
|
204
|
+
return compileStaticOperator(op, leftFilter, rightFilter);
|
|
205
|
+
}
|
|
206
|
+
else if (isParameterValueClause(leftFilter) && isRowValueClause(rightFilter)) {
|
|
207
|
+
// token_parameters.value IN table.some_array
|
|
208
|
+
// bucket.param IN table.some_array
|
|
209
|
+
const inputParam = basicInputParameter(leftFilter);
|
|
210
|
+
return {
|
|
211
|
+
error: false,
|
|
212
|
+
inputParameters: [inputParam],
|
|
213
|
+
unbounded: true,
|
|
214
|
+
filterRow(tables) {
|
|
215
|
+
const aValue = rightFilter.evaluate(tables);
|
|
216
|
+
if (aValue == null) {
|
|
217
|
+
return MATCH_CONST_FALSE;
|
|
218
|
+
}
|
|
219
|
+
const values = JSON.parse(aValue);
|
|
220
|
+
if (!Array.isArray(values)) {
|
|
221
|
+
throw new Error('Not an array');
|
|
222
|
+
}
|
|
223
|
+
return values.map((value) => {
|
|
224
|
+
return { [inputParam.key]: value };
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
usesAuthenticatedRequestParameters: leftFilter.usesAuthenticatedRequestParameters,
|
|
228
|
+
usesUnauthenticatedRequestParameters: leftFilter.usesUnauthenticatedRequestParameters
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
else if (this.supports_expanding_parameters &&
|
|
232
|
+
isRowValueClause(leftFilter) &&
|
|
233
|
+
isParameterValueClause(rightFilter)) {
|
|
234
|
+
// table.some_value IN token_parameters.some_array
|
|
235
|
+
// This expands into "table_some_value = <value>" for each value of the array.
|
|
236
|
+
// We only support one such filter per query
|
|
237
|
+
const key = `${rightFilter.key}[*]`;
|
|
238
|
+
const inputParam = {
|
|
239
|
+
key: key,
|
|
240
|
+
expands: true,
|
|
241
|
+
filteredRowToLookupValue: (filterParameters) => {
|
|
242
|
+
return filterParameters[key];
|
|
243
|
+
},
|
|
244
|
+
parametersToLookupValue: (parameters) => {
|
|
245
|
+
return rightFilter.lookupParameterValue(parameters);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
return {
|
|
249
|
+
error: false,
|
|
250
|
+
inputParameters: [inputParam],
|
|
251
|
+
unbounded: false,
|
|
252
|
+
filterRow(tables) {
|
|
253
|
+
const value = leftFilter.evaluate(tables);
|
|
254
|
+
if (!isJsonValue(value)) {
|
|
255
|
+
// Cannot persist, e.g. BLOB
|
|
256
|
+
return MATCH_CONST_FALSE;
|
|
257
|
+
}
|
|
258
|
+
return [{ [inputParam.key]: value }];
|
|
259
|
+
},
|
|
260
|
+
usesAuthenticatedRequestParameters: rightFilter.usesAuthenticatedRequestParameters,
|
|
261
|
+
usesUnauthenticatedRequestParameters: rightFilter.usesUnauthenticatedRequestParameters
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
return this.error(`Unsupported usage of IN operator`, expr);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else if (BASIC_OPERATORS.has(op)) {
|
|
269
|
+
const fnImpl = getOperatorFunction(op);
|
|
270
|
+
return this.composeFunction(fnImpl, [leftFilter, rightFilter], [left, right]);
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
return this.error(`Operator not supported: ${op}`, expr);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
else if (expr.type == 'unary') {
|
|
277
|
+
if (expr.op == 'NOT') {
|
|
278
|
+
const clause = this.compileClause(expr.operand);
|
|
279
|
+
return this.composeFunction(OPERATOR_NOT, [clause], [expr.operand]);
|
|
280
|
+
}
|
|
281
|
+
else if (expr.op == 'IS NULL') {
|
|
282
|
+
const clause = this.compileClause(expr.operand);
|
|
283
|
+
return this.composeFunction(OPERATOR_IS_NULL, [clause], [expr.operand]);
|
|
284
|
+
}
|
|
285
|
+
else if (expr.op == 'IS NOT NULL') {
|
|
286
|
+
const clause = this.compileClause(expr.operand);
|
|
287
|
+
return this.composeFunction(OPERATOR_IS_NOT_NULL, [clause], [expr.operand]);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
return this.error(`Operator ${expr.op} is not supported`, expr);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
else if (expr.type == 'call' && expr.function?.name != null) {
|
|
294
|
+
const schema = expr.function.schema; // schema.function()
|
|
295
|
+
const fn = expr.function.name;
|
|
296
|
+
if (schema == null) {
|
|
297
|
+
// Just fn()
|
|
298
|
+
const fnImpl = SQL_FUNCTIONS[fn];
|
|
299
|
+
if (fnImpl == null) {
|
|
300
|
+
return this.error(`Function '${fn}' is not defined`, expr);
|
|
301
|
+
}
|
|
302
|
+
const argClauses = expr.args.map((arg) => this.compileClause(arg));
|
|
303
|
+
const composed = this.composeFunction(fnImpl, argClauses, expr.args);
|
|
304
|
+
return composed;
|
|
305
|
+
}
|
|
306
|
+
else if (schema == 'request') {
|
|
307
|
+
// Special function
|
|
308
|
+
if (!this.supports_parameter_expressions) {
|
|
309
|
+
return this.error(`${schema} schema is not available in data queries`, expr);
|
|
310
|
+
}
|
|
311
|
+
if (expr.args.length > 0) {
|
|
312
|
+
return this.error(`Function '${schema}.${fn}' does not take arguments`, expr);
|
|
313
|
+
}
|
|
314
|
+
if (fn in REQUEST_FUNCTIONS) {
|
|
315
|
+
const fnImpl = REQUEST_FUNCTIONS[fn];
|
|
316
|
+
return {
|
|
317
|
+
key: 'request.parameters()',
|
|
318
|
+
lookupParameterValue(parameters) {
|
|
319
|
+
return fnImpl.call(parameters);
|
|
320
|
+
},
|
|
321
|
+
usesAuthenticatedRequestParameters: fnImpl.usesAuthenticatedRequestParameters,
|
|
322
|
+
usesUnauthenticatedRequestParameters: fnImpl.usesUnauthenticatedRequestParameters
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
return this.error(`Function '${schema}.${fn}' is not defined`, expr);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
// Unknown function with schema
|
|
331
|
+
return this.error(`Function '${schema}.${fn}' is not defined`, expr);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
else if (expr.type == 'member') {
|
|
335
|
+
const operand = this.compileClause(expr.operand);
|
|
336
|
+
if (!(typeof expr.member == 'string' && (expr.op == '->>' || expr.op == '->'))) {
|
|
337
|
+
return this.error(`Unsupported member operation ${expr.op}`, expr);
|
|
338
|
+
}
|
|
339
|
+
const debugArgs = [expr.operand, expr];
|
|
340
|
+
const args = [operand, staticValueClause(expr.member)];
|
|
341
|
+
if (expr.op == '->') {
|
|
342
|
+
return this.composeFunction(OPERATOR_JSON_EXTRACT_JSON, args, debugArgs);
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
return this.composeFunction(OPERATOR_JSON_EXTRACT_SQL, args, debugArgs);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
else if (expr.type == 'cast') {
|
|
349
|
+
const operand = this.compileClause(expr.operand);
|
|
350
|
+
const to = expr.to?.name?.toLowerCase();
|
|
351
|
+
const castFn = castOperator(to);
|
|
352
|
+
if (castFn == null) {
|
|
353
|
+
return this.error(`CAST not supported for '${to}'`, expr);
|
|
354
|
+
}
|
|
355
|
+
return this.composeFunction(castFn, [operand], [expr.operand]);
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
return this.error(`${expr.type} not supported here`, expr);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* "some_column" => "some_column"
|
|
363
|
+
* "table.some_column" => "some_column".
|
|
364
|
+
* "some_function() AS some_column" => "some_column"
|
|
365
|
+
* "some_function() some_column" => "some_column"
|
|
366
|
+
* "some_function()" => error
|
|
367
|
+
*/
|
|
368
|
+
getOutputName(column) {
|
|
369
|
+
let alias = column.alias?.name;
|
|
370
|
+
if (alias) {
|
|
371
|
+
return alias;
|
|
372
|
+
}
|
|
373
|
+
const expr = column.expr;
|
|
374
|
+
if (expr.type == 'ref') {
|
|
375
|
+
return expr.name;
|
|
376
|
+
}
|
|
377
|
+
throw new SqlRuleError(`alias is required`, this.sql, column.expr);
|
|
378
|
+
}
|
|
379
|
+
getSpecificOutputName(column) {
|
|
380
|
+
const name = this.getOutputName(column);
|
|
381
|
+
if (name == '*') {
|
|
382
|
+
throw new SqlRuleError('* is not supported here - use explicit columns', this.sql, column.expr);
|
|
383
|
+
}
|
|
384
|
+
return name;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Check if an expression is a parameter_table reference.
|
|
388
|
+
*/
|
|
389
|
+
isParameterRef(expr) {
|
|
390
|
+
if (expr.type != 'ref') {
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
return this.parameter_tables.includes(expr.table?.name ?? '');
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Check if an expression is a value_tables reference.
|
|
397
|
+
*
|
|
398
|
+
* This means the expression can be evaluated directly on a value row.
|
|
399
|
+
*/
|
|
400
|
+
isTableRef(expr) {
|
|
401
|
+
if (expr.type != 'ref') {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
try {
|
|
405
|
+
this.getTableName(expr);
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
catch (e) {
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
checkRef(table, ref) {
|
|
413
|
+
if (this.schema) {
|
|
414
|
+
const type = this.schema.getType(table, ref.name);
|
|
415
|
+
if (type.typeFlags == TYPE_NONE) {
|
|
416
|
+
this.warn(`Column not found: ${ref.name}`, ref);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
getParameterRefClause(expr) {
|
|
421
|
+
const table = expr.table.name;
|
|
422
|
+
const column = expr.name;
|
|
423
|
+
return {
|
|
424
|
+
key: `${table}.${column}`,
|
|
425
|
+
lookupParameterValue: (parameters) => {
|
|
426
|
+
const pt = parameters[table];
|
|
427
|
+
return pt?.[column] ?? null;
|
|
428
|
+
},
|
|
429
|
+
usesAuthenticatedRequestParameters: table == 'token_parameters',
|
|
430
|
+
usesUnauthenticatedRequestParameters: table == 'user_parameters'
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
refHasSchema(ref) {
|
|
434
|
+
return ref.table?.schema != null;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Get the table name from an expression.
|
|
438
|
+
*
|
|
439
|
+
* Only "value" tables are supported here, not parameter values.
|
|
440
|
+
*/
|
|
441
|
+
getTableName(ref) {
|
|
442
|
+
if (this.refHasSchema(ref)) {
|
|
443
|
+
throw new SqlRuleError(`Specifying schema in column references is not supported`, this.sql, ref);
|
|
444
|
+
}
|
|
445
|
+
if (ref.table?.name == null && this.default_table != null) {
|
|
446
|
+
return this.default_table;
|
|
447
|
+
}
|
|
448
|
+
else if (this.value_tables.includes(ref.table?.name ?? '')) {
|
|
449
|
+
return ref.table.name;
|
|
450
|
+
}
|
|
451
|
+
else if (ref.table?.name == null) {
|
|
452
|
+
throw new SqlRuleError(`Table name required`, this.sql, ref);
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
throw new SqlRuleError(`Undefined table ${ref.table?.name}`, this.sql, ref);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Given a function, compile a clause with the function over compiled arguments.
|
|
460
|
+
*
|
|
461
|
+
* For functions with multiple arguments, the following combinations are supported:
|
|
462
|
+
* fn(StaticValueClause, StaticValueClause) => StaticValueClause
|
|
463
|
+
* fn(ParameterValueClause, ParameterValueClause) => ParameterValueClause
|
|
464
|
+
* fn(RowValueClause, RowValueClause) => RowValueClause
|
|
465
|
+
* fn(ParameterValueClause, StaticValueClause) => ParameterValueClause
|
|
466
|
+
* fn(RowValueClause, StaticValueClause) => RowValueClause
|
|
467
|
+
*
|
|
468
|
+
* This is not supported, and will likely never be supported:
|
|
469
|
+
* fn(ParameterValueClause, RowValueClause) => error
|
|
470
|
+
*
|
|
471
|
+
* @param fnImpl The function or operator implementation
|
|
472
|
+
* @param argClauses The compiled argument clauses
|
|
473
|
+
* @param debugArgExpressions The original parsed expressions, for debug info only
|
|
474
|
+
* @returns a compiled function clause
|
|
475
|
+
*/
|
|
476
|
+
composeFunction(fnImpl, argClauses, debugArgExpressions) {
|
|
477
|
+
let argsType = 'static';
|
|
478
|
+
for (let i = 0; i < argClauses.length; i++) {
|
|
479
|
+
const debugArg = debugArgExpressions[i];
|
|
480
|
+
const clause = argClauses[i];
|
|
481
|
+
if (isClauseError(clause)) {
|
|
482
|
+
// Return immediately on error
|
|
483
|
+
return clause;
|
|
484
|
+
}
|
|
485
|
+
else if (isStaticValueClause(clause)) {
|
|
486
|
+
// argsType unchanged
|
|
487
|
+
}
|
|
488
|
+
else if (isParameterValueClause(clause)) {
|
|
489
|
+
if (!this.supports_parameter_expressions) {
|
|
490
|
+
return this.error(`Cannot use bucket parameters in expressions`, debugArg);
|
|
491
|
+
}
|
|
492
|
+
if (argsType == 'static' || argsType == 'param') {
|
|
493
|
+
argsType = 'param';
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
return this.error(`Cannot use table values and parameters in the same clauses`, debugArg);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
else if (isRowValueClause(clause)) {
|
|
500
|
+
if (argsType == 'static' || argsType == 'row') {
|
|
501
|
+
argsType = 'row';
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
504
|
+
return this.error(`Cannot use table values and parameters in the same clauses`, debugArg);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
return this.error(`Parameter match clauses cannot be used here`, debugArg);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
if (argsType == 'row' || argsType == 'static') {
|
|
512
|
+
return {
|
|
513
|
+
evaluate: (tables) => {
|
|
514
|
+
const args = argClauses.map((e) => e.evaluate(tables));
|
|
515
|
+
return fnImpl.call(...args);
|
|
516
|
+
},
|
|
517
|
+
getType(schema) {
|
|
518
|
+
const argTypes = argClauses.map((e) => e.getType(schema));
|
|
519
|
+
return fnImpl.getReturnType(argTypes);
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
else if (argsType == 'param') {
|
|
524
|
+
const argStrings = argClauses.map((e) => e.key);
|
|
525
|
+
const name = `${fnImpl.debugName}(${argStrings.join(',')})`;
|
|
526
|
+
const usesAuthenticatedRequestParameters = argClauses.find((clause) => isParameterValueClause(clause) && clause.usesAuthenticatedRequestParameters) !=
|
|
527
|
+
null;
|
|
528
|
+
const usesUnauthenticatedRequestParameters = argClauses.find((clause) => isParameterValueClause(clause) && clause.usesUnauthenticatedRequestParameters) !=
|
|
529
|
+
null;
|
|
530
|
+
return {
|
|
531
|
+
key: name,
|
|
532
|
+
lookupParameterValue: (parameters) => {
|
|
533
|
+
const args = argClauses.map((e) => {
|
|
534
|
+
if (isParameterValueClause(e)) {
|
|
535
|
+
return e.lookupParameterValue(parameters);
|
|
536
|
+
}
|
|
537
|
+
else if (isStaticValueClause(e)) {
|
|
538
|
+
return e.value;
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
throw new Error('unreachable condition');
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
return fnImpl.call(...args);
|
|
545
|
+
},
|
|
546
|
+
usesAuthenticatedRequestParameters,
|
|
547
|
+
usesUnauthenticatedRequestParameters
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
throw new Error('unreachable condition');
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
parameterFunction() { }
|
|
555
|
+
}
|
|
556
|
+
function isStatic(expr) {
|
|
557
|
+
return ['integer', 'string', 'numeric', 'boolean', 'null'].includes(expr.type);
|
|
558
|
+
}
|
|
559
|
+
function staticValue(expr) {
|
|
560
|
+
if (expr.type == 'boolean') {
|
|
561
|
+
return expr.value ? SQLITE_TRUE : SQLITE_FALSE;
|
|
562
|
+
}
|
|
563
|
+
else if (expr.type == 'integer') {
|
|
564
|
+
return BigInt(expr.value);
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
return expr.value;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
function staticValueClause(value) {
|
|
571
|
+
return {
|
|
572
|
+
value: value,
|
|
573
|
+
// RowValueClause compatibility
|
|
574
|
+
evaluate: () => value,
|
|
575
|
+
getType() {
|
|
576
|
+
return ExpressionType.fromTypeText(sqliteTypeOf(value));
|
|
577
|
+
},
|
|
578
|
+
// ParamterValueClause compatibility
|
|
579
|
+
key: JSONBig.stringify(value),
|
|
580
|
+
lookupParameterValue(_parameters) {
|
|
581
|
+
return value;
|
|
582
|
+
},
|
|
583
|
+
usesAuthenticatedRequestParameters: false,
|
|
584
|
+
usesUnauthenticatedRequestParameters: false
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
function basicInputParameter(clause) {
|
|
588
|
+
return {
|
|
589
|
+
key: clause.key,
|
|
590
|
+
expands: false,
|
|
591
|
+
filteredRowToLookupValue: (filterParameters) => {
|
|
592
|
+
return filterParameters[clause.key];
|
|
593
|
+
},
|
|
594
|
+
parametersToLookupValue: (parameters) => {
|
|
595
|
+
return clause.lookupParameterValue(parameters);
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
//# sourceMappingURL=sql_filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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