edit/createRow Default Values (#266)

Returns strings for the default value of a column when a new row is created. The values that could come back:
* `null` when there isn't a default for the column
* a string when there is a default for the column
* a placeholder (currently <TBD>) when the column cannot be updated

* Renaming EditTableMetadata to reflect its SMO source

* Implementation of returning default values

* Unit test for default values

* Reworking column defaults using default constraints

* Adding unit test for new sql script unwrapper

* Disabling flaky test

* Fixing oddities in tests, removing personal tests

* Fixing broken unit test
This commit is contained in:
Benjamin Russell
2017-03-08 13:51:38 -08:00
committed by GitHub
parent 29d27c2341
commit 056a08cd1b
21 changed files with 286 additions and 90 deletions

View File

@@ -23,7 +23,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Setup: Create the values to store
const long rowId = 0;
ResultSet rs = QueryExecution.Common.GetBasicExecutedBatch().ResultSets[0];
IEditTableMetadata etm = Common.GetMetadata(rs.Columns);
IEditTableMetadata etm = Common.GetStandardMetadata(rs.Columns);
// If: I create a RowUpdate instance
RowUpdate rc = new RowUpdate(rowId, rs, etm);
@@ -40,7 +40,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Setup: Create a fake table to update
DbColumn[] columns = Common.GetColumns(true);
ResultSet rs = Common.GetResultSet(columns, true);
IEditTableMetadata etm = Common.GetMetadata(columns);
IEditTableMetadata etm = Common.GetStandardMetadata(columns);
// If:
// ... I add updates to all the cells in the row
@@ -77,7 +77,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Setup: Create a fake table to update
DbColumn[] columns = Common.GetColumns(true);
ResultSet rs = Common.GetResultSet(columns, true);
IEditTableMetadata etm = Common.GetMetadata(columns, false, isMemoryOptimized);
IEditTableMetadata etm = Common.GetStandardMetadata(columns, false, isMemoryOptimized);
// If: I ask for a script to be generated for update
RowUpdate ru = new RowUpdate(0, rs, etm);
@@ -116,7 +116,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... Create a row update with cell updates
var columns = Common.GetColumns(includeIdentity);
var rs = Common.GetResultSet(columns, includeIdentity);
var etm = Common.GetMetadata(columns, !includeIdentity, isMemoryOptimized);
var etm = Common.GetStandardMetadata(columns, !includeIdentity, isMemoryOptimized);
RowUpdate ru = new RowUpdate(0, rs, etm);
Common.AddCells(ru, includeIdentity);
@@ -169,7 +169,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// Setup: Create a row create
var columns = Common.GetColumns(false);
var rs = Common.GetResultSet(columns, false);
var etm = Common.GetMetadata(columns);
var etm = Common.GetStandardMetadata(columns);
RowUpdate rc = new RowUpdate(0, rs, etm);
// If: I attempt to create a command with a null connection
@@ -186,7 +186,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... Create a row update (no cell updates needed)
var columns = Common.GetColumns(includeIdentity);
var rs = Common.GetResultSet(columns, includeIdentity);
var etm = Common.GetMetadata(columns, !includeIdentity);
var etm = Common.GetStandardMetadata(columns, !includeIdentity);
RowUpdate ru = new RowUpdate(0, rs, etm);
long oldBytesWritten = rs.totalBytesWritten;
@@ -209,7 +209,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
// ... Create a row update (no cell updates needed)
var columns = Common.GetColumns(true);
var rs = Common.GetResultSet(columns, true);
var etm = Common.GetMetadata(columns, false);
var etm = Common.GetStandardMetadata(columns, false);
RowUpdate ru = new RowUpdate(0, rs, etm);
// If: I ask for the changes to be applied with a null db reader