mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Task/script refactor (#446)
* scripting working with race conditions * new service works with no race conditions * use new scripting service and commented out tests * refactored peek definition to use mssql-scripter * fixed peek definition tests * removed auto gen comment * fixed peek definition highlighting bug * made scripting async and fixed event handlers * fixed tests (without cancel and plan notifs) * removed dead code * added nuget package * CR comments + select script service implementation * minor fixes and added test * CR comments and script select * added unit tests * code review comments and cleanup
This commit is contained in:
@@ -75,7 +75,7 @@ CREATE SYNONYM [dbo].[pd_testTable] FOR master.dbo.spt_monitor
|
||||
GO";
|
||||
|
||||
private const string TableValuedFunctionTypeName = "TableValuedFunction";
|
||||
private const string ScalarValuedFunctionTypeName = "ScalarValuedFunction";
|
||||
private const string ScalarValuedFunctionTypeName = "UserDefinedFunction";
|
||||
private const string UserDefinedDataTypeTypeName = "UserDefinedDataType";
|
||||
private const string UserDefinedTableTypeTypeName = "UserDefinedTableType";
|
||||
private const string SynonymTypeName = "Synonym";
|
||||
@@ -100,7 +100,7 @@ GO";
|
||||
string objectType = "TABLE";
|
||||
|
||||
// Get locations for valid table object
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetTableScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(objectName, schemaName, objectType);
|
||||
Assert.NotNull(locations);
|
||||
Cleanup(locations);
|
||||
}
|
||||
@@ -121,7 +121,7 @@ GO";
|
||||
string objectType = "TABLE";
|
||||
|
||||
// Get locations for invalid table object
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetTableScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(objectName, schemaName, objectType);
|
||||
Assert.Null(locations);
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ GO";
|
||||
string objectType = "TABLE";
|
||||
|
||||
// Get locations for valid table object with schema name
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetTableScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(objectName, schemaName, objectType);
|
||||
Assert.NotNull(locations);
|
||||
Cleanup(locations);
|
||||
}
|
||||
@@ -262,7 +262,7 @@ GO";
|
||||
string schemaName = "sys";
|
||||
string objectType = "VIEW";
|
||||
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetViewScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(objectName, schemaName, objectType);
|
||||
Assert.NotNull(locations);
|
||||
Cleanup(locations);
|
||||
}
|
||||
@@ -282,7 +282,7 @@ GO";
|
||||
string schemaName = null;
|
||||
string objectType = "VIEW";
|
||||
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetViewScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(objectName, schemaName, objectType);
|
||||
Assert.Null(locations);
|
||||
}
|
||||
|
||||
@@ -300,9 +300,9 @@ GO";
|
||||
string objectName = "sp_columns";
|
||||
|
||||
string schemaName = "sys";
|
||||
string objectType = "PROCEDURE";
|
||||
string objectType = "StoredProcedure";
|
||||
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetStoredProcedureScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(objectName, schemaName, objectType);
|
||||
Assert.NotNull(locations);
|
||||
Cleanup(locations);
|
||||
}
|
||||
@@ -322,7 +322,7 @@ GO";
|
||||
string schemaName = "dbo";
|
||||
string objectType = "PROCEDURE";
|
||||
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetStoredProcedureScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(objectName, schemaName, objectType);
|
||||
Assert.Null(locations);
|
||||
}
|
||||
|
||||
@@ -339,9 +339,9 @@ GO";
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
string objectName = "sp_MSrepl_startup";
|
||||
string schemaName = null;
|
||||
string objectType = "PROCEDURE";
|
||||
string objectType = "StoredProcedure";
|
||||
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(scripter.GetStoredProcedureScripts, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(objectName, schemaName, objectType);
|
||||
Assert.NotNull(locations);
|
||||
Cleanup(locations);
|
||||
}
|
||||
@@ -377,40 +377,7 @@ GO";
|
||||
|
||||
Scripter scripter = new Scripter(serverConnection, connInfo);
|
||||
|
||||
Scripter.ScriptGetter sqlScriptGetter = null;
|
||||
switch (objectType)
|
||||
{
|
||||
case SynonymTypeName:
|
||||
sqlScriptGetter = scripter.GetSynonymScripts;
|
||||
break;
|
||||
case ScalarValuedFunctionTypeName:
|
||||
sqlScriptGetter = scripter.GetScalarValuedFunctionScripts;
|
||||
objectType = "Function";
|
||||
break;
|
||||
case TableValuedFunctionTypeName:
|
||||
sqlScriptGetter = scripter.GetTableValuedFunctionScripts;
|
||||
objectType = "Function";
|
||||
break;
|
||||
case TableTypeName:
|
||||
sqlScriptGetter = scripter.GetTableScripts;
|
||||
break;
|
||||
case ViewTypeName:
|
||||
sqlScriptGetter = scripter.GetViewScripts;
|
||||
break;
|
||||
case StoredProcedureTypeName:
|
||||
sqlScriptGetter = scripter.GetStoredProcedureScripts;
|
||||
break;
|
||||
case UserDefinedDataTypeTypeName:
|
||||
sqlScriptGetter = scripter.GetUserDefinedDataTypeScripts;
|
||||
objectType = "Type";
|
||||
break;
|
||||
case UserDefinedTableTypeTypeName:
|
||||
sqlScriptGetter = scripter.GetUserDefinedTableTypeScripts;
|
||||
objectType = "Type";
|
||||
break;
|
||||
}
|
||||
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(sqlScriptGetter, objectName, schemaName, objectType);
|
||||
Location[] locations = scripter.GetSqlObjectDefinition(objectName, schemaName, objectType);
|
||||
if (shouldReturnValidResult)
|
||||
{
|
||||
Assert.NotNull(locations);
|
||||
|
||||
Reference in New Issue
Block a user