mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-20 01:25:41 -05:00
@@ -15,6 +15,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting.Contracts
|
||||
Insert = 2,
|
||||
Update = 3,
|
||||
Delete = 4,
|
||||
Execute = 5
|
||||
Execute = 5,
|
||||
Alter = 6
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
|
||||
switch (this.Parameters.Operation)
|
||||
{
|
||||
case ScriptingOperationType.Create:
|
||||
case ScriptingOperationType.Alter:
|
||||
case ScriptingOperationType.Delete: // Using Delete here is wrong. delete usually means delete rows from table but sqlopsstudio sending the operation name as delete instead of drop
|
||||
resultScript = GenerateScriptAs(server, urns, options);
|
||||
break;
|
||||
@@ -438,6 +439,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
|
||||
try
|
||||
{
|
||||
scripter = new SqlServer.Management.Smo.Scripter(server);
|
||||
if(this.Parameters.Operation == ScriptingOperationType.Alter)
|
||||
{
|
||||
options.ScriptForAlter = true;
|
||||
foreach (var urn in urns)
|
||||
{
|
||||
SqlSmoObject smoObject = server.GetSmoObject(urn);
|
||||
|
||||
// without calling the toch method, no alter script get generated from smo
|
||||
smoObject.Touch();
|
||||
}
|
||||
}
|
||||
|
||||
scripter.Options = options;
|
||||
scripter.ScriptingError += ScripterScriptingError;
|
||||
|
||||
@@ -163,7 +163,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
|
||||
// To script Select, alter and execute use scripting as operation. The other operation doesn't support those types
|
||||
if( (parameters.ScriptingObjects != null && parameters.ScriptingObjects.Count == 1 && parameters.ScriptOptions != null
|
||||
&& parameters.ScriptOptions.TypeOfDataToScript == "SchemaOnly" && parameters.ScriptDestination == "ToEditor") ||
|
||||
parameters.Operation == ScriptingOperationType.Select || parameters.Operation == ScriptingOperationType.Execute)
|
||||
parameters.Operation == ScriptingOperationType.Select || parameters.Operation == ScriptingOperationType.Execute ||
|
||||
parameters.Operation == ScriptingOperationType.Alter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user