-
Notifications
You must be signed in to change notification settings - Fork 30
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
Describe the bug
Trying to insert new rows into a table with a Reference (many-to-one) relationship throws a PostgresException.
PostgrestException: {"code":"PGRST204","details":null,"hint":null,"message":"Column '[table]' of relation '[table]' does not exist"}
To Reproduce
Take the following two simple models:
[Table("people")]
public class Person : BaseModel
{
[PrimaryKey("id")]
public string id { get; set; }
public string first_name { get; set; }
public string last_name { get; set; }
[Reference(typeof(Quote))]
public List<Quote> quotes { get; set; } = new();
}
[Table("quotes")]
public class Quote : BaseModel
{
[PrimaryKey("id")]
public string id { get; set; }
[Column("quote")]
public string quote { get; set; }
[Column("people_id")]
public string people_id { get; set; }
[Column("created_at")]
public DateTime created_at { get; set; }
}Now try to insert data:
await supabaseClient.From<Person>().Insert(new Person { first_name = "Leeroy", last_name = "Jenkins"});Results in: PostgrestException:
{"code":"PGRST204","details":null,"hint":null,"message":"Column 'quotes' of relation 'people' does not exist"}
Expected behavior
I would expect a row to be inserted as normal.
System information
- OS: Windows, Unity
- Version of supabase-core: 0.0.3
- Version of supabase-csharp: 0.14.0
Additional context
Without the reference, people data inserts fine! It's only after adding the reference that the exception arises. Interestingly, I can't find any examples of one-to-many relationships here. Perhaps it isn't supported?
Here is the schema:
CREATE TABLE IF NOT EXISTS sandbox.people
(
id uuid NOT NULL DEFAULT gen_random_uuid(),
first_name character varying(255) COLLATE pg_catalog."default",
last_name character varying(255) COLLATE pg_catalog."default",
CONSTRAINT people_pkey PRIMARY KEY (id)
)
CREATE TABLE IF NOT EXISTS sandbox.quotes
(
id uuid NOT NULL DEFAULT gen_random_uuid(),
quote character varying(255) COLLATE pg_catalog."default" NOT NULL,
created_at timestamp with time zone NOT NULL DEFAULT now(),
people_id uuid NOT NULL,
CONSTRAINT quotes_pkey PRIMARY KEY (id),
CONSTRAINT quotes_people_id_fkey FOREIGN KEY (people_id)
REFERENCES sandbox.people (id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
)Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working