groonga 0.0.7 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/NEWS.ja.rdoc +56 -0
  2. data/NEWS.rdoc +58 -0
  3. data/Rakefile +2 -3
  4. data/benchmark/read-write-many-small-items.rb +16 -32
  5. data/benchmark/write-many-small-items.rb +14 -28
  6. data/example/bookmark.rb +19 -17
  7. data/example/index-html.rb +11 -1
  8. data/example/search/config.ru +14 -9
  9. data/ext/rb-grn-array.c +6 -6
  10. data/ext/rb-grn-column.c +348 -18
  11. data/ext/rb-grn-context.c +8 -4
  12. data/ext/rb-grn-database.c +6 -7
  13. data/ext/rb-grn-exception.c +101 -5
  14. data/ext/rb-grn-expression.c +206 -23
  15. data/ext/rb-grn-fix-size-column.c +6 -39
  16. data/ext/rb-grn-hash.c +24 -24
  17. data/ext/rb-grn-index-column.c +74 -19
  18. data/ext/rb-grn-logger.c +48 -0
  19. data/ext/rb-grn-object.c +281 -67
  20. data/ext/rb-grn-operation.c +1 -1
  21. data/ext/rb-grn-patricia-trie-cursor.c +10 -1
  22. data/ext/rb-grn-patricia-trie.c +268 -7
  23. data/ext/rb-grn-query.c +52 -1
  24. data/ext/rb-grn-record.c +8 -2
  25. data/ext/rb-grn-snippet.c +63 -1
  26. data/ext/rb-grn-table-cursor-key-support.c +15 -1
  27. data/ext/rb-grn-table-cursor.c +57 -0
  28. data/ext/rb-grn-table-key-support.c +382 -46
  29. data/ext/rb-grn-table.c +729 -192
  30. data/ext/rb-grn-type.c +63 -12
  31. data/ext/rb-grn-utils.c +156 -158
  32. data/ext/rb-grn-variable.c +18 -0
  33. data/ext/rb-grn.h +85 -21
  34. data/ext/rb-groonga.c +13 -3
  35. data/extconf.rb +19 -4
  36. data/html/developer.html +1 -1
  37. data/html/header.html.erb +1 -1
  38. data/html/index.html +4 -4
  39. data/lib/groonga.rb +10 -0
  40. data/lib/groonga/expression-builder.rb +81 -42
  41. data/lib/groonga/patricia-trie.rb +13 -0
  42. data/lib/groonga/record.rb +158 -13
  43. data/lib/groonga/schema.rb +339 -33
  44. data/pkg-config.rb +6 -1
  45. data/test-unit/lib/test/unit.rb +23 -42
  46. data/test-unit/lib/test/unit/assertionfailederror.rb +11 -0
  47. data/test-unit/lib/test/unit/assertions.rb +87 -9
  48. data/test-unit/lib/test/unit/autorunner.rb +20 -11
  49. data/test-unit/lib/test/unit/collector.rb +1 -8
  50. data/test-unit/lib/test/unit/collector/load.rb +2 -3
  51. data/test-unit/lib/test/unit/color-scheme.rb +13 -1
  52. data/test-unit/lib/test/unit/diff.rb +223 -37
  53. data/test-unit/lib/test/unit/error.rb +4 -0
  54. data/test-unit/lib/test/unit/failure.rb +31 -5
  55. data/test-unit/lib/test/unit/notification.rb +8 -4
  56. data/test-unit/lib/test/unit/omission.rb +51 -3
  57. data/test-unit/lib/test/unit/pending.rb +4 -0
  58. data/test-unit/lib/test/unit/testcase.rb +55 -4
  59. data/test-unit/lib/test/unit/ui/console/testrunner.rb +190 -4
  60. data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +14 -0
  61. data/test-unit/lib/test/unit/ui/testrunner.rb +8 -0
  62. data/test-unit/lib/test/unit/version.rb +1 -1
  63. data/test-unit/sample/{tc_adder.rb → test_adder.rb} +3 -1
  64. data/test-unit/sample/{tc_subtracter.rb → test_subtracter.rb} +3 -1
  65. data/test-unit/sample/test_user.rb +1 -0
  66. data/test-unit/test/collector/test-descendant.rb +2 -4
  67. data/test-unit/test/collector/test_objectspace.rb +7 -5
  68. data/test-unit/test/run-test.rb +2 -0
  69. data/test-unit/test/test-color-scheme.rb +7 -0
  70. data/test-unit/test/test-diff.rb +48 -7
  71. data/test-unit/test/test-omission.rb +1 -1
  72. data/test-unit/test/test-testcase.rb +47 -0
  73. data/test-unit/test/test_assertions.rb +79 -10
  74. data/test/groonga-test-utils.rb +6 -1
  75. data/test/test-array.rb +29 -14
  76. data/test/test-column.rb +107 -55
  77. data/test/test-context.rb +5 -0
  78. data/test/test-database.rb +2 -37
  79. data/test/test-exception.rb +9 -1
  80. data/test/test-expression-builder.rb +23 -5
  81. data/test/test-expression.rb +44 -8
  82. data/test/test-fix-size-column.rb +16 -5
  83. data/test/test-gqtp.rb +70 -0
  84. data/test/test-hash.rb +142 -43
  85. data/test/test-index-column.rb +9 -9
  86. data/test/test-patricia-trie.rb +79 -20
  87. data/test/test-procedure.rb +4 -2
  88. data/test/test-record.rb +32 -20
  89. data/test/test-remote.rb +3 -2
  90. data/test/test-schema.rb +226 -92
  91. data/test/test-table-cursor.rb +103 -1
  92. data/test/test-table-offset-and-limit.rb +102 -0
  93. data/test/test-table-select-normalize.rb +4 -4
  94. data/test/test-table-select.rb +52 -8
  95. data/test/test-table.rb +235 -116
  96. data/test/test-type.rb +2 -2
  97. data/test/test-variable-size-column.rb +21 -5
  98. data/test/test-vector-column.rb +76 -0
  99. data/{TUTORIAL.ja.rdoc → text/TUTORIAL.ja.rdoc} +52 -52
  100. data/text/expression.rdoc +284 -0
  101. metadata +11 -7
  102. data/test-unit/sample/ts_examples.rb +0 -7
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -28,8 +28,8 @@ class ArrayTest < Test::Unit::TestCase
28
28
  "id: <#{contain_table.id}>, " +
