Add support for custom relationships to ReferenceAttribute
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 55/100
Research direction
Open Postgrest/Attributes/ReferenceAttribute.cs at the ColumnName/ForeignKey logic around lines 183-194. Trace how ReferenceAttribute derives the embedded field name, then verify that a ColumnName without ForeignKey is used for both select construction and returned-JSON parsing while existing ForeignKey behavior remains unchanged.
Written by the indexing model from the issue text.
Description
Feature request
PostgREST supports defining custom relationships between tables.
See https://docs.postgrest.org/en/stable/references/api/resource_embedding.html#computed-relationships
The field name in the select queries and in the returned JSON is determined by the name of each function. The name may match the table name that's being returned, but it doesn't have to.
I have a situation where we have multiple different relationships between the same two tables. As a result, we have defined multiple computed relationship functions in PostgreSQL. Each function/relationships has a different field name. I need to provide this custom field name to the ReferenceAttribute for each embedded relationship field in the associated C# model so that the C# client uses the correct field name when querying for the embedded relationship and parsing the returned JSON.
ReferenceAttribute already provides a ColumnName property that could be used. However, that property is only used to determine the field name if the ForeignKey property is also set, which isn't applicable in this case.
See https://github.com/supabase-community/postgrest-csharp/blob/726dbd8d3af7e85cc11bbdad66ca3750809240c4/Postgrest/Attributes/ReferenceAttribute.cs#L183-L194
Describe the solution you'd like
A simple solution is to update ReferenceAttribute so that, if ColumnName is set but ForeignKey is not, then ColumnName is used instead of TableName.
System information
Version of Supabase.Postgrest: 4.1.0
- Dominant language
- C#
- Stars
- 701
- Forks
- 106
- Avg merge
- 16h 35m
- Merged PRs (30d)
- 45
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from supabase/supabase-csharp
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
supabase/supabase-csharp#440 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
supabase/supabase-csharp#437 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
supabase/supabase-csharp#427 ·
-
supabase/supabase-csharp#409 · 1 comment · 1 assignee ·
-
area: realtime bug parity
supabase/supabase-csharp#393 · 1 assignee ·
All issues in supabase/supabase-csharp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100