@tanstack/electric-db-collection 0.4.8 → 0.4.10
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/electric.cjs +648 -435
- package/dist/cjs/electric.cjs.map +1 -1
- package/dist/cjs/sql-compiler.cjs +5 -4
- package/dist/cjs/sql-compiler.cjs.map +1 -1
- package/dist/esm/electric.js +650 -437
- package/dist/esm/electric.js.map +1 -1
- package/dist/esm/sql-compiler.js +5 -4
- package/dist/esm/sql-compiler.js.map +1 -1
- package/package.json +4 -3
- package/src/electric.ts +942 -647
- package/src/sql-compiler.ts +18 -4
package/src/sql-compiler.ts
CHANGED
|
@@ -194,9 +194,23 @@ function compileFunction(
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
const compiledArgs = args.map((arg: IR.BasicExpression) =>
|
|
198
|
-
compileBasicExpression(arg, params, encodeColumnName)
|
|
199
|
-
|
|
197
|
+
const compiledArgs = args.map((arg: IR.BasicExpression) => {
|
|
198
|
+
const compiled = compileBasicExpression(arg, params, encodeColumnName)
|
|
199
|
+
// AND/OR group their children by precedence; NOT already wraps its operand.
|
|
200
|
+
// In value positions, preserve any nested operator as a single expression.
|
|
201
|
+
return arg.type === `func` &&
|
|
202
|
+
(arg.name === `and` ||
|
|
203
|
+
arg.name === `or` ||
|
|
204
|
+
(name !== `and` &&
|
|
205
|
+
name !== `or` &&
|
|
206
|
+
name !== `not` &&
|
|
207
|
+
(isBinaryOp(arg.name) ||
|
|
208
|
+
arg.name === `not` ||
|
|
209
|
+
arg.name === `isNull` ||
|
|
210
|
+
arg.name === `isUndefined`)))
|
|
211
|
+
? `(${compiled})`
|
|
212
|
+
: compiled
|
|
213
|
+
})
|
|
200
214
|
|
|
201
215
|
// Special case for IS NULL / IS NOT NULL - these are postfix operators
|
|
202
216
|
if (name === `isNull` || name === `isUndefined`) {
|
|
@@ -231,7 +245,7 @@ function compileFunction(
|
|
|
231
245
|
// Special handling for AND/OR which can be variadic
|
|
232
246
|
if ((name === `and` || name === `or`) && compiledArgs.length > 2) {
|
|
233
247
|
// Chain multiple arguments: (a AND b AND c) or (a OR b OR c)
|
|
234
|
-
return compiledArgs.
|
|
248
|
+
return compiledArgs.join(` ${opName} `)
|
|
235
249
|
}
|
|
236
250
|
|
|
237
251
|
if (compiledArgs.length !== 2) {
|