29
29
  "name: <name>, " +
30
30
  "path: <#{path}>, " +
31
- "domain: <nil>, " +
32
- "range: <nil>, " +
31
+ "domain: (nil), " +
32
+ "range: (nil), " +
33
33
  "flags: <>, " +
34
34
  "size: <3>>",
35
35
  contain_table.inspect)
@@ -41,21 +41,21 @@ class ArrayTest < Test::Unit::TestCase
41
41
  end
42
42
 
43
43
  def test_add
44
- users = Groonga::Array.create(:name => "<users>")
45
- users.define_column("name", "<text>")
44
+ users = Groonga::Array.create(:name => "Users")
45
+ users.define_column("name", "Text")
46
46
  me = users.add(:name => "me")
47
47
  assert_equal("me", me[:name])
48
48
  end
49
49
 
50
50
  def test_define_index_column
51
- users = Groonga::Array.create(:name => "<users>")
52
- users.define_column("name", "<text>")
53
- bookmarks = Groonga::Array.create(:name => "<bookmarks>")
54
- bookmarks.define_column("title", "<text>")
51
+ users = Groonga::Array.create(:name => "Users")
52
+ users.define_column("name", "Text")
53
+ bookmarks = Groonga::Array.create(:name => "Bookmarks")
54
+ bookmarks.define_column("title", "Text")
55
55
  bookmarks.define_column("user", users)
56
56
 
57
57
  index = users.define_index_column("bookmarks", bookmarks,
58
- :source => "<bookmarks>.user")
58
+ :source => "Bookmarks.user")
59
59
  morita = users.add(:name => "morita")
60
60
  gunyara_kun = users.add(:name => "gunyara-kun")
61
61
  groonga = bookmarks.add(:title => "groonga", :user => morita)
@@ -67,16 +67,31 @@ class ArrayTest < Test::Unit::TestCase
67
67
  end
68
68
 
69
69
  def test_create_duplicated_name
70
- Groonga::Array.create(:name => "<users>")
70
+ Groonga::Array.create(:name => "Users")
71
71
  assert_raise(Groonga::InvalidArgument) do
72
- Groonga::Array.create(:name => "<users>")
72
+ Groonga::Array.create(:name => "Users")
73
73
  end
74
74
  end
75
75
 
