2012-04-30 12 views
1

文字列のハッシュキーと範囲キーで設定されたDynamoDBデータベースがあります。これは動作します:table.queryでattributes_to_getを使用したときのBoto DynamoDBエラー

>>> x = table.query(hash_key='[email protected]', range_key_condition=BEGINS_WITH("20"), 
    request_limit=5) 
>>> [i for i in x] 
[{u'x-entry-page': ... 

これは、と私はなぜ理解することはできませんしません:

>>> x = table.query(hash_key='[email protected]', range_key_condition=BEGINS_WITH("20"), 
    attributes_to_get=[u'x-start-time'], request_limit=5) 
>>> [i for i in x] 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/boto-2.3.0-py2.7.egg/boto/dynamodb/layer2.py", line 588, in query 
    yield item_class(table, attrs=item) 
    File "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/boto-2.3.0-py2.7.egg/boto/dynamodb/item.py", line 45, in __init__ 
    raise DynamoDBItemError('You must supply a hash_key') 
boto.dynamodb.exceptions.DynamoDBItemError: BotoClientError: You must supply a hash_key 

これは私には非常にほとんど意味がありません。私は明らかにハッシュキーを供給しています。 Botoのソースを見るだけでは問題が何であるかはわかりません。問題の属性はすべてのレコードに確実に存在します(エラーを送出するものではありません)。

提案がありますか?ありがとう!

答えて

2

同僚の助けを借りて、われわれは把握している。問題は、attributes_to_getにはハッシュと範囲キーの名前が必要だということです。だから、これは動作します:

>>> x = table.query(hash_key='[email protected]', range_key_condition=BEGINS_WITH("20"), 
    attributes_to_get=[u'x-start-time', 'user_id', 'session_time'], request_limit=5) 
>>> [i for i in x] 
[{u'session_time': u'2012/04/18 09:59:20.247 -0400', u'user_id': u'[email protected]', 
    u'x-start-time': u'2012/04/18 09:59:20.247 -0400'}, ... 

これは私に(マイナー)後のBoto問題のように思える...

+0

、[問題を修正しました3時間前](https://github.com/boto/boto/issues/656)! – Harlan

関連する問題