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

オープン
#142 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
database

調査の方向性

文書化されている Django shell セッションとビュー定義で問題を再現します。まず couchdbkit/client.py の iterator、first、row_wrapper 周辺を確認し、次に couchdbkit/schema/util.py の wrap 周辺を調べます。reduce=False と辞書値を使ってビューの結果にアクセスしても KeyError が発生しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Python
スター
261
フォーク
90
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

benoitc/couchdbkit のほかの issue

benoitc/couchdbkit の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。