mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
This commit is contained in:
@@ -58,7 +58,7 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData
|
|||||||
// Connect with SMO and get the metadata for the table
|
// Connect with SMO and get the metadata for the table
|
||||||
Server server = new Server(new ServerConnection(sqlConn));
|
Server server = new Server(new ServerConnection(sqlConn));
|
||||||
Database db = new Database(server, sqlConn.Database);
|
Database db = new Database(server, sqlConn.Database);
|
||||||
|
|
||||||
TableViewTableTypeBase smoResult;
|
TableViewTableTypeBase smoResult;
|
||||||
switch (objectType.ToLowerInvariant())
|
switch (objectType.ToLowerInvariant())
|
||||||
{
|
{
|
||||||
@@ -82,17 +82,26 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData
|
|||||||
{
|
{
|
||||||
throw new ArgumentOutOfRangeException(nameof(objectNamedParts), SR.EditDataObjectNotFound);
|
throw new ArgumentOutOfRangeException(nameof(objectNamedParts), SR.EditDataObjectNotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the edit column metadata
|
// Generate the edit column metadata
|
||||||
List<EditColumnMetadata> editColumns = new List<EditColumnMetadata>();
|
List<EditColumnMetadata> editColumns = new List<EditColumnMetadata>();
|
||||||
for (int i = 0; i < smoResult.Columns.Count; i++)
|
for (int i = 0; i < smoResult.Columns.Count; i++)
|
||||||
{
|
{
|
||||||
Column smoColumn = smoResult.Columns[i];
|
Column smoColumn = smoResult.Columns[i];
|
||||||
|
|
||||||
// The default value may be escaped
|
string defaultValue = null;
|
||||||
string defaultValue = smoColumn.DefaultConstraint == null
|
try
|
||||||
? null
|
{
|
||||||
: FromSqlScript.UnwrapLiteral(smoColumn.DefaultConstraint.Text);
|
// The default value may be escaped
|
||||||
|
defaultValue = smoColumn.DefaultConstraint == null
|
||||||
|
? null
|
||||||
|
: FromSqlScript.UnwrapLiteral(smoColumn.DefaultConstraint.Text);
|
||||||
|
}
|
||||||
|
catch (PropertyCannotBeRetrievedException)
|
||||||
|
{
|
||||||
|
// This exception will be thrown when the user doesn't have view definition privilege,
|
||||||
|
// we can ignore it and use null as the default value;
|
||||||
|
}
|
||||||
|
|
||||||
EditColumnMetadata column = new EditColumnMetadata
|
EditColumnMetadata column = new EditColumnMetadata
|
||||||
{
|
{
|
||||||
@@ -113,7 +122,7 @@ namespace Microsoft.SqlTools.ServiceLayer.EditData
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escape the parts of the name
|
// Escape the parts of the name
|
||||||
string[] objectNameParts = {smoResult.Schema, smoResult.Name};
|
string[] objectNameParts = { smoResult.Schema, smoResult.Name };
|
||||||
string escapedMultipartName = ToSqlScript.FormatMultipartIdentifier(objectNameParts);
|
string escapedMultipartName = ToSqlScript.FormatMultipartIdentifier(objectNameParts);
|
||||||
|
|
||||||
return new EditTableMetadata
|
return new EditTableMetadata
|
||||||
|
|||||||
Reference in New Issue
Block a user