public void TestSingleLineFormat() { const string sourceFormat = @"SELECT SELECTION.NAME, COUNT(*) OVER (PARTITION BY NAME ORDER BY RESPONDENTBUCKET_ID, SELECTION_ID) DUMMY_COUNT, MAX(RESPONDENTBUCKET_ID) KEEP (DENSE_RANK FIRST ORDER BY PROJECT_ID, SELECTION_ID) FROM SELECTION LEFT JOIN RESPONDENTBUCKET ON SELECTION.RESPONDENTBUCKET_ID = RESPONDENTBUCKET.RESPONDENTBUCKET_ID LEFT JOIN TARGETGROUP ON RESPONDENTBUCKET.TARGETGROUP_ID = TARGETGROUP.TARGETGROUP_ID ORDER BY NAME, SELECTION_ID;" ; _documentRepository.UpdateStatements(sourceFormat); var executionContext = new ActionExecutionContext(sourceFormat, 0, 0, 0, _documentRepository); Formatter.SingleLineExecutionHandler.ExecutionHandler(executionContext); const string expectedFormat = "SELECT SELECTION.NAME, COUNT (*) OVER (PARTITION BY NAME ORDER BY RESPONDENTBUCKET_ID, SELECTION_ID) DUMMY_COUNT, MAX (RESPONDENTBUCKET_ID) KEEP (DENSE_RANK FIRST ORDER BY PROJECT_ID, SELECTION_ID) FROM SELECTION LEFT JOIN RESPONDENTBUCKET ON SELECTION.RESPONDENTBUCKET_ID = RESPONDENTBUCKET.RESPONDENTBUCKET_ID LEFT JOIN TARGETGROUP ON RESPONDENTBUCKET.TARGETGROUP_ID = TARGETGROUP.TARGETGROUP_ID ORDER BY NAME, SELECTION_ID"; AssertFormattedResult(executionContext, expectedFormat); }
private SqlDocumentRepository ConfigureDocumentRepository() { var documentRepository = new SqlDocumentRepository(_infrastructureFactory.CreateParser(), _infrastructureFactory.CreateStatementValidator(), _infrastructureFactory.CreateDatabaseModel(ConfigurationProvider.ConnectionStrings[0], "Test database model")); documentRepository.UpdateStatements(_editor.Text); return(documentRepository); }
private static MultiNodeEditorData GetMultiNodeEditorData(string sqlText, int caretOffset) { DocumentRepository.UpdateStatements(sqlText); var executionContext = new ActionExecutionContext(sqlText, caretOffset, caretOffset, 0, DocumentRepository); return(MultiNodeEditorDataProvider.GetMultiNodeEditorData(executionContext)); }
private List <TextSegment> FindUsagesOrdered(string statementText, int currentPosition) { _documentRepository.UpdateStatements(statementText); var executionContext = new ActionExecutionContext(statementText, currentPosition, currentPosition, 0, _documentRepository); FindUsagesCommand.FindUsages.ExecutionHandler(executionContext); return(executionContext.SegmentsToReplace.OrderBy(s => s.IndextStart).ToList()); }
public void TestNavigateToColumnDefinitionWhenDatabaseModelNotLoaded() { const string query = "SELECT P.PROJECT_ID, P.NAME FROM (SELECT * FROM PROJECT) P"; var databaseModel = new OracleTestDatabaseModel(); databaseModel.AllObjects.Clear(); var documentRepository = new SqlDocumentRepository(OracleSqlParser.Instance, new OracleStatementValidator(), databaseModel); documentRepository.UpdateStatements(query); const int caretOffset = 13; var executionContext = new ActionExecutionContext(query, caretOffset, caretOffset, caretOffset, documentRepository); var targetIndex = _navigationService.NavigateToDefinition(executionContext); targetIndex.ShouldBe(null); }
private ActionExecutionContext CreateExecutionContext(string statementText, int currentPosition) { _documentRepository.UpdateStatements(statementText); return(new ActionExecutionContext(statementText, currentPosition, currentPosition, currentPosition, _documentRepository)); }