You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Nothing refuses a Mongo variant field with the same name as a base field #30472
What a user sees. A Mongo variant model (@@base(Asset, "photo")) can declare a field with the same name as a field of its base model, and nothing reports it. If the two have different types, the ORM writes and reads that field through .variant(...) with the variant's codec, while the collection validator derived from the contract keeps the base field's type. A write the ORM accepts can then fail with Document failed validation. No committed contract has such a field today.
Where. Mongo PSL interpretation of @@base in packages/2-mongo-family/2-authoring/contract-psl/src/interpreter.ts (and the TypeScript builder's variant handling); the ORM merge of base and variant fields in packages/2-mongo-family/5-query-builders/orm/src/collection.ts.
Likely fix. Refuse a variant field whose name matches a base field during contract emit, with a diagnostic at the variant field naming both models. If redeclaring a base field with the same type should be allowed, refuse only a differing type.
Activity