supabase-community / postgrest-csharp

A C# Client library for Postgrest
https://supabase-community.github.io/postgrest-csharp/api/Postgrest.html
MIT License
117 stars 23 forks source link

Nullable column cant be filtered #98

Closed oalpar closed 3 months ago

oalpar commented 3 months ago

Bug report

Describe the bug

Regression of closed issue https://github.com/supabase-community/postgrest-csharp/issues/61 A clear and concise description of what the bug is. nullable model throws exception when using where/filter clause

To Reproduce

[Table("scenes")]
public class Scene : BaseModel
{
    [PrimaryKey("id")]
    public long Id
    {
        get; set;
    }

    [Column("created_at")]
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    [Column("name")]
    public string Name
    {
        get; set;
    }

    [Column("cluster")]
    public long? Cluster
    {
        get; set;
    }

    [Column("ip")]
    public string Ip
    {
        get; set;
    }

    [Column("port")]
    public int Port
    {
        get; set;
    }

    [Column("is_in_use")]
    public bool IsInUse
    {
        get; set;
    }
    [Column("is_dynamic")]
    public bool IsDynamic
    {
        get; set;
    }

    [Column("tick_rate")]
    public float TickRate
    {
        get; set;
    }
}

 long? cluster = null; //var `reference`
var scene= await _client.Postgrest.Table<Scene>().Where(x => x.Name == SceneName && x.IsDynamic == false && x.cluser==cluster).Single();

replicate this statement with a matching entry in the database

Expected behavior

result is returned

real behaviour

exception is thrown image

acupofjose commented 3 months ago

Presumably - downgrading to Supabase.Postgrest@4.0.2 fixes your issue?

If so then it looks like our test suite needs to be expanded a bit, because #97 wasn't caught as a regression. Thanks for the heads up!

oalpar commented 3 months ago

actually, it seems like it was because i had > 2 conditions in my where statement... https://github.com/supabase-community/postgrest-csharp/issues/84 same as this issue. The documentation doesn't highlight this limitation at all, and my use case was highlighting both this bug and the previously mentioned nullable bug. So no regression, ill close the topic