Help with using postgrest attribute reference #71
-
I am running into issues when trying to mock up my database to in classes and have reference attributes between related tables and am confused by how I am suppose to implement this. I keep getting various errors when I try and adjust how I have it structured. I am confused by how the example mock up is shown for this in the readme. The class values with the reference attribute aren't given a column name or match a column name in the example schema. How does it then get mapped during requests to and from |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 8 replies
-
Sure! What specifically are you struggling with - the Getting Started section ought to be pretty clear I think? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
For full disclosure I originally was trying to get this to work over the weekend. Gave up and did it without using the reference attribute but then decided I should probably do it the right way instead of the very jank way I was doing it that was only gonna cause more problems down the line. I originally didn't have the column names included. When I first tried it I tried doing an insert from the rating table and all the relational keys were just null in the database. Then when I changed something (apologies that I can't remember the exact change) I got runtime errors about not being able to serialize the data if I recall correctly. Now with the column names removed and just trying to call |
Beta Was this translation helpful? Give feedback.
-
All good. Thanks for the assistance. I will open up an issue on postgrest-csharp about it and give that suggestion a try. |
Beta Was this translation helpful? Give feedback.
-
Ok so I updated the class and am still getting the same error when I try to just do I updated the class to look like this
|
Beta Was this translation helpful? Give feedback.
-
Sorry to keep asking questions but I was messing around with it and got the other error I was running into. The error is This comes from trying to query the groups table like so This is the updated groups table
While thinking about it I also realized another question related to this. How would I handle using additional columns in the join table like in the group_movie_rating one? |
Beta Was this translation helpful? Give feedback.
I've got some commits in for the next version of postgrest-csharp that ought to address all of these issues (including the circular references)!
The example models are here and the example usage is as so:
https://github.com/supabase-community/postgrest-csharp/blob/1b3813e0be8808e8d77d01d347c82056b9142719/PostgrestTests/ReferenceTests.cs#L48-L95