diff --git a/Postgrest/Table.cs b/Postgrest/Table.cs index ef23779..58b3f8c 100644 --- a/Postgrest/Table.cs +++ b/Postgrest/Table.cs @@ -474,13 +474,13 @@ public IPostgrestTable Set(Expression> keySelector, throw new ArgumentException( "Expression should return a KeyValuePair with a key of a Model Property and a value."); - if (value == null) + if (value == null && visitor.ExpectedType != typeof(string)) { if (Nullable.GetUnderlyingType(visitor.ExpectedType) == null) throw new ArgumentException( $"Expected Value to be of Type: {visitor.ExpectedType.Name}, instead received: {null}."); } - else if (!visitor.ExpectedType.IsInstanceOfType(value)) + else if (value != null && !visitor.ExpectedType.IsInstanceOfType(value)) { throw new ArgumentException(string.Format("Expected Value to be of Type: {0}, instead received: {1}.", visitor.ExpectedType.Name, value.GetType().Name)); diff --git a/PostgrestTests/LinqTests.cs b/PostgrestTests/LinqTests.cs index 4519925..d65eba8 100644 --- a/PostgrestTests/LinqTests.cs +++ b/PostgrestTests/LinqTests.cs @@ -129,6 +129,10 @@ await client.Table() await client.Table() .Set(x => x.BooleanValue, true) .Update(); + + await client.Table() + .Set(x => x.StringValue!, null) + .Update(); } [TestMethod("Linq: OnConflict")]