Skip to content

Make MODEL_TYPE fragment classification non-breaking#217

Open
llali wants to merge 1 commit into
mainfrom
dev/llali/externalModel_breaking
Open

Make MODEL_TYPE fragment classification non-breaking#217
llali wants to merge 1 commit into
mainfrom
dev/llali/externalModel_breaking

Conversation

@llali

@llali llali commented Jul 20, 2026

Copy link
Copy Markdown
Member

Summary

Reworks the MODEL_TYPE fix so it fixes the fragment-classification bug (#176) without breaking the public API.

Background

Commit 20f9bf1 (PR #210, fixing #176) reclassified MODEL_TYPE as a TSqlFragment, but did so in a breaking way:

  • Repurposed the public enum ExternalModelTypeOption { EMBEDDINGS } into a TSqlFragment class.
  • Changed ExternalModelStatement.ModelType from ExternalModelTypeOption? (nullable enum) to a fragment reference.
  • Renamed the enum value EMBEDDINGSEmbeddings (moved into a new ExternalModelTypeOptionKind enum).

Any downstream consumer (e.g. DacFx) referencing ExternalModelTypeOption.EMBEDDINGS or reading ModelType as an enum would fail to compile.

What this PR does instead (additive / non-breaking)

  • Keeps enum ExternalModelTypeOption { EMBEDDINGS } and the ExternalModelStatement.ModelType (ExternalModelTypeOption?) member unchanged for backward compatibility.
  • Adds a visitable fragment ExternalModelTypeSpecification whose OptionKind reuses the existing ExternalModelTypeOption enum, plus a new ModelTypeSpecification member on ExternalModelStatement.
  • The parser populates both representations; the script generator prefers the fragment and falls back to the legacy enum.
  • This resolves MODEL_TYPE not classified as TSqlFragment in CreateExternalModelStatement #176 (MODEL_TYPE is now a proper visitable fragment with real token offsets) while existing enum-based consumers keep compiling.

Files changed

  • SqlScriptDom/Parser/TSql/Ast.xml
  • SqlScriptDom/Parser/TSql/ExternalModelTypeOption.cs
  • SqlScriptDom/Parser/TSql/TSql170.g, TSql180.g
  • SqlScriptDom/ScriptDom/SqlServer/ScriptGenerator/SqlScriptGeneratorVisitor.CreateExternalModelStatement.cs
  • SqlScriptDom/ScriptDom/SqlServer/ScriptGenerator/SqlScriptGenerator.AlterExternalModelStatement.cs
  • Test/SqlDom/Only170SyntaxTests.cs

Testing

  • Full suite: 624 passed, 0 failed on both net8.0 and net472.
  • Test asserts both the new fragment (ModelTypeSpecification / OptionKind) and the legacy enum (ModelType == ExternalModelTypeOption.EMBEDDINGS) to prove backward compatibility.

Commit 20f9bf1 (PR #210, fixing #176) reclassified MODEL_TYPE as a
TSqlFragment but broke the public API: it repurposed the enum
ExternalModelTypeOption into a fragment class and changed the type of
ExternalModelStatement.ModelType from ExternalModelTypeOption? to a
fragment reference.

This change delivers the same fix additively, without breaking the API:

- Keep enum ExternalModelTypeOption { EMBEDDINGS } and the
  ExternalModelStatement.ModelType (ExternalModelTypeOption?) member
  unchanged for backward compatibility.
- Add a visitable fragment ExternalModelTypeSpecification whose
  OptionKind reuses the existing ExternalModelTypeOption enum, plus a
  new ModelTypeSpecification member on ExternalModelStatement.
- The parser populates both representations; the script generator
  prefers the fragment and falls back to the legacy enum.

All 624 unit tests pass on net8.0 and net472.
@llali

llali commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

@ZEUSXXIV you commit caused breaking changes and I had to make these changes in this PR to make sure you fix stays but also they won't be any breaking changes. please let me know if you have any comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MODEL_TYPE not classified as TSqlFragment in CreateExternalModelStatement

1 participant