Kouhei Sutou
null+****@clear*****
Fri Jan 10 19:08:27 JST 2014
Kouhei Sutou 2014-01-10 19:08:27 +0900 (Fri, 10 Jan 2014) New Revision: 76b65b5b0d100129487dc5cb6f28aadd2e85933a https://github.com/ranguba/rroonga/commit/76b65b5b0d100129487dc5cb6f28aadd2e85933a Message: Add _value value to Record#attributes [groonga-dev,02046] Suggested by ongaeshi. Thanks!!! Modified files: lib/groonga/record.rb test/test-record.rb Modified: lib/groonga/record.rb (+7 -0) =================================================================== --- lib/groonga/record.rb 2014-01-10 19:07:35 +0900 (b1de2c7) +++ lib/groonga/record.rb 2014-01-10 19:08:27 +0900 (aad597b) @@ -435,6 +435,7 @@ module Groonga add_id(attributes, record) add_key(attributes, record) + add_value(attributes, record) add_score(attributes, record) add_n_sub_records(attributes, record) add_columns(attributes, record) @@ -488,6 +489,12 @@ module Groonga end end + def add_value(attributes, record) + if record.support_value? + attributes["_value"] = build_value(record.value) + end + end + def add_score(attributes, record) if record.support_score? attributes["_score"] = record.score Modified: test/test-record.rb (+32 -0) =================================================================== --- test/test-record.rb 2014-01-10 19:07:35 +0900 (e719917) +++ test/test-record.rb 2014-01-10 19:08:27 +0900 (8705204) @@ -318,6 +318,7 @@ class RecordTest < Test::Unit::TestCase } groonga =****@bookm*****(values) assert_equal(values.merge("_id" => groonga.id, + "_value" => 0, "content" => nil, "user" => nil), groonga.attributes) @@ -336,11 +337,13 @@ class RecordTest < Test::Unit::TestCase expected = { "_id" => 1, + "_value" => 0, "user" => nil, "uri" => "http://groonga.org/", "rate" => 5, "next" => { "_id" => 2, + "_value" => 0, "user" => nil, "uri" => "http://groonga.org/document.html", "rate" => 8, @@ -370,6 +373,7 @@ class RecordTest < Test::Unit::TestCase doc_page_attributes = { "_id" => 2, + "_value" => 0, "user" => nil, "uri" => "http://groonga.org/document.html", "rate" => 8, @@ -379,6 +383,7 @@ class RecordTest < Test::Unit::TestCase } top_page_attributes = { "_id" => 1, + "_value" => 0, "user" => nil, "uri" => "http://groonga.org/", "rate" => 5, @@ -406,6 +411,7 @@ class RecordTest < Test::Unit::TestCase "comment" => "Great!", "content" => nil, "_id" => 1, + "_value" => 0, "rate" => 5, "uri" => "http://groonga.org/", "user" => nil @@ -416,6 +422,27 @@ class RecordTest < Test::Unit::TestCase assert_equal(expected_attributes, select_result_result.attributes) end + def test_sort_result + @bookmarks.add(top_page) + sort_result =****@bookm*****(["_id"]) + sort_result_result = sort_result.first + + expected_attributes = { + "_id" => 1, + "_value" => { + "comment" => "Great!", + "content" => nil, + "_id" => 1, + "_value" => 0, + "rate" => 5, + "uri" => "http://groonga.org/", + "user" => nil + }, + } + + assert_equal(expected_attributes, sort_result_result.attributes) + end + def test_self_referencing need_self_recursive_equal @@ -426,6 +453,7 @@ class RecordTest < Test::Unit::TestCase expected = { "_id" => 1, + "_value" => 0, "user" => nil, "uri" => "http://groonga.org/", "rate" => 5, @@ -446,12 +474,14 @@ class RecordTest < Test::Unit::TestCase expected = { "_id" => 1, + "_value" => 0, "user" => nil, "uri" => "http://groonga.org/", "rate" => 5, "related_bookmarks" => [ { "_id" => 2, + "_value" => 0, "comment" => "Informative", "content" => nil, "rate" => 8, @@ -481,6 +511,7 @@ class RecordTest < Test::Unit::TestCase top_page_attributes = { "_id" => 1, + "_value" => 0, "user" => nil, "uri" => "http://groonga.org/", "rate" => 5, @@ -489,6 +520,7 @@ class RecordTest < Test::Unit::TestCase } doc_page_attributes = { "_id" => 2, + "_value" => 0, "comment" => "Informative", "content" => nil, "rate" => 8, -------------- next part -------------- HTML����������������������������...Download