Make MODEL_TYPE fragment classification non-breaking - #217
Conversation
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.
|
@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 |
|
@llali Thanks for the fix and the explanation, makes sense now. For future reference, what should I actually be checking for before raising PRs like this, so I catch breaking changes like this earlier? |
Hi @ZEUSXXIV it's prefers not to break existing public APIs unless we can do a major version bump. I'll add more tests to prevent breaking changes like this |
@llali Got it! Thanks again |
Summary
Reworks the
MODEL_TYPEfix so it fixes the fragment-classification bug (#176) without breaking the public API.Background
Commit
20f9bf1(PR #210, fixing #176) reclassifiedMODEL_TYPEas aTSqlFragment, but did so in a breaking way:enum ExternalModelTypeOption { EMBEDDINGS }into aTSqlFragmentclass.ExternalModelStatement.ModelTypefromExternalModelTypeOption?(nullable enum) to a fragment reference.EMBEDDINGS→Embeddings(moved into a newExternalModelTypeOptionKindenum).Any downstream consumer (e.g. DacFx) referencing
ExternalModelTypeOption.EMBEDDINGSor readingModelTypeas an enum would fail to compile.What this PR does instead (additive / non-breaking)
enum ExternalModelTypeOption { EMBEDDINGS }and theExternalModelStatement.ModelType(ExternalModelTypeOption?) member unchanged for backward compatibility.ExternalModelTypeSpecificationwhoseOptionKindreuses the existingExternalModelTypeOptionenum, plus a newModelTypeSpecificationmember onExternalModelStatement.MODEL_TYPEnot classified asTSqlFragmentinCreateExternalModelStatement#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.xmlSqlScriptDom/Parser/TSql/ExternalModelTypeOption.csSqlScriptDom/Parser/TSql/TSql170.g,TSql180.gSqlScriptDom/ScriptDom/SqlServer/ScriptGenerator/SqlScriptGeneratorVisitor.CreateExternalModelStatement.csSqlScriptDom/ScriptDom/SqlServer/ScriptGenerator/SqlScriptGenerator.AlterExternalModelStatement.csTest/SqlDom/Only170SyntaxTests.csTesting
net8.0andnet472.ModelTypeSpecification/OptionKind) and the legacy enum (ModelType == ExternalModelTypeOption.EMBEDDINGS) to prove backward compatibility.