Repository navigation
Wire the model builder to the field type registry - #2733
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #2730
What
FieldStoragenow asks the field type registry the schema was built with where a field lives (IFieldType.StorageKind) and keeps only the column CLR type and length defaults of the core types. The three schema checks thatContentModelBuilderraised at the firstcontext.Modelaccess (and the duplicate-column check) now run inSchemaValidator, so they appear atSchemaBuilder.Build()with the other FCMS12xx errors.ContentModelBuilderno longer referencesSchemaValidationExceptionorSchemaError.Why
A plugin field type the validator accepted used to throw
InvalidOperationExceptionwhen the context built its model, and a field namedsiteIdonly failed on the first query.Dependencies
None. No new packages or actions.
Decisions beyond the issue
SchemaModelgets aninternal IFieldTypeRegistry FieldTypes, set bySchemaBuilder.Build()through the internal constructor. It adds nothing toPublicAPI.Unshipped.txt, stays out ofSchemaJsonWriterandSchemaModelKey, and the model builder needs no second reference. I rejected a public property (surface to keep after 1.0) and a side table keyed bySchemaModel(hidden state). ASchemaModelbuilt any other way would have no registry, but the constructor is internal and onlySchemaBuildercalls it.Columntype is a nullablestring. It honours[Length]max, is neverNOT NULL, has no default. A plugin that needs another CLR type stores a string form. A pluginJsontype is a nullable JSON string column; if the field isMultipleit isNOT NULL DEFAULT '[]', as the core lists are.selectandcomponentwithMultipleareJsonbecause theirStorageKindsays so. A singlecomponentis still flattened by name, since it is the only type whose columns come from another type.SchemaValidationException, and two fields on one column was the third such check.jobfails now rather than after Database-backed job runner with leases, retries, dead letter and recurring jobs #2698 addscms_job. The{type}-i18nbeside a localizedtypecheck stays. The list lives inStorageNames.SystemTables, built fromStorageNames.Prefixand the existingDocument,ReferenceandVersionconstants; system columns (SystemColumns,LocaleTableColumns) live there too andStorageNames.Table/LocaleTabletake a type name so the validator and the mapping share them. Only collections and singletons are checked; a component or block namedjobhas no table. A new Appendix C table must be added to that list.id,locale) is already FCMS1206 by name, so the column check does not report it a second time. A repeated field name is reported once, as before.SchemaModelFactory.Create(FieldDraft)became internal-visible so the validator can ask the registry about a draft.Acceptance
Columnbuilds a context and round-trips a row on SQLite without a change toFieldStorage(PluginFieldStorageTests;Jsonas well)siteIdand a collection namedversionfailSchemaBuilder.Build()with FCMS1206 (alsojoband the other Appendix C tables)ContentModelBuilderraises noSchemaValidationExceptionof its own (ContentModelBuilderRaisesNoSchemaErrorsOfItsOwninspects the source)ContentModelTeststoStorageSchemaValidationTestsand now callBuild(); theFieldStoragetest of an unmapped field type now asserts the plugin mapping)Verified on SQLite only (Q19):
dotnet build -c Release -warnaserroranddotnet test -c Releasepass.