mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-18 17:23:52 -05:00
NULL column validation when updating cells (#274)
* Adding validation that NULL is allowed when setting cell values * Adding unit tests
This commit is contained in:
@@ -38,8 +38,7 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData.UpdateManagement
|
||||
// Check for null
|
||||
if (valueAsString == NullString)
|
||||
{
|
||||
Value = DBNull.Value;
|
||||
ValueAsString = valueAsString;
|
||||
ProcessNullValue();
|
||||
}
|
||||
else if (columnType == typeof(byte[]))
|
||||
{
|
||||
@@ -197,6 +196,18 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData.UpdateManagement
|
||||
ValueAsString = Value.ToString();
|
||||
}
|
||||
|
||||
private void ProcessNullValue()
|
||||
{
|
||||
// Make sure that nulls are allowed if we set it to null
|
||||
if (!Column.AllowDBNull.HasTrue())
|
||||
{
|
||||
throw new InvalidOperationException(SR.EditDataNullNotAllowed);
|
||||
}
|
||||
|
||||
Value = DBNull.Value;
|
||||
ValueAsString = NullString;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user