Skip to content

Contains on nullable string fields throws exception #100

@6pppzytfk7-tech

Description

@6pppzytfk7-tech

while integrating the library I faced an issue when I try to use contains with nullable string field

example :

public class Person {
     public string Name {get; set;}
     public string Email {get; set;}
 }
 
 var filter1 = """ Email @=* "gmail" """;
 var filter2 = """ Email ==* "gmail" """;

 var input = new List<Person>(){ new (){ Email = null; } }  
 // input.ApplyQueryKitFilter(filter1) => throws exception 
 // input.ApplyQueryKitFilter(filter2) => works

I believe the issue happens after building and excuting the filter experssion , the first filter results :

x.Email.ToLower().Contains(...)

Expected behavior

@=* should safely handle nullable strings and behave similarly to:

x.Email != null && x.Email.ToLower().Contains("gmail")

or simply treat null values as non-matching, without throwing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions