Skip to content

Commit

Permalink
feat: Force _rev for queries with .select fields
Browse files Browse the repository at this point in the history
When specifying fields in a query, e.g.
`Q('io.cozy.todos').where({done: true}).select(['date'])`, the revision
was missing if not explicitly given. This is now problematic because we
rely on the revision existence to identify "virtual" documents, i.e. not
persisted in CouchDB, that never have any revision.
See #1486 for more insights.
  • Loading branch information
paultranvan committed Aug 20, 2024
1 parent 594fe63 commit b182986
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/cozy-stack-client/src/DocumentCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,8 @@ The returned documents are paginated by the stack.
return {
selector: mergedSelector,
use_index: indexName,
// TODO: type and class should not be necessary, it's just a temp fix for a stack bug
fields: fields ? [...fields, '_id', '_type', 'class'] : undefined,
// _id is necessary for the store, and _rev is required for offline. See https://github.com/cozy/cozy-client/blob/95978d39546023920b0c01d689fed5dd41577a02/packages/cozy-client/src/CozyClient.js#L1153
fields: fields ? [...fields, '_id', '_rev'] : undefined,
limit,
skip,
bookmark: options.bookmark || bookmark,
Expand Down

0 comments on commit b182986

Please sign in to comment.