Repository navigation
fix(xpo): XpoDatabase creates only the tables of its own data layer - #25
Merged
Merged
Conversation
The schema update (UpdateSchema = DatabaseAndSchema) ran session.UpdateSchema()
on a SimpleDataLayer without a dictionary: XPO's process-wide default dictionary
with every persistent class of every loaded assembly. Classes that
[XpoDataLayer("other")] assigns to another data layer got a table in every
database, and two copies of an assembly in separate load contexts (plugins) made
it throw "Dictionary already contains ClassInfo".
It now uses a dictionary of its own with the classes XPO collects per assembly,
minus those of other data layers. Classes without [XpoDataLayer] (with or without
[Persistent]) still get their tables, as before. Version 26.1.3.42.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
With
UpdateSchema = AutoCreateOption.DatabaseAndSchema,XpoDatabase.CreateDataLayerransession.UpdateSchema()on aSimpleDataLayercreated without a dictionary. That uses XPO's process-wide default dictionary with every persistent class of every loaded assembly, so:[XpoDataLayer("other")]assigns to another data layer got a table in every database (the data layer's own dictionary was filtered, the schema update was not);AssemblyLoadContexts (plugins), it threwDictionary already contains ClassInfo …, also for data layers that never use those classes;XpoDefault's dictionary as a side effect.Found in DX.Cms: a plugin's XPO classes ended up in the content database, and test hosts that load a plugin more than once failed.
Fix
The schema update uses a dictionary of its own, with the classes XPO collects per assembly (
CollectClassInfos, one throwaway dictionary per assembly so duplicate copies do not clash), minus the classes of other data layers. Only persistent class infos go toUpdateSchema/CreateObjectTypeRecords.Behaviour kept: classes without
[XpoDataLayer], with or without[Persistent], still get their tables in every data layer (PlainXPObjectWithoutPersistentAttribute_IsUsable). Tables that older versions created for other data layers stay in existing databases.Version: DX.Data.Xpo 26.1.3.42, with release notes in the csproj,
DX.Data.Xpo/README.mdand the root README.Tests
UpdateSchema_CreatesTheTablesOfItsOwnDataLayerOnly,UpdateSchema_CreatesTheTablesOfClassesAssignedToIt(OtherLayerNotewith[XpoDataLayer]).🤖 Generated with Claude Code