Fix for deleting text columns (#928)

* Added handling for deleting problematic rows

* minor formatting changes

* Null checks and executereader implemented

* minor formatting

* Fix for column deletion for text

* minor space format

* more format changes

* Removal of top 200 and change of text comparison

* space fix

* minor commit

* Added new tests for single clause

* simplified regex

* spacing fix

* some polish for RowEditBaseTests

* space fix

* loc update (#914)

* loc update

* loc updates

* Warning for multiple delete (#931)

* Fix for multiple delete bug

* minor space removal

* removed catch error in RowDelete

* small optimizations

* space adding

* WIP on creating test

* Some cleanup

* removed spaces

* Fix for verifytext

* Added check for command format correctness.

* tidying up

* added working test for command exception

* simplification of TestDbDataReader getint

* Corrections made

* spacing and naming issues

* minor space

* one more space issue

* Revert "Support ActiveDirectoryPassword authentication (#899)" (#915)

This reverts commit b786a14c03.

* revert changes to connectionService

* fix for asserts

* fix clauses

Co-authored-by: khoiph1 <khoiph@microsoft.com>
Co-authored-by: Amir Omidi <amir@aaomidi.com>
This commit is contained in:
Alex Ma
2021-07-16 14:11:32 -07:00
committed by GitHub
parent 0032cc684b
commit c731744298
2 changed files with 79 additions and 29 deletions

View File

@@ -80,7 +80,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
EditTableMetadata etm = Common.GetCustomEditTableMetadata(cols);
RowEditTester rt = new RowEditTester(rs, etm);
rt.ValidateWhereClauseSingleKey(nullClause);
if (val == DBNull.Value)
{
rt.ValidateWhereClauseNullKey(nullClause);
}
else
{
rt.ValidateWhereClauseSingleKey(nullClause);
}
}
public static IEnumerable<object[]> GetWhereClauseIsNotNullData
@@ -95,7 +102,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
DataType = typeof(byte[])
},
new byte[5],
"IS NOT NULL"
"= 0x0000000000"
};
yield return new object[]
{
@@ -105,7 +112,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
DataTypeName = "TEXT"
},
"abc",
"IS NOT NULL"
"= N'abc'"
};
yield return new object[]
{
@@ -116,7 +123,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
},
"abc",
"IS NOT NULL"
"= N'abc'"
};
}
}
@@ -252,11 +259,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
}
// ReSharper disable once UnusedParameter.Local
public void ValidateWhereClauseSingleKey(string nullValue)
public void ValidateWhereClauseNullKey(string nullValue)
{
// If: I generate a where clause with one is null column value
WhereClause wc = GetWhereClause(false);
// Then:
// ... There should only be one component
Assert.AreEqual(1, wc.ClauseComponents.Count);
@@ -272,6 +279,27 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.AreEqual($"WHERE {wc.ClauseComponents[0]}", wc.CommandText);
}
public void ValidateWhereClauseSingleKey(string clauseValue)
{
// If: I generate a where clause with one is null column value
WhereClause wc = GetWhereClause(false);
// Then:
// ... There should only be one component
Assert.AreEqual(1, wc.ClauseComponents.Count);
// ... Parameterization should be empty
Assert.IsEmpty(wc.Parameters);
// ... The component should contain the name of the column and the value
Assert.True(wc.ClauseComponents[0].Contains(AssociatedObjectMetadata.Columns.First().EscapedName));
Regex r = new Regex($@"\(CONVERT \([A-Z]*\(MAX\), {AssociatedObjectMetadata.Columns.First().EscapedName}\) {clauseValue}\)");
Assert.True(r.IsMatch(wc.ClauseComponents[0]));
// ... The complete clause should contain a single WHERE
Assert.AreEqual($"WHERE {wc.ClauseComponents[0]}", wc.CommandText);
}
public void ValidateWhereClauseMultipleKeys()
{
// If: I generate a where clause with multiple key columns