76
76
  def test_open_same_name
77
- users_created = Groonga::Array.create(:name => "<users>")
78
- users_opened = Groonga::Array.open(:name => "<users>")
77
+ users_created = Groonga::Array.create(:name => "Users")
78
+ users_opened = Groonga::Array.open(:name => "Users")
79
79
  users_opened.add
80
80
  assert_equal(1, users_created.size)
81
81
  end
82
+
83
+ def test_value
84
+ users = Groonga::Array.create(:value_type => "Int32")
85
+ user_id = users.add.id
86
+ users.set_value(user_id, 29)
87
+ assert_equal(29, users.value(user_id))
88
+ end
89
+
90
+ def test_column_value
91
+ users = Groonga::Array.create(:name => "Users")
92
+ name = users.define_column("name", "ShortText")
93
+ morita_id = users.add.id
94
+ users.set_column_value(morita_id, "name", "morita")
95
+ assert_equal("morita", users.column_value(morita_id, "name"))
96
+ end
82
97
  end
@@ -26,31 +26,31 @@ class ColumnTest < Test::Unit::TestCase
26
26
 
27
27
  def setup_users_table
28
28
  @users_path = @tables_dir + "users"
29
- @users = Groonga::Array.create(:name => "users",
29
+ @users = Groonga::Array.create(:name => "Users",
30
30
  :path => @users_path.to_s)
31
31
 
32
32
  @users_name_column_path = @columns_dir + "name"
33
33
  @users_name_column =
34
- @users.define_column("name", "<shorttext>",
34
+ @users.define_column("name", "ShortText",
35
35
  :path => @users_name_column_path.to_s)
36
36
  end
37
37
 
38
38
  def setup_bookmarks_table
39
39
  @bookmarks_path = @tables_dir + "bookmarks"
40
- @bookmarks = Groonga::Array.create(:name => "bookmarks",
40
+ @bookmarks = Groonga::Array.create(:name => "Bookmarks",
41
41
  :path => @bookmarks_path.to_s)
42
42
 
43
43
  @uri_column_path = @columns_dir + "uri"
44
- @bookmarks_uri = @bookmarks.define_column("uri", "<shorttext>",
44
+ @bookmarks_uri = @bookmarks.define_column("uri", "ShortText",
45
45
  :path => @uri_column_path.to_s)
46
46
 
47
47
  @comment_column_path = @columns_dir + "comment"
48
48
  @bookmarks_comment =
49
- @bookmarks.define_column("comment", "<text>",
49
+ @bookmarks.define_column("comment", "Text",
50
50
  :path => @comment_column_path.to_s)
51
51
 
52
52
  @content_column_path = @columns_dir + "content"
53
- @bookmarks_content = @bookmarks.define_column("content", "<longtext>")
53
+ @bookmarks_content = @bookmarks.define_column("content", "LongText")
54
54
 
55
55
  @user_column_path = @columns_dir + "user"
56
56
  @bookmarks_user = @bookmarks.define_column("user", @users)
@@ -117,16 +117,16 @@ class ColumnTest < Test::Unit::TestCase
117
117
  end
118
118
 
119
119
  def test_accessor
120
- posts = Groonga::Hash.create(:name => "<posts>", :key_type => "<shorttext>")
121
- posts.define_column("body", "<text>")
122
- comments = Groonga::Hash.create(:name => "<comments>",
123
- :key_type => "<shorttext>")
124
- content = comments.define_column("content", "<shorttext>")
120
+ posts = Groonga::Hash.create(:name => "Posts", :key_type => "ShortText")
121
+ posts.define_column("body", "Text")
122
+ comments = Groonga::Hash.create(:name => "Comments",
123
+ :key_type => "ShortText")
124
+ content = comments.define_column("content", "ShortText")
125
125
  comments.define_column("post", posts)
126
126
 
127
- index = Groonga::PatriciaTrie.create(:name => "<terms>",
128
- :key_type => "<shorttext>")
129
- index.default_tokenizer = "<token:bigram>"
127
+ index = Groonga::PatriciaTrie.create(:name => "Terms",
128
+ :key_type => "ShortText")
129
+ index.default_tokenizer = "TokenBigram"
130
130
  content_index = index.define_index_column("content_index", comments,
131
131
  :with_position => true)
132
132
  content_index.source = content
@@ -143,7 +143,7 @@ class ColumnTest < Test::Unit::TestCase
143
143
  result = content_index.search("drive")
144
144
  assert_equal([["I'm also like drive", "My Hobby"]],
145
145
  result.records.collect do |record|
146
- [record[".content"], record[".post.:key"]]
146
+ [record[".content"], record[".post._key"]]
147
147
  end)
148
148
  end
149
149
 
@@ -158,71 +158,85 @@ class ColumnTest < Test::Unit::TestCase
158
158
  end
159
159
 
160
160
  def test_array_set_with_key_of_table
161
- users = Groonga::Hash.create(:name => "<users>")
162
- bookmarks = Groonga::Hash.create(:name => "<bookmarks>")
163
- bookmarks.define_column("user", users)
164
-
165
- users.add("morita")
166
- groonga = bookmarks.add("http://groonga.org/", :user => "morita")
167
- assert_equal("morita", groonga[:user].key)
161
+ languages = Groonga::Hash.create(:name => "Languages",
162
+ :key_type => "ShortText")
163
+ sites = Groonga::Hash.create(:name => "Sites")
164
+ sites.define_column("language", languages)
165
+
166
+ languages.add("Ruby")
167
+ taiyaki_ru = sites.add("http://taiyaki.ru/", :language => "Ruby")
168
+ assert_equal("Ruby", taiyaki_ru[:language].key)
168
169
  end
169
170
 
170
171
  def test_local_name
171
- items = Groonga::Array.create(:name => "<items>")
172
- title = items.define_column("title", "<shorttext>")
173
- assert_equal("<items>.title", title.name)
172
+ items = Groonga::Array.create(:name => "Items")
173
+ title = items.define_column("title", "ShortText")
174
+ assert_equal("Items.title", title.name)
174
175
  assert_equal("title", title.local_name)
175
176
  end
176
177
 
177
- def test_select
178
- posts = Groonga::Hash.create(:name => "<posts>", :key_type => "<shorttext>")
179
- body = posts.define_column("body", "<text>")
178
+ def test_select_query
179
+ populate_table_for_select
180
180
 
181
- index = Groonga::PatriciaTrie.create(:name => "<terms>",
182
- :key_type => "<shorttext>",
183
- :key_normalize => true)
184
- index.default_tokenizer = "<token:bigram>"
185
- body_index = index.define_index_column("body_index", posts,
186
- :with_position => true,
187
- :source => body)
181
+ result = @body.select("drive")
182
+ assert_equal(["Drive and Eat"],
183
+ result.records.collect do |record|
184
+ record["body"]
185
+ end)
186
+ assert_equal("#<Groonga::Expression noname(?0:\"\")" +
187
+ "{body GET_VALUE \"drive\" MATCH}>",
188
+ result.expression.inspect)
189
+ end
190
+
191
+ def test_select_query_with_parser
192
+ populate_table_for_select
188
193
 
189
- first_post = posts.add("Hello!", :body => "World")
190
- hobby = posts.add("My Hobby", :body => "Drive and Eat")
191
-
192
- result = body.select("drive")
194
+ result = @body.select("body @ \"drive\"", :syntax => :script)
193
195
  assert_equal(["Drive and Eat"],
194
196
  result.records.collect do |record|
195
197
  record["body"]
196
198
  end)
199
+ assert_equal("#<Groonga::Expression noname(?0:\"\")" +
200
+ "{body GET_VALUE \"drive\" MATCH}>",
201
+ result.expression.inspect)
197
202
  end
198
203
 
199
- def test_select_with_block
200
- posts = Groonga::Hash.create(:name => "<posts>", :key_type => "<shorttext>")
201
- body = posts.define_column("body", "<text>")
204
+ def test_select_expression
205
+ populate_table_for_select
202
206
 
203
- index = Groonga::PatriciaTrie.create(:name => "<terms>",
204
- :key_type => "<shorttext>",
205
- :key_normalize => true)
206
- index.default_tokenizer = "<token:bigram>"
207
- body_index = index.define_index_column("body_index", posts,
208
- :with_position => true,
209
- :source => body)
207
+ expression = Groonga::Expression.new
208
+ variable = expression.define_variable(:domain => @posts)
209
+ expression.append_object(variable)
210
+ expression.parse("body:%drive", :syntax => :query)
211
+ expression.compile
212
+ result = @body.select(expression)
213
+ assert_equal(["Drive and Eat"],
214
+ result.records.collect do |record|
215
+ record["body"]
216
+ end)
217
+ assert_equal("#<Groonga::Expression noname(?0:\"\")" +
218
+ "{?0 body GET_VALUE \"drive\" MATCH}>",
219
+ result.expression.inspect)
220
+ end
210
221
 
211
- first_post = posts.add("Hello!", :body => "World")
212
- hobby = posts.add("My Hobby", :body => "Drive and Eat")
213
-
214
- result = body.select do |column|
222
+ def test_select_with_block
223
+ populate_table_for_select
224
+
225
+ result = @body.select do |column|
215
226
  column =~ "drive"
216
227
  end
217
228
  assert_equal(["Drive and Eat"],
218
229
  result.records.collect do |record|
219
230
  record["body"]
220
231
  end)
232
+ assert_equal("#<Groonga::Expression noname(?0:\"\")" +
233
+ "{?0 body GET_VALUE \"drive\" MATCH}>",
234
+ result.expression.inspect)
221
235
  end
222
236
 
223
237
  def test_set_time
224
- posts = Groonga::Hash.create(:name => "<posts>", :key_type => "<shorttext>")
225
- body = posts.define_column("issued", "<time>")
238
+ posts = Groonga::Hash.create(:name => "Posts", :key_type => "ShortText")
239
+ body = posts.define_column("issued", "Time")
226
240
 
227
241
  post = posts.add("hello", :issued => 123456)
228
242
  assert_equal(Time.at(123456), post[".issued"])
@@ -232,6 +246,28 @@ class ColumnTest < Test::Unit::TestCase
232
246
  assert_in_delta(Time.at(1251380635.1234567).usec, post[".issued"].usec, 10)
233
247
  end
234
248
 
249
+ def test_set_nil_to_time
250
+ posts = Groonga::Hash.create(:name => "Posts", :key_type => "ShortText")
251
+ body = posts.define_column("issued", "Time")
252
+
253
+ post = posts.add("hello", :issued => nil)
254
+ assert_equal(Time.at(0), post["issued"])
255
+ end
256
+
257
+ def test_bool
258
+ posts = Groonga::Hash.create(:name => "Posts", :key_type => "ShortText")
259
+ hidden = posts.define_column("hidden", "Bool")
260
+
261
+ post = posts.add("hello")
262
+ assert_false(post["hidden"])
263
+
264
+ post["hidden"] = true
265
+ assert_true(post["hidden"])
266
+
267
+ post["hidden"] = false
268
+ assert_false(post["hidden"])
269
+ end
270
+
235
271
  private
236
272
  def assert_content_search(expected_records, term)
237
273
  records = @bookmarks_index_content.search(term).records
@@ -243,4 +279,20 @@ class ColumnTest < Test::Unit::TestCase
243
279
  end
244
280
  assert_equal(expected_contents, actual_contents)
245
281
  end
282
+
283
+ def populate_table_for_select
284
+ @posts = Groonga::Hash.create(:name => "Posts", :key_type => "ShortText")
285
+ @body = @posts.define_column("body", "Text")
286
+
287
+ index = Groonga::PatriciaTrie.create(:name => "Terms",
288
+ :key_type => "ShortText",
289
+ :key_normalize => true)
290
+ index.default_tokenizer = "TokenBigram"
291
+ body_index = index.define_index_column("body_index", @posts,
292
+ :with_position => true,
293
+ :source => @body)
294
+
295
+ first_post = @posts.add("Hello!", :body => "World")
296
+ hobby = @posts.add("My Hobby", :body => "Drive and Eat")
297
+ end
246
298
  end
@@ -65,4 +65,9 @@ class ContextTest < Test::Unit::TestCase
65
65
  context = Groonga::Context.default
66
66
  assert_equal("Bool", context[:Bool].name)
67
67
  end
68
+
69
+ def test_shortcut_access
70
+ Groonga::Database.create
71
+ assert_equal("ShortText", Groonga["ShortText"].name)
72
+ end
68
73
  end
@@ -63,43 +63,8 @@ class DatabaseTest < Test::Unit::TestCase
63
63
  def test_each
64
64
  db_path = @tmp_dir + "db"
65
65
  database = Groonga::Database.create(:path => db_path.to_s)
66
- assert_equal(["Bool",
67
- "Float",
68
- "Int16",
69
- "Int32",
70
- "Int64",
71
- "Int8",
72
- "LongText",
73
- "Object",
74
- "ShortText",
75
- "Text",
76
- "Time",
77
- "TokenBigram",
78
- "TokenDelimit",
79
- "TokenMecab",
80
- "TokenTrigram",
81
- "TokenUnigram",
82
- "TokyoGeoPoint",
83
- "UInt16",
84
- "UInt32",
85
- "UInt64",
86
- "UInt8",
87
- "WGS84GeoPoint",
88
- "column_create",
89
- "column_list",
90
- "define_selector",
91
- "expr_missing",
92
- "load",
93
- "now",
94
- "quit",
95
- "rand",
96
- "select",
97
- "shutdown",
98
- "status",
99
- "table_create",
100
- "table_list",
101
- "view_add"],
102
- database.collect {|object| object.name}.sort)
66
+ default_object_names = database.collect {|object| object.name}.sort
67
+ assert_send([default_object_names, :include?, "Bool"])
103
68
  end
104
69
 
105
70
  def test_encoding
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -19,6 +19,9 @@ class ExceptionTest < Test::Unit::TestCase
19
19
  def test_defined
20
20
  assert_not_const_defined(Groonga, :Success)
21
21
 
22
+ assert_const_defined(Groonga, :Error)
23
+ assert_const_defined(Groonga, :ObjectClosed)
24
+
22
25
  assert_const_defined(Groonga, :EndOfData)
23
26
  assert_const_defined(Groonga, :UnknownError)
24
27
  assert_const_defined(Groonga, :OperationNotPermitted)
@@ -81,5 +84,10 @@ class ExceptionTest < Test::Unit::TestCase
81
84
  assert_const_defined(Groonga, :AddressIsInUse)
82
85
  assert_const_defined(Groonga, :ZLibError)
83
86
  assert_const_defined(Groonga, :LZOError)
87
+ assert_const_defined(Groonga, :StackOverFlow)
88
+ assert_const_defined(Groonga, :SyntaxError)
89
+ assert_const_defined(Groonga, :RetryMax)
90
+ assert_const_defined(Groonga, :IncompatibleFileFormat)
91
+ assert_const_defined(Groonga, :UpdateNotAllowed)
84
92
  end
85
93
  end
@@ -21,15 +21,15 @@ class ExpressionBuilderTest < Test::Unit::TestCase
21
21
  setup :setup_data
22
22
 
23
23
  def setup_tables
24
- @users = Groonga::Hash.create(:name => "<users>")
25
- @name = @users.define_column("name", "<shorttext>")
26
- @hp = @users.define_column("hp", "<uint>")
24
+ @users = Groonga::Hash.create(:name => "Users")
25
+ @name = @users.define_column("name", "ShortText")
26
+ @hp = @users.define_column("hp", "UInt32")
27
27
 
28
- @terms = Groonga::PatriciaTrie.create(:name => "<terms>",
28
+ @terms = Groonga::PatriciaTrie.create(:name => "Terms",
29
29
  :default_tokenizer => "TokenBigram")
30
30
  @terms.define_index_column("user-name", @users, :source => @name)
31
31
 
32
- @bookmarks = Groonga::Array.create(:name => "bookmarks")
32
+ @bookmarks = Groonga::Array.create(:name => "Bookmarks")
33
33
  @bookmarks.define_column("user", @users)
34
34
  @bookmarks.define_column("uri", "ShortText")
35
35
  end
@@ -135,4 +135,22 @@ class ExpressionBuilderTest < Test::Unit::TestCase
135
135
  assert_equal(["http://groonga.org/", "http://ruby-lang.org/"],
136
136
  result.collect {|record| record.key["uri"]})
137
137
  end
138
+
139
+ def test_nested_column
140
+ result = @bookmarks.select do |record|
141
+ record[".user.name"] == @morita["name"]
142
+ end
143
+ assert_equal(["http://groonga.org/", "http://ruby-lang.org/"],
144
+ result.collect {|record| record.key["uri"]})
145
+ end
146
+
147
+ def test_nil_match
148
+ @users.select do |record|
149
+ exception = ArgumentError.new("match word should not be nil: Users.name")
150
+ assert_raise(exception) do
151
+ record["name"] =~ nil
152
+ end
153
+ record["name"] == "dummy"
154
+ end
155
+ end
138
156
  end