Fix SQL clause parsing and stabilize tests #110
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
SELECT/INSERT/UPDATE/DELETE) needed to correctly capture initial clause content and then read remaining parts in order.DELETEsometimes emitted duplicate/misplaced targets whenOUTPUTwas present and needed normalization.Description
SelectStatementParser,InsertStatementParser,UpdateStatementParser,DeleteStatementParser) to first capture the initial clause using the part reader and then callReadSegmentsto parse following clauses, passingClauseStart.StatementEndas a terminator.StatementParserBase.ReadSegmentsto provide clause terminators (includingStatementEnd) to part readers so readers stop at statement end.SqlStatementPartReaders.csto explicitly consume their leading keywords viaTryConsumeSegmentKeywordand to handle empty results (e.g.,DeletePartReaderreturnsnullwhen no target tokens were read).SqlQueryAnalyzer.Parsestrip a pair of surrounding quotes for certain quoted inputs and updatedSqlQuery/SqlDeleteStatementbinding/output logic soDELETEoutput formatting avoids duplicate target text when equal to theFROMexpression.HttpListenererrors by catchingObjectDisposedExceptionalongsideHttpListenerExceptioninServeCompressedMetadataAsync.Testing
mise exec dotnet@9.0.100 -- dotnet test Utils.slnunder .NET 9.dotnet testcompleted without errors (packages created as part of the solution build).Codex Task