-
Notifications
You must be signed in to change notification settings - Fork 30
Calls to Insert
and Update
fail when a Reference
is specified on a Model
#81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@AdamBuchweitz hope you had a nice holiday! This is currently intended functionality. Or, rather, an expected lack of functionality. But looking at the docs, this isn't documented anywhere as far as I see. Unfortunately, when the The problem being that when performing an insert with related data, the library needs the related keys to perform the inserts (which are usually generated). So, for your use case, the library would need to translate your model with inserts by creating the It's doable, for sure, but no one has implemented it yet. I'm up to implementing it, but I'm traveling for the next month. So, just being honest, I'll probably be slow implementing it! Thanks for the issue/enhancement request! Love seeing people using supabase and c#. |
Insert
and Update
support for Nested/Foreign Referenced Models
Thanks for the reply @acupofjose . Support for inserting/updating referenced data would be really nice, but I'm fine without that. The bug is that the library won't even insert the Person without the referenced data. I have taken to building models with derivatives like this:
which allows me to insert a Person with the
Since there is already supposed to be support for |
Ah, yep. I actually noticed that as a bug as I was starting the implementation (it's becoming a rabbit hole lol). But the bug fix for just that is definitely easy enough! Good call. I'm over here making mountains out of molehills. Give me a few, I think I can have a patch worked out here for you on this issue. |
Insert
and Update
support for Nested/Foreign Referenced ModelsInsert
and Update
fail when a Reference
is specified on a Model
…eAttribute` as changing these properties to `false` does not currently provide the expected functionality.
Your request should be supported in v3.4.0! Thanks for the bug report @AdamBuchweitz, apologies for the confusion on my part. |
I hope you don't mind if I throw more reports your way - I'm working on a project and we're using this library in production. |
Looks like I got excited and spoke too soon... I didn't realize that the test I ran, switching an argument from |
Please do, always looking to improve the codebase! |
Also, to clarify, is this still an issue? Or has it been resolved? |
@acupofjose I think this might be still be going on. It was specifically on the INSERT of a many to many link record that I had the issue. I just upgraded the postgrest-csharp version to 3.4.0 to see if the issue is resolved. I'm currently attempting to debug the issue using an insert model stand-in for that table. Though, I also noticed that the link table just has the two primary keys. The exception report is rather vexing as well: The insert data looked correct with model definition that had the three primary keys set on the table model (captured with the debug handler on the Postgrest client):
|
That may be a false alarm @acupofjose - I will attempt to confirm. I had a typo in my Table attribute (name was misspelled). However, the "NotFound" reason did not propagate to something meaningful. However, I can file another handling or my own PR for that. If I determine this issue's problem is still present, I'll update this ticket. |
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:
Now try to insert data:
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
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:
The text was updated successfully, but these errors were encountered: