supabase-community / postgrest-csharp

A C# Client library for Postgrest
https://supabase-community.github.io/postgrest-csharp/api/Postgrest.html
MIT License
114 stars 22 forks source link

Fix set null value on string property #97

Closed alustrement-bob closed 1 month ago

alustrement-bob commented 1 month ago

What kind of change does this PR introduce?

This PR skip the null check on the expected type of a table column if it's a string.

What is the current behavior?

Because reflexion does not make difference between string and string?, updating text column with a null value failed :

System.ArgumentException: Expected Value to be of Type: String, instead received: .
at Supabase.Postgrest.Table`1.Set(Expression`1 keySelector, Object value)

What is the new behavior?

If a new value is of type string, the null check is bypassed.

Additional context

This should be improved with NullabilityInfoContext (https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-7/#libraries-reflection-apis-for-nullability-information), but not available with netstandard2.0

acupofjose commented 1 month ago

LGTM! Thanks for the contribution @alustrement-bob