Skip to content
This repository was archived by the owner on Aug 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Realtime/PostgresChanges/PostgresChangesOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ public enum ListenType
public string Schema { get; set; }

/// <summary>
/// The table for this listener, can be: `*` matching all tables in schema.
/// The table for this listener, can be: `*` matching all tables in schema. When <c>null</c>
/// (a schema-wide listener), the <c>table</c> key is omitted from the join payload rather than
/// sent as <c>null</c>.
/// </summary>
[JsonProperty("table")]
[JsonProperty("table", NullValueHandling = NullValueHandling.Ignore)]
public string? Table { get; set; }

/// <summary>
Expand Down
29 changes: 29 additions & 0 deletions RealtimeTests/Serialization/PostgresChangesOptionsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Supabase.Realtime.PostgresChanges;

namespace RealtimeTests;

/// <summary>
/// Wire-shape of <see cref="PostgresChangesOptions"/> as it is serialized into a channel's
/// join <c>config.postgres_changes</c> payload.
/// </summary>
[TestClass]
public class PostgresChangesOptionsTests
{
[TestMethod]
public void Table_ShouldBeOmittedFromJson_WhenNull()
{
// A schema-wide listener has no table; the server expects the key absent, not `"table": null`.
var json = JsonConvert.SerializeObject(new PostgresChangesOptions("public"));
Assert.IsFalse(JObject.Parse(json).ContainsKey("table"));
}

[TestMethod]
public void Table_ShouldBeSerialized_WhenProvided()
{
var json = JsonConvert.SerializeObject(new PostgresChangesOptions("public", "todos"));
Assert.AreEqual("todos", JObject.Parse(json)["table"]?.Value<string>());
}
}
Loading