2016-05-24 10 views
1

レコードを作成しようとしていますが、このエラーが発生しています。CQL Cassandra必須ではないPRIMARY KEYのパートID

[40] pry(main)> a = TopicPost.new(topic_id: "professional_safety", pub_date: "5a612420-21e2-11e6-bdf4-0800200c9a66") 
=> #<TopicPost topic_id: "professional_safety", pub_date: 5a612420-21e2-11e6-bdf4-0800200c9a66, publisher: nil, author_id: nil, id: nil, message: nil, name: nil, link: nil, shared_count: nil, prospect_score: nil, indico_score: nil, keywords: #<Set: {}>, updated_at: nil, created_at: nil, profile_image: nil, bio: nil, account_link: nil, twitter_handle: nil, favorite_count: nil, followers_count: nil, klout_score: nil, has_engagements: nil, is_retweet: nil, engaged_influencer_ids: #<Set: {}>, urls: #<Set: {}>, images: #<Set: {}>, feed_name: nil, feed_url: nil, description: nil, title: nil, batch_id: nil, score: nil, fcm: nil, scorelog: {}> 
[41] pry(main)> a.save 
Cql::QueryError: Missing mandatory PRIMARY KEY part id 
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/cql-rb-2.0.4/lib/cql/client/client.rb:545:in `execute' 
[42] pry(main)> 

答えて

2

テーブルの構造はどのようになっていますか?

複合PRIMARY KEYがあり、idの列がその一部であると思います。 Cassandra PRIMARY KEYはユニークなので、UPSERTには完全なキーを提供する必要があります。あなたのコードを見て

、特にコメントアウト部分は、私は手がかりを参照してください行います

[40] pry(main)> a = TopicPost.new(topic_id: "professional_safety", pub_date: "5a612420-21e2-11e6-bdf4-0800200c9a66") 
=> #<TopicPost topic_id: "professional_safety", pub_date: 5a612420-21e2-11e6-bdf4-0800200c9a66, publisher: nil, author_id: nil, id: nil, message: nil, name: nil, link: nil, shared_count: nil, prospect_score: nil, indico_score: nil, keywords: #<Set: {}>, updated_at: nil, created_at: nil, profile_image: nil, bio: nil, account_link: nil, twitter_handle: nil, favorite_count: nil, followers_count: nil, klout_score: nil, has_engagements: nil, is_retweet: nil, engaged_influencer_ids: #<Set: {}>, urls: #<Set: {}>, images: #<Set: {}>, feed_name: nil, feed_url: nil, description: nil, title: nil, batch_id: nil, score: nil, fcm: nil, scorelog: {}> 

あなたのTopicPost.new文でidための価値を提供するためには表示されませんが、私はあなたのコメントでそれを参照してください。

author_id: nil, id: nil, message: nil 

idのための価値を提供してください。もちろん、PRIMARY KEY定義が表示されない場合は、値を提供していないがそこから開始する必要のある他の列が存在する可能性があります。

+1

それでした。ありがとう! –

+0

@BrianLau Excellent。お役に立てて嬉しいです! – Aaron

関連する問題