@@ -380,13 +380,17 @@ function appendWhereEntry({type, operands}, args, escaper) {
380380 if ( operands . length < 1 ) throw new Error ( "Invalid operand length" ) ;
381381
382382 // 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" ) {
384386 appendOperand ( operands [ 0 ] , args , escaper ) ;
385387 switch ( type ) {
386388 case "n" :
389+ case "nv" :
387390 appendSql ( ` IS NULL` , args ) ;
388391 return ;
389392 case "nn" :
393+ case "v" :
390394 appendSql ( ` IS NOT NULL` , args ) ;
391395 return ;
392396 default :
@@ -398,7 +402,7 @@ function appendWhereEntry({type, operands}, args, escaper) {
398402 if ( operands . length === 2 ) {
399403 if ( [ "in" , "nin" ] . includes ( type ) ) {
400404 // Fallthrough to next parent block.
401- } else if ( [ "c" , "nc" , "v" , "nv" ] . includes ( type ) ) {
405+ } else if ( [ "c" , "nc" ] . includes ( type ) ) {
402406 // TODO: Case (in)sensitive?
403407 appendOperand ( operands [ 0 ] , args , escaper ) ;
404408 switch ( type ) {
@@ -408,14 +412,6 @@ function appendWhereEntry({type, operands}, args, escaper) {
408412 case "nc" :
409413 appendSql ( ` NOT LIKE ` , args ) ;
410414 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 ;
419415 }
420416 appendOperand ( likeOperand ( operands [ 1 ] ) , args , escaper ) ;
421417 return ;
0 commit comments