Skip to content

ArgumentException raised when updating nullable JObject with null #171

@justdmitry

Description

@justdmitry

Bug report

Updating (via IPostgrestTable.Set) nullable JObject field with null value fails with ArgumentException (Expected Value to be of Type: JObject, instead received: .)

Inserts are Ok, only updates fail.

Steps to reproduce

Table structure (non-relevant fields skipped):

public.analytics (
  id bigint generated by default as identity not null,
  properties jsonb null
)

Model (non-relevant fields skipped):

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

    [Column("properties")]
    public Newtonsoft.Json.Linq.JObject? Properties { get; set; }
}

Program code:

var client = new Supabase.Client(...);
JObject? properties = null;

var existing = await client.From<Analytics>()
    .Filter(x => /* some filtering here */)
    .Limit(1)
    .Single();
if (existing != null)
{
    await client.From<Analytics>()
        .Where(x => x.Id == existing.Id)
        .Set(x => x.Properties, properties)
        .Update();
}
else
{
    var item = new Analytics  { Properties = properties };
    await client.From<Analytics>().Insert(item);
}

Bottom code part (that handles Insert logic) works, but middle one (Update) does not: System.ArgumentException gets raised with Expected Value to be of Type: JObject, instead received: . message.

Expected behavior

Both code parts should work Ok.

System information

  • OS: Linux (Ubuntu)
  • NuGet package: Supabase, v1.1.1 and v1.0.5
  • Project .NET version: net8.0
  • Project nullable setting: enabled (<Nullable>enable</Nullable> in .csproj)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions