Bug report
Describe the bug
When a model property mapped to a PostgreSQL enum column is declared as a C# enum, the client serializes it as its underlying integer value (e.g. 0, 1) instead of the string name (e.g. "Open"/"Closed").
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Create a PostgreSQL enum and table:
CREATE TYPE public.door_status AS ENUM ('Open', 'Closed');
CREATE TABLE public.doors(
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
status door_status NOT NULL
);
- Define a model with an enum property:
[Table("doors")]
public class Door: BaseModel
{
[PrimaryKey("id", false)]
public Guid Id { get; set; }
[Column("status")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public DoorStatus status{ get; set; }
}
public enum DoorStatus { Open, Closed }
- Perform an insert:
await supabaseClient.From<Door>()
.Insert(new Door { Status = DoorStatus.Closed });
Expected behavior
The client should serialize the enum property as its string name ("Outbound") and respect [JsonConverter] attributes, so the value matches the PostgreSQL enum label.
System information
- OS: Windows
- Supabase (C#): 1.1.1
- .NET Version: 10
Additional context
I know the workaround is to use strings, but why is this so? Is it a deliberate decision? I cannot find any upsides to not letting Postgres Enums map directly to C# enums. I found an old issue where they said I could use JsonConverter to get over this. But this is clearly not working. Also, the Select methods work fine and they serialize to C# enums, so why not while upsert/insert?
Bug report
Describe the bug
When a model property mapped to a PostgreSQL enum column is declared as a C# enum, the client serializes it as its underlying integer value (e.g. 0, 1) instead of the string name (e.g. "Open"/"Closed").
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Expected behavior
The client should serialize the enum property as its string name ("Outbound") and respect [JsonConverter] attributes, so the value matches the PostgreSQL enum label.
System information
Additional context
I know the workaround is to use strings, but why is this so? Is it a deliberate decision? I cannot find any upsides to not letting Postgres Enums map directly to C# enums. I found an old issue where they said I could use
JsonConverterto get over this. But this is clearly not working. Also, the Select methods work fine and they serialize to C# enums, so why not while upsert/insert?