diff --git a/src/Microsoft.SqlTools.ServiceLayer/EditData/UpdateManagement/CellUpdate.cs b/src/Microsoft.SqlTools.ServiceLayer/EditData/UpdateManagement/CellUpdate.cs
index 823d3902..1b5516de 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/EditData/UpdateManagement/CellUpdate.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/EditData/UpdateManagement/CellUpdate.cs
@@ -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
}
}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs
index ac5414e5..58b86a8e 100755
--- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs
@@ -525,6 +525,14 @@ namespace Microsoft.SqlTools.ServiceLayer
}
}
+ public static string EditDataNullNotAllowed
+ {
+ get
+ {
+ return Keys.GetString(Keys.EditDataNullNotAllowed);
+ }
+ }
+
public static string EE_BatchSqlMessageNoProcedureInfo
{
get
@@ -1079,6 +1087,9 @@ namespace Microsoft.SqlTools.ServiceLayer
public const string EditDataInitializeInProgress = "EditDataInitializeInProgress";
+ public const string EditDataNullNotAllowed = "EditDataNullNotAllowed";
+
+
public const string EE_BatchSqlMessageNoProcedureInfo = "EE_BatchSqlMessageNoProcedureInfo";
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx
index addb71fb..ecc3b2c3 100755
--- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx
+++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx
@@ -435,6 +435,10 @@
Another edit data initialize is in progress for this owner URI. Please wait for completion.
+
+ NULL is not allowed for this column
+
+
Msg {0}, Level {1}, State {2}, Line {3}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings
index 12792b5d..aeac66c1 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings
+++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings
@@ -206,6 +206,8 @@ EditDataComputedColumnPlaceholder =
EditDataInitializeInProgress = Another edit data initialize is in progress for this owner URI. Please wait for completion.
+EditDataNullNotAllowed = NULL is not allowed for this column
+
############################################################################
# DacFx Resources
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf
index c5cd03c9..2ede8d52 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf
+++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf
@@ -551,6 +551,11 @@
Cannot add row to result buffer, data reader does not contain rows
+
+ NULL is not allowed for this column
+ NULL is not allowed for this column
+
+