Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError accessing results from Document.view when reduce=False and value is dictionary #142

Open
vkfu opened this issue Jun 27, 2012 · 1 comment

Comments

@vkfu
Copy link

vkfu commented Jun 27, 2012

Additional details at mailing list post:
https://groups.google.com/forum/?fromgroups#!topic/couchdbkit/OldePEe3uxU

Ubuntu 12.04
Couchdbkit 0.6.2
Couchdb 1.2
Django 1.5.dev17942
Python 2.7.3

/home/vincent/temp/greeting/views/all contains a file called map.js with the contents:
function(doc) { emit( 1, {'a': 1, 'b': 2} ); }
There is no reduce.js (so reduce=False is unnecessary)

Reproduce via the following interactive Django Python session:

$ ./manage.py shell

from couchdbkit import *
class Greeting(Document):
 def __unicode__(self):
  return None

server = Server()
db = server.get_or_create_db("greeting")
Greeting.set_db(db)
greet = Greeting()
greet.test = "test"
greet.save()
from couchdbkit.designer import push
push('/home/vincent/temp/greeting', db)
greets = Greeting.view('greeting/all')
greets.count()  # returns 1
greets.first()

Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/couchdbkit/client.py", line 930, in first
return list(self)[0]
File "/usr/local/lib/python2.7/dist-packages/couchdbkit/client.py", line 920, in iterator
yield wrapper(row)
File "/usr/local/lib/python2.7/dist-packages/couchdbkit/client.py", line 901, in row_wrapper
return schema(data)
File "/usr/local/lib/python2.7/dist-packages/couchdbkit/schema/util.py", line 29, in wrap
cls = classes[doc_type]
KeyError: None

Via the URL http://127.0.0.1:5984/greeting/_design/greeting/_view/all Couchdb gives the output

{"total_rows":1,"offset":0,"rows":[{"id":"49ca1d5086e0c7eb36471d2e621f5a49","key":1,"value":{"a":1,"b":2}}]}

This is the line from the Couchdb log for the Couchdbkit query

[info] [<0.12793.16>] 127.0.0.1 - - GET /greeting/_design/greeting/_view/all?wrap_doc=true 200

@vkfu
Copy link
Author

vkfu commented Jun 27, 2012

The same error occurs with Couchdbkit 0.6.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant