|
1 | 1 | import { SqlRuleError } from '../errors.js'; |
2 | | -import { |
3 | | - ClauseError, |
4 | | - CompiledClause, |
5 | | - FilterParameters, |
6 | | - InputParameter, |
7 | | - ParameterMatchClause, |
8 | | - ParameterValueClause, |
9 | | - ParameterValueSet, |
10 | | - QueryParameters, |
11 | | - QuerySchema, |
12 | | - RowValueClause, |
13 | | - SqliteJsonValue, |
14 | | - SqliteValue, |
15 | | - StaticValueClause, |
16 | | - StreamParseOptions, |
17 | | - TrueIfParametersMatch |
18 | | -} from '../types.js'; |
| 2 | +import { CompiledClause, QuerySchema, StaticValueClause, StreamParseOptions } from '../types.js'; |
19 | 3 | import { isSelectStatement } from '../utils.js'; |
20 | 4 | import { |
21 | 5 | andFilters, |
@@ -72,7 +56,6 @@ class SyncStreamCompiler { |
72 | 56 |
|
73 | 57 | compile(): SyncStream { |
74 | 58 | const [stmt, ...illegalRest] = parse(this.sql, { locationTracking: true }); |
75 | | - const errors: SqlRuleError[] = []; |
76 | 59 |
|
77 | 60 | // TODO: Share more of this code with SqlDataQuery |
78 | 61 | if (illegalRest.length > 0) { |
@@ -100,7 +83,7 @@ class SyncStreamCompiler { |
100 | 83 | stream.subscribedToByDefault = this.options.default ?? false; |
101 | 84 | stream.variants = filter.compileVariants(this.descriptorName); |
102 | 85 |
|
103 | | - errors.push(...tools.errors); |
| 86 | + this.errors.push(...tools.errors); |
104 | 87 | return stream; |
105 | 88 | } |
106 | 89 |
|
@@ -282,7 +265,15 @@ class SyncStreamCompiler { |
282 | 265 | } |
283 | 266 | const [subquery, subqueryTools] = subqueryResult; |
284 | 267 |
|
285 | | - if (isStaticValueClause(left) || isParameterValueClause(left)) { |
| 268 | + if (isStaticValueClause(left)) { |
| 269 | + tools.error( |
| 270 | + 'For IN subqueries, the left operand must either depend on the row to sync or stream parameters.', |
| 271 | + clause.left |
| 272 | + ); |
| 273 | + return recoverErrorClause(tools); |
| 274 | + } |
| 275 | + |
| 276 | + if (isParameterValueClause(left)) { |
286 | 277 | // Case 2: We can't implement this as an actual IN operator because we need to use exact parameter lookups (so |
287 | 278 | // we can't, for instance, resolve `SELECT * FROM users WHERE is_admin` via parameter data sets). Since the |
288 | 279 | // left clause doesn't depend on row data however, we can push it down into the subquery where it would be |
|
0 commit comments