@@ -757,11 +757,21 @@ export abstract class BaseCrudDialect<Schema extends SchemaDef> {
757757 }
758758
759759 protected buildJsonEqualityFilter ( lhs : Expression < any > , rhs : unknown ) {
760- return this . buildLiteralFilter ( lhs , 'Json' , rhs ) ;
760+ return this . buildValueFilter ( lhs , 'Json' , rhs ) ;
761761 }
762762
763- private buildLiteralFilter ( lhs : Expression < any > , type : BuiltinType , rhs : unknown ) {
764- return this . eb ( lhs , '=' , rhs !== null && rhs !== undefined ? this . transformInput ( rhs , type , false ) : rhs ) ;
763+ private buildValueFilter ( lhs : Expression < any > , type : BuiltinType , rhs : unknown ) {
764+ if ( rhs === undefined ) {
765+ // undefined filter is no-op, always true
766+ return this . true ( ) ;
767+ }
768+
769+ if ( rhs === null ) {
770+ // null comparison
771+ return this . eb ( lhs , 'is' , null ) ;
772+ }
773+
774+ return this . eb ( lhs , '=' , this . transformInput ( rhs , type , false ) ) ;
765775 }
766776
767777 private buildStandardFilter (
@@ -776,7 +786,7 @@ export abstract class BaseCrudDialect<Schema extends SchemaDef> {
776786 ) {
777787 if ( payload === null || ! isPlainObject ( payload ) ) {
778788 return {
779- conditions : [ this . buildLiteralFilter ( lhs , type , payload ) ] ,
789+ conditions : [ this . buildValueFilter ( lhs , type , payload ) ] ,
780790 consumedKeys : [ ] ,
781791 } ;
782792 }
0 commit comments