Skip to content

Controlled Exception Handling for Incomplete VECTOR_SEARCH AST Nodes - #237

Closed
Fabian-Montero wants to merge 6 commits into
microsoft:mainfrom
cenfosoft:feature/HU-02-controlled-exception-handling
Closed

Fabian-Montero wants to merge 6 commits into
microsoft:mainfrom
cenfosoft:feature/HU-02-controlled-exception-handling

Conversation

@Fabian-Montero

Copy link
Copy Markdown

Summary

Add controlled script-generation validation for incomplete VECTOR_SEARCH AST nodes.

Prevent the generator from silently producing invalid T-SQL when a manually constructed VectorSearchTableReference does not include the required Metric property.

Implementation

Add validation in SqlScriptGeneratorVisitor.ExplicitVisit(VectorSearchTableReference).

Reject a VECTOR_SEARCH node with Metric == null before generating any SQL tokens.

Return: VECTOR_SEARCH requires a METRIC value.

Add an MSTest regression test that manually builds a VectorSearchTableReference without Metric and verifies that generation throws InvalidOperationException.

No ANTLR grammar, parser, generated AST code, or public API was changed.

TDD Evidence

RED: Without the validation guard, the focused test failed 1/1 because no InvalidOperationException was thrown and the generator silently produced invalid SQL.

image

GREEN: With the validation guard enabled, the same focused test passed 1/1.

image

Testing

Passed:

dotnet test Test/SqlDom/UTSqlScriptDom.csproj -c Debug -f net8.0 -m:1 --filter "FullyQualifiedName~VectorSearchWithoutMetricIsRejected"

dotnet test Test/SqlDom/UTSqlScriptDom.csproj -c Debug -f net8.0 -m:1 --filter "FullyQualifiedNameVectorSearchWithoutMetricIsRejected|FullyQualifiedNameTSql170SyntaxIn170ParserTest"

dotnet test Test/SqlDom/UTSqlScriptDom.csproj -c Debug -f net8.0 -m:1 --filter "FullyQualifiedName~TSql180SyntaxTests"

dotnet test Test/SqlDom/UTSqlScriptDom.csproj -c Debug -f net8.0 -m:1

The full net8.0 suite passed: 1,177 tests passed, 0 failed, and 0 skipped.

Signed-off-by: Randy Villarreal <rvillarrealf@ucenfotec.ac.cr>
Signed-off-by: Randy Villarreal <rvillarrealf@ucenfotec.ac.cr>
Signed-off-by: Randy Villarreal <rvillarrealf@ucenfotec.ac.cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants