@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.
@@ -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.map((arg) => `(${arg})`).join(` ${opName} `)
248
+ return compiledArgs.join(` ${opName} `)
235
249
  }
236
250
 
237
251
  if (compiledArgs.length !== 2) {