Updating a document resets reference strength
TedSanne opened this issue · comments
When querying a document all references seem to have the Weak prop on SanityReference set to null.
This in turn seems to be converted into a strong reference when the document is updated.
Example:
var docSet = await _sanity.DocumentSet<Filmomtale>()
.Include(f => f.Distributor)
.Where(f => f.Id == id)
.ExecuteAsync(cancellationToken);
var doc = docSet.Single();
<... update some fields on doc, but leave Distributor reference untouched ....>
await _sanity.DocumentSet<Filmomtale>()
.Update(doc)
.CommitAsync(cancellationToken: cancellationToken);
Here "Distributor" is a reference to another document type, the schema specifies the reference as weak:
{
title: 'Distributør',
name: 'distributor',
type: 'reference',
readOnly: false,
to: [
{ type: 'distributor' }
],
weak: true,
group: "metadata"
}
When debugging this I can see that the Weak property on the reference to Distributor is null.
After the document has been updated, Sanity Studio now shows a warning "Reference strength mismatch" for the Distributor field.
Is this a bug, or is there something else I need to do when querying to make sure the reference is returned?
EDIT: I am using 1.5.0 from NuGet
Other weak references that are not .Incude(...)
in the query are not affected.