@@ -380,13 +380,17 @@ function appendWhereEntry({type, operands}, args, escaper) {
380
380
if ( operands . length < 1 ) throw new Error ( "Invalid operand length" ) ;
381
381
382
382
// Unary operations
383
- if ( operands . length === 1 ) {
383
+ // We treat `v` and `nv` as `NULL` and `NOT NULL` unary operations in SQL,
384
+ // since the database already validates column types.
385
+ if ( operands . length === 1 || type === "v" || type === "nv" ) {
384
386
appendOperand ( operands [ 0 ] , args , escaper ) ;
385
387
switch ( type ) {
386
388
case "n" :
389
+ case "nv" :
387
390
appendSql ( ` IS NULL` , args ) ;
388
391
return ;
389
392
case "nn" :
393
+ case "v" :
390
394
appendSql ( ` IS NOT NULL` , args ) ;
391
395
return ;
392
396
default :
@@ -398,7 +402,7 @@ function appendWhereEntry({type, operands}, args, escaper) {
398
402
if ( operands . length === 2 ) {
399
403
if ( [ "in" , "nin" ] . includes ( type ) ) {
400
404
// Fallthrough to next parent block.
401
- } else if ( [ "c" , "nc" , "v" , "nv" ] . includes ( type ) ) {
405
+ } else if ( [ "c" , "nc" ] . includes ( type ) ) {
402
406
// TODO: Case (in)sensitive?
403
407
appendOperand ( operands [ 0 ] , args , escaper ) ;
404
408
switch ( type ) {
@@ -408,14 +412,6 @@ function appendWhereEntry({type, operands}, args, escaper) {
408
412
case "nc" :
409
413
appendSql ( ` NOT LIKE ` , args ) ;
410
414
break ;
411
- // JavaScript "not valid" filter translate to a SQL "IS NULL"
412
- case "nv" :
413
- appendSql ( ` IS NULL` , args ) ;
414
- break ;
415
- // JavaScript "valid" filter translate to a SQL "IS NOT NULL"
416
- case "v" :
417
- appendSql ( ` IS NOT NULL` , args ) ;
418
- break ;
419
415
}
420
416
appendOperand ( likeOperand ( operands [ 1 ] ) , args , escaper ) ;
421
417
return ;
0 commit comments