Skip to content

Commit adaaaa1

Browse files
committed
Improve support for the include_docs option in the schema module.
--HG-- extra : convert_revision : svn%3A7a298fb0-333a-0410-83e7-658617cd9cf3/trunk%40123
1 parent 5ac45fb commit adaaaa1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

couchdb/schema.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ def __init__(self, design, map_fun, reduce_fun=None,
233233
def __get__(self, instance, cls=None):
234234
if self.wrapper is DEFAULT:
235235
def wrapper(row):
236+
if row.doc is not None:
237+
return cls.wrap(row.doc)
236238
data = row.value
237239
data['_id'] = row.id
238240
return cls.wrap(data)
@@ -340,10 +342,13 @@ def query(cls, db, map_fun, reduce_fun, language='javascript',
340342
included in the values of the view will be treated as if they were
341343
missing from the document. If you'd rather want to load the full
342344
document for every row, set the `eager` option to `True`, but note that
343-
this will initiate a new HTTP request for every document.
345+
this will initiate a new HTTP request for every document, unless the
346+
`include_docs` option is explitly specified.
344347
"""
345348
def _wrapper(row):
346349
if eager:
350+
if row.doc is not None:
351+
return row.doc
347352
return cls.load(db, row.id)
348353
data = row.value
349354
data['_id'] = row.id
@@ -360,10 +365,13 @@ def view(cls, db, viewname, eager=False, **options):
360365
included in the values of the view will be treated as if they were
361366
missing from the document. If you'd rather want to load the full
362367
document for every row, set the `eager` option to `True`, but note that
363-
this will initiate a new HTTP request for every document.
368+
this will initiate a new HTTP request for every document, unless the
369+
`include_docs` option is explitly specified.
364370
"""
365371
def _wrapper(row):
366372
if eager:
373+
if row.doc is not None:
374+
return row.doc
367375
return cls.load(db, row.id)
368376
data = row.value
369377
data['_id'] = row.id

0 commit comments

Comments
 (0)