groonga 0.0.7 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/NEWS.ja.rdoc +56 -0
- data/NEWS.rdoc +58 -0
- data/Rakefile +2 -3
- data/benchmark/read-write-many-small-items.rb +16 -32
- data/benchmark/write-many-small-items.rb +14 -28
- data/example/bookmark.rb +19 -17
- data/example/index-html.rb +11 -1
- data/example/search/config.ru +14 -9
- data/ext/rb-grn-array.c +6 -6
- data/ext/rb-grn-column.c +348 -18
- data/ext/rb-grn-context.c +8 -4
- data/ext/rb-grn-database.c +6 -7
- data/ext/rb-grn-exception.c +101 -5
- data/ext/rb-grn-expression.c +206 -23
- data/ext/rb-grn-fix-size-column.c +6 -39
- data/ext/rb-grn-hash.c +24 -24
- data/ext/rb-grn-index-column.c +74 -19
- data/ext/rb-grn-logger.c +48 -0
- data/ext/rb-grn-object.c +281 -67
- data/ext/rb-grn-operation.c +1 -1
- data/ext/rb-grn-patricia-trie-cursor.c +10 -1
- data/ext/rb-grn-patricia-trie.c +268 -7
- data/ext/rb-grn-query.c +52 -1
- data/ext/rb-grn-record.c +8 -2
- data/ext/rb-grn-snippet.c +63 -1
- data/ext/rb-grn-table-cursor-key-support.c +15 -1
- data/ext/rb-grn-table-cursor.c +57 -0
- data/ext/rb-grn-table-key-support.c +382 -46
- data/ext/rb-grn-table.c +729 -192
- data/ext/rb-grn-type.c +63 -12
- data/ext/rb-grn-utils.c +156 -158
- data/ext/rb-grn-variable.c +18 -0
- data/ext/rb-grn.h +85 -21
- data/ext/rb-groonga.c +13 -3
- data/extconf.rb +19 -4
- data/html/developer.html +1 -1
- data/html/header.html.erb +1 -1
- data/html/index.html +4 -4
- data/lib/groonga.rb +10 -0
- data/lib/groonga/expression-builder.rb +81 -42
- data/lib/groonga/patricia-trie.rb +13 -0
- data/lib/groonga/record.rb +158 -13
- data/lib/groonga/schema.rb +339 -33
- data/pkg-config.rb +6 -1
- data/test-unit/lib/test/unit.rb +23 -42
- data/test-unit/lib/test/unit/assertionfailederror.rb +11 -0
- data/test-unit/lib/test/unit/assertions.rb +87 -9
- data/test-unit/lib/test/unit/autorunner.rb +20 -11
- data/test-unit/lib/test/unit/collector.rb +1 -8
- data/test-unit/lib/test/unit/collector/load.rb +2 -3
- data/test-unit/lib/test/unit/color-scheme.rb +13 -1
- data/test-unit/lib/test/unit/diff.rb +223 -37
- data/test-unit/lib/test/unit/error.rb +4 -0
- data/test-unit/lib/test/unit/failure.rb +31 -5
- data/test-unit/lib/test/unit/notification.rb +8 -4
- data/test-unit/lib/test/unit/omission.rb +51 -3
- data/test-unit/lib/test/unit/pending.rb +4 -0
- data/test-unit/lib/test/unit/testcase.rb +55 -4
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +190 -4
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +14 -0
- data/test-unit/lib/test/unit/ui/testrunner.rb +8 -0
- data/test-unit/lib/test/unit/version.rb +1 -1
- data/test-unit/sample/{tc_adder.rb → test_adder.rb} +3 -1
- data/test-unit/sample/{tc_subtracter.rb → test_subtracter.rb} +3 -1
- data/test-unit/sample/test_user.rb +1 -0
- data/test-unit/test/collector/test-descendant.rb +2 -4
- data/test-unit/test/collector/test_objectspace.rb +7 -5
- data/test-unit/test/run-test.rb +2 -0
- data/test-unit/test/test-color-scheme.rb +7 -0
- data/test-unit/test/test-diff.rb +48 -7
- data/test-unit/test/test-omission.rb +1 -1
- data/test-unit/test/test-testcase.rb +47 -0
- data/test-unit/test/test_assertions.rb +79 -10
- data/test/groonga-test-utils.rb +6 -1
- data/test/test-array.rb +29 -14
- data/test/test-column.rb +107 -55
- data/test/test-context.rb +5 -0
- data/test/test-database.rb +2 -37
- data/test/test-exception.rb +9 -1
- data/test/test-expression-builder.rb +23 -5
- data/test/test-expression.rb +44 -8
- data/test/test-fix-size-column.rb +16 -5
- data/test/test-gqtp.rb +70 -0
- data/test/test-hash.rb +142 -43
- data/test/test-index-column.rb +9 -9
- data/test/test-patricia-trie.rb +79 -20
- data/test/test-procedure.rb +4 -2
- data/test/test-record.rb +32 -20
- data/test/test-remote.rb +3 -2
- data/test/test-schema.rb +226 -92
- data/test/test-table-cursor.rb +103 -1
- data/test/test-table-offset-and-limit.rb +102 -0
- data/test/test-table-select-normalize.rb +4 -4
- data/test/test-table-select.rb +52 -8
- data/test/test-table.rb +235 -116
- data/test/test-type.rb +2 -2
- data/test/test-variable-size-column.rb +21 -5
- data/test/test-vector-column.rb +76 -0
- data/{TUTORIAL.ja.rdoc → text/TUTORIAL.ja.rdoc} +52 -52
- data/text/expression.rdoc +284 -0
- metadata +11 -7
- data/test-unit/sample/ts_examples.rb +0 -7
data/test/test-index-column.rb
CHANGED
|
@@ -23,11 +23,11 @@ class IndexColumnTest < Test::Unit::TestCase
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def test_array_set_with_record
|
|
26
|
-
articles = Groonga::Array.create(:name => "
|
|
27
|
-
articles.define_column("content", "
|
|
26
|
+
articles = Groonga::Array.create(:name => "Articles")
|
|
27
|
+
articles.define_column("content", "Text")
|
|
28
28
|
|
|
29
|
-
terms = Groonga::Hash.create(:name => "
|
|
30
|
-
:default_tokenizer => "
|
|
29
|
+
terms = Groonga::Hash.create(:name => "Terms",
|
|
30
|
+
:default_tokenizer => "TokenBigram")
|
|
31
31
|
content_index = terms.define_index_column("content", articles,
|
|
32
32
|
:with_section => true)
|
|
33
33
|
|
|
@@ -56,13 +56,13 @@ class IndexColumnTest < Test::Unit::TestCase
|
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def test_shorter_query_than_ngram
|
|
59
|
-
articles = Groonga::Array.create(:name => "
|
|
60
|
-
articles.define_column("content", "
|
|
59
|
+
articles = Groonga::Array.create(:name => "Articles")
|
|
60
|
+
articles.define_column("content", "Text")
|
|
61
61
|
|
|
62
|
-
terms = Groonga::PatriciaTrie.create(:name => "
|
|
63
|
-
:default_tokenizer => "
|
|
62
|
+
terms = Groonga::PatriciaTrie.create(:name => "Terms",
|
|
63
|
+
:default_tokenizer => "TokenBigram")
|
|
64
64
|
content_index = terms.define_index_column("content", articles,
|
|
65
|
-
:source => "
|
|
65
|
+
:source => "Articles.content")
|
|
66
66
|
articles.add(:content => 'l')
|
|
67
67
|
articles.add(:content => 'll')
|
|
68
68
|
articles.add(:content => 'hello')
|
data/test/test-patricia-trie.rb
CHANGED
|
@@ -27,19 +27,17 @@ class PatriciaTrieTest < Test::Unit::TestCase
|
|
|
27
27
|
def test_tokenizer
|
|
28
28
|
trie = Groonga::PatriciaTrie.create
|
|
29
29
|
assert_nil(trie.default_tokenizer)
|
|
30
|
-
trie.default_tokenizer = "
|
|
31
|
-
assert_equal(Groonga::Context.default["
|
|
30
|
+
trie.default_tokenizer = "TokenTrigram"
|
|
31
|
+
assert_equal(Groonga::Context.default["TokenTrigram"],
|
|
32
32
|
trie.default_tokenizer)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def test_search
|
|
36
|
-
|
|
36
|
+
users = Groonga::Array.create(:name => "Users")
|
|
37
|
+
user_name = users.define_column("name", "ShortText")
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
bookmarks = Groonga::PatriciaTrie.create(:name => "<bookmarks>",
|
|
42
|
-
:key_type => "<shorttext>")
|
|
39
|
+
bookmarks = Groonga::PatriciaTrie.create(:name => "Bookmarks",
|
|
40
|
+
:key_type => "ShortText")
|
|
43
41
|
bookmark_user_id = bookmarks.define_column("user_id", users)
|
|
44
42
|
|
|
45
43
|
daijiro = users.add
|
|
@@ -56,35 +54,35 @@ class PatriciaTrieTest < Test::Unit::TestCase
|
|
|
56
54
|
end
|
|
57
55
|
|
|
58
56
|
def test_add
|
|
59
|
-
users = Groonga::PatriciaTrie.create(:name => "
|
|
57
|
+
users = Groonga::PatriciaTrie.create(:name => "Users")
|
|
60
58
|
users.define_column("address", "<text>")
|
|
61
59
|
me = users.add("me", :address => "me@example.com")
|
|
62
60
|
assert_equal("me@example.com", me[:address])
|
|
63
61
|
end
|
|
64
62
|
|
|
65
63
|
def test_default_tokenizer_on_create
|
|
66
|
-
terms = Groonga::PatriciaTrie.create(:name => "
|
|
67
|
-
:default_tokenizer => "
|
|
64
|
+
terms = Groonga::PatriciaTrie.create(:name => "Terms",
|
|
65
|
+
:default_tokenizer => "TokenUnigram")
|
|
68
66
|
assert_equal(context[Groonga::Type::UNIGRAM],
|
|
69
67
|
terms.default_tokenizer)
|
|
70
68
|
end
|
|
71
69
|
|
|
72
70
|
def test_duplicated_name
|
|
73
|
-
Groonga::PatriciaTrie.create(:name => "
|
|
71
|
+
Groonga::PatriciaTrie.create(:name => "Users")
|
|
74
72
|
assert_raise(Groonga::InvalidArgument) do
|
|
75
|
-
Groonga::PatriciaTrie.create(:name => "
|
|
73
|
+
Groonga::PatriciaTrie.create(:name => "Users")
|
|
76
74
|
end
|
|
77
75
|
end
|
|
78
76
|
|
|
79
77
|
def test_open_same_name
|
|
80
|
-
users_created = Groonga::PatriciaTrie.create(:name => "
|
|
81
|
-
users_opened = Groonga::PatriciaTrie.open(:name => "
|
|
78
|
+
users_created = Groonga::PatriciaTrie.create(:name => "Users")
|
|
79
|
+
users_opened = Groonga::PatriciaTrie.open(:name => "Users")
|
|
82
80
|
users_opened.add("morita")
|
|
83
81
|
assert_equal(1, users_created.size)
|
|
84
82
|
end
|
|
85
83
|
|
|
86
84
|
def test_has_key?
|
|
87
|
-
users = Groonga::PatriciaTrie.create(:name => "
|
|
85
|
+
users = Groonga::PatriciaTrie.create(:name => "Users")
|
|
88
86
|
assert_false(users.has_key?("morita"))
|
|
89
87
|
users.add("morita")
|
|
90
88
|
assert_true(users.has_key?("morita"))
|
|
@@ -95,28 +93,31 @@ class PatriciaTrieTest < Test::Unit::TestCase
|
|
|
95
93
|
words = Groonga::PatriciaTrie.create(:key_type => "ShortText",
|
|
96
94
|
:key_normalize => true)
|
|
97
95
|
words.add("リンク")
|
|
96
|
+
arupaka = words.add("アルパカ")
|
|
97
|
+
words.add("アルパカ(生物)")
|
|
98
98
|
adventure_of_link = words.add('リンクの冒険')
|
|
99
99
|
words.add('冒険')
|
|
100
100
|
gaxtu = words.add('ガッ')
|
|
101
101
|
muteki = words.add('MUTEKI')
|
|
102
102
|
assert_equal([[muteki, "muTEki", 0, 6],
|
|
103
103
|
[adventure_of_link, "リンクの冒険", 7, 18],
|
|
104
|
-
[
|
|
105
|
-
|
|
104
|
+
[arupaka, "アルパカ", 42, 12],
|
|
105
|
+
[gaxtu, "ガッ", 55, 6]],
|
|
106
|
+
words.scan('muTEki リンクの冒険 ミリバール アルパカ ガッ'))
|
|
106
107
|
end
|
|
107
108
|
|
|
108
109
|
def test_tag_keys
|
|
109
110
|
Groonga::Context.default_options = {:encoding => "utf-8"}
|
|
110
111
|
words = Groonga::PatriciaTrie.create(:key_type => "ShortText",
|
|
111
112
|
:key_normalize => true)
|
|
112
|
-
words.add(
|
|
113
|
+
words.add('リンク')
|
|
113
114
|
words.add('リンクの冒険')
|
|
114
115
|
words.add('冒険')
|
|
115
116
|
words.add('㍊')
|
|
116
117
|
words.add('ガッ')
|
|
117
118
|
words.add('MUTEKI')
|
|
118
119
|
|
|
119
|
-
text = 'muTEki リンクの冒険 マッチしない ミリバール ガッ'
|
|
120
|
+
text = 'muTEki リンクの冒険 マッチしない ミリバール ガッ おわり'
|
|
120
121
|
actual = words.tag_keys(text) do |record, word|
|
|
121
122
|
"<#{word}(#{record.key})>"
|
|
122
123
|
end
|
|
@@ -124,7 +125,65 @@ class PatriciaTrieTest < Test::Unit::TestCase
|
|
|
124
125
|
"<リンクの冒険(リンクの冒険)> " +
|
|
125
126
|
"マッチしない " +
|
|
126
127
|
"<ミリバール(ミリバール)> " +
|
|
128
|
+
"<ガッ(ガッ)> " +
|
|
129
|
+
"おわり",
|
|
130
|
+
actual)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def test_tag_keys_with_last_match
|
|
134
|
+
Groonga::Context.default_options = {:encoding => "utf-8"}
|
|
135
|
+
words = Groonga::PatriciaTrie.create(:key_type => "ShortText",
|
|
136
|
+
:key_normalize => true)
|
|
137
|
+
words.add('ガッ')
|
|
138
|
+
words.add('MUTEKI')
|
|
139
|
+
|
|
140
|
+
text = 'muTEki マッチしない ガッ'
|
|
141
|
+
actual = words.tag_keys(text) do |record, word|
|
|
142
|
+
"<#{word}(#{record.key})>"
|
|
143
|
+
end
|
|
144
|
+
assert_equal("<muTEki(muteki)> " +
|
|
145
|
+
"マッチしない " +
|
|
127
146
|
"<ガッ(ガッ)>",
|
|
128
147
|
actual)
|
|
129
148
|
end
|
|
149
|
+
|
|
150
|
+
def test_tag_keys_with_no_match
|
|
151
|
+
Groonga::Context.default_options = {:encoding => "utf-8"}
|
|
152
|
+
words = Groonga::PatriciaTrie.create(:key_type => "ShortText",
|
|
153
|
+
:key_normalize => true)
|
|
154
|
+
|
|
155
|
+
words.add('無敵')
|
|
156
|
+
words.add('BOUKEN')
|
|
157
|
+
|
|
158
|
+
text = 'muTEki リンクの冒険'
|
|
159
|
+
actual = words.tag_keys(text) do |record, word|
|
|
160
|
+
"<#{word}(#{record.key})>"
|
|
161
|
+
end
|
|
162
|
+
assert_equal(text, actual)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def test_prefix_search
|
|
166
|
+
paths = Groonga::PatriciaTrie.create(:name => "Paths",
|
|
167
|
+
:key_type => 'ShortText')
|
|
168
|
+
root_path = paths.add('/')
|
|
169
|
+
tmp_path = paths.add('/tmp')
|
|
170
|
+
usr_bin_path = paths.add('/usr/bin')
|
|
171
|
+
usr_local_bin_path = paths.add('/usr/local/bin')
|
|
172
|
+
|
|
173
|
+
records = paths.prefix_search('/')
|
|
174
|
+
assert_equal(["/usr/local/bin", "/usr/bin", "/tmp", "/"],
|
|
175
|
+
records.records.collect {|record| record["._key"]})
|
|
176
|
+
|
|
177
|
+
records = paths.prefix_search('/usr')
|
|
178
|
+
assert_equal(["/usr/local/bin", "/usr/bin"],
|
|
179
|
+
records.records.collect {|record| record["._key"]})
|
|
180
|
+
|
|
181
|
+
records = paths.prefix_search('/usr/local')
|
|
182
|
+
assert_equal(["/usr/local/bin"],
|
|
183
|
+
records.records.collect {|record| record["._key"]})
|
|
184
|
+
|
|
185
|
+
records = paths.prefix_search('nonexistent')
|
|
186
|
+
assert_equal([],
|
|
187
|
+
records.records.collect {|record| record["._key"]})
|
|
188
|
+
end
|
|
130
189
|
end
|
data/test/test-procedure.rb
CHANGED
|
@@ -23,12 +23,14 @@ class ProcedureTest < Test::Unit::TestCase
|
|
|
23
23
|
assert_equal_procedure("TokenUnigram", Groonga::Procedure::UNIGRAM)
|
|
24
24
|
assert_equal_procedure("TokenBigram", Groonga::Procedure::BIGRAM)
|
|
25
25
|
assert_equal_procedure("TokenTrigram", Groonga::Procedure::TRIGRAM)
|
|
26
|
-
assert_equal_procedure("TokenMecab", Groonga::Procedure::MECAB
|
|
26
|
+
assert_equal_procedure("TokenMecab", Groonga::Procedure::MECAB,
|
|
27
|
+
:accept_nil => true)
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
private
|
|
30
|
-
def assert_equal_procedure(expected_name, id)
|
|
31
|
+
def assert_equal_procedure(expected_name, id, options={})
|
|
31
32
|
procedure = Groonga::Context.default[id]
|
|
33
|
+
expected_name = nil if procedure.nil? and options[:accept_nil]
|
|
32
34
|
assert_equal(expected_name,
|
|
33
35
|
procedure ? procedure.name : procedure)
|
|
34
36
|
end
|
data/test/test-record.rb
CHANGED
|
@@ -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
|
|
@@ -27,23 +27,23 @@ class RecordTest < Test::Unit::TestCase
|
|
|
27
27
|
|
|
28
28
|
def setup_addresses_table
|
|
29
29
|
@addresses_path = @tables_dir + "addresses"
|
|
30
|
-
@addresses = Groonga::Array.create(:name => "
|
|
30
|
+
@addresses = Groonga::Array.create(:name => "Addresses",
|
|
31
31
|
:path => @addresses_path.to_s)
|
|
32
32
|
|
|
33
33
|
@addresses_mail_column_path = @columns_dir + "mail"
|
|
34
34
|
@addresses_mail_column =
|
|
35
|
-
@addresses.define_column("mail", "
|
|
35
|
+
@addresses.define_column("mail", "ShortText",
|
|
36
36
|
:path => @addresses_mail_column_path.to_s)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def setup_users_table
|
|
40
40
|
@users_path = @tables_dir + "users"
|
|
41
|
-
@users = Groonga::Array.create(:name => "
|
|
41
|
+
@users = Groonga::Array.create(:name => "Users",
|
|
42
42
|
:path => @users_path.to_s)
|
|
43
43
|
|
|
44
44
|
@users_name_column_path = @columns_dir + "name"
|
|
45
45
|
@users_name_column =
|
|
46
|
-
@users.define_column("name", "
|
|
46
|
+
@users.define_column("name", "ShortText",
|
|
47
47
|
:path => @users_name_column_path.to_s)
|
|
48
48
|
|
|
49
49
|
@users_addresses_column_path = @columns_dir + "addresses"
|
|
@@ -55,26 +55,25 @@ class RecordTest < Test::Unit::TestCase
|
|
|
55
55
|
|
|
56
56
|
def setup_bookmarks_table
|
|
57
57
|
@bookmarks_path = @tables_dir + "bookmarks"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
:value_type => value_type,
|
|
58
|
+
@bookmarks = Groonga::Array.create(:name => "Bookmarks",
|
|
59
|
+
:value_type => "Int32",
|
|
61
60
|
:path => @bookmarks_path.to_s)
|
|
62
61
|
|
|
63
62
|
@uri_column_path = @columns_dir + "uri"
|
|
64
|
-
@bookmarks_uri = @bookmarks.define_column("uri", "
|
|
63
|
+
@bookmarks_uri = @bookmarks.define_column("uri", "ShortText",
|
|
65
64
|
:path => @uri_column_path.to_s)
|
|
66
65
|
|
|
67
66
|
@rate_column_path = @columns_dir + "rate"
|
|
68
|
-
@bookmarks_rate = @bookmarks.define_column("rate", "
|
|
67
|
+
@bookmarks_rate = @bookmarks.define_column("rate", "Int32",
|
|
69
68
|
:path => @rate_column_path.to_s)
|
|
70
69
|
|
|
71
70
|
@comment_column_path = @columns_dir + "comment"
|
|
72
71
|
@bookmarks_comment =
|
|
73
|
-
@bookmarks.define_column("comment", "
|
|
72
|
+
@bookmarks.define_column("comment", "Text",
|
|
74
73
|
:path => @comment_column_path.to_s)
|
|
75
74
|
|
|
76
75
|
@content_column_path = @columns_dir + "content"
|
|
77
|
-
@bookmarks_content = @bookmarks.define_column("content", "
|
|
76
|
+
@bookmarks_content = @bookmarks.define_column("content", "LongText")
|
|
78
77
|
|
|
79
78
|
@user_column_path = @columns_dir + "user"
|
|
80
79
|
@bookmarks_user = @bookmarks.define_column("user", @users)
|
|
@@ -83,7 +82,7 @@ class RecordTest < Test::Unit::TestCase
|
|
|
83
82
|
def setup_indexes
|
|
84
83
|
@bookmarks_index_path = @tables_dir + "bookmarks-index"
|
|
85
84
|
@bookmarks_index =
|
|
86
|
-
Groonga::PatriciaTrie.create(:name => "
|
|
85
|
+
Groonga::PatriciaTrie.create(:name => "BookmarksIndex",
|
|
87
86
|
:path => @bookmarks_index_path.to_s)
|
|
88
87
|
@bookmarks_index.default_tokenizer = "TokenBigram"
|
|
89
88
|
|
|
@@ -122,14 +121,14 @@ class RecordTest < Test::Unit::TestCase
|
|
|
122
121
|
|
|
123
122
|
def test_get_nonexistent_column
|
|
124
123
|
groonga = @bookmarks.add
|
|
125
|
-
assert_raise(Groonga::
|
|
124
|
+
assert_raise(Groonga::NoSuchColumn) do
|
|
126
125
|
groonga["nonexistent"]
|
|
127
126
|
end
|
|
128
127
|
end
|
|
129
128
|
|
|
130
129
|
def test_set_nonexistent_column
|
|
131
130
|
groonga = @bookmarks.add
|
|
132
|
-
assert_raise(Groonga::
|
|
131
|
+
assert_raise(Groonga::NoSuchColumn) do
|
|
133
132
|
groonga["nonexistent"] = "value"
|
|
134
133
|
end
|
|
135
134
|
end
|
|
@@ -160,17 +159,17 @@ class RecordTest < Test::Unit::TestCase
|
|
|
160
159
|
end
|
|
161
160
|
|
|
162
161
|
def test_key
|
|
163
|
-
documents = Groonga::PatriciaTrie.create(:name => "
|
|
164
|
-
:key_type => "
|
|
162
|
+
documents = Groonga::PatriciaTrie.create(:name => "Documents",
|
|
163
|
+
:key_type => "ShortText")
|
|
165
164
|
reference = documents.add("reference")
|
|
166
165
|
assert_equal("reference", reference.key)
|
|
167
166
|
end
|
|
168
167
|
|
|
169
168
|
def test_value
|
|
170
169
|
bookmark = @bookmarks.add
|
|
171
|
-
assert_equal(
|
|
172
|
-
bookmark.value =
|
|
173
|
-
assert_equal(
|
|
170
|
+
assert_equal(0, bookmark.value)
|
|
171
|
+
bookmark.value = 100
|
|
172
|
+
assert_equal(100, bookmark.value)
|
|
174
173
|
end
|
|
175
174
|
|
|
176
175
|
def test_reference_column?
|
|
@@ -253,4 +252,17 @@ class RecordTest < Test::Unit::TestCase
|
|
|
253
252
|
groonga.clear_lock
|
|
254
253
|
assert_not_predicate(groonga, :locked?)
|
|
255
254
|
end
|
|
255
|
+
|
|
256
|
+
def test_attributes
|
|
257
|
+
values = {
|
|
258
|
+
"uri" => "http://groonga.org/",
|
|
259
|
+
"rate" => 5,
|
|
260
|
+
"comment" => "Grate!"
|
|
261
|
+
}
|
|
262
|
+
groonga = @bookmarks.add(values)
|
|
263
|
+
assert_equal(values.merge("id" => groonga.id,
|
|
264
|
+
"content" => nil,
|
|
265
|
+
"user" => nil),
|
|
266
|
+
groonga.attributes)
|
|
267
|
+
end
|
|
256
268
|
end
|
data/test/test-remote.rb
CHANGED
|
@@ -46,7 +46,8 @@ class RemoteTest < Test::Unit::TestCase
|
|
|
46
46
|
assert_equal(0, _context.send("status"))
|
|
47
47
|
id, result = _context.receive
|
|
48
48
|
assert_equal(0, id)
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
return_code, values = JSON.load(result)
|
|
50
|
+
assert_equal([[0], ["alloc_count", "starttime", "uptime"]],
|
|
51
|
+
[return_code, values.keys.sort])
|
|
51
52
|
end
|
|
52
53
|
end
|
data/test/test-schema.rb
CHANGED
|
@@ -19,54 +19,57 @@ class SchemaTest < Test::Unit::TestCase
|
|
|
19
19
|
setup :setup_database
|
|
20
20
|
|
|
21
21
|
def test_create_table
|
|
22
|
-
assert_nil(context["
|
|
23
|
-
Groonga::Schema.create_table("
|
|
22
|
+
assert_nil(context["Posts"])
|
|
23
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
24
24
|
end
|
|
25
|
-
assert_not_nil(context["
|
|
25
|
+
assert_not_nil(context["Posts"])
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def test_create_table_force
|
|
29
|
-
Groonga::Schema.create_table("
|
|
29
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
30
|
+
table.string("name")
|
|
30
31
|
end
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
assert_not_nil(context["Posts.name"])
|
|
33
|
+
|
|
34
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
34
35
|
end
|
|
35
|
-
|
|
36
|
+
assert_not_nil(context["Posts.name"])
|
|
37
|
+
|
|
38
|
+
Groonga::Schema.create_table("Posts", :force => true) do |table|
|
|
36
39
|
end
|
|
40
|
+
assert_nil(context["Posts.name"])
|
|
37
41
|
end
|
|
38
42
|
|
|
39
43
|
def test_remove_table
|
|
40
|
-
Groonga::Array.create(:name => "
|
|
41
|
-
assert_not_nil(context["
|
|
42
|
-
Groonga::Schema.remove_table("
|
|
43
|
-
assert_nil(context["
|
|
44
|
+
Groonga::Array.create(:name => "Posts")
|
|
45
|
+
assert_not_nil(context["Posts"])
|
|
46
|
+
Groonga::Schema.remove_table("Posts")
|
|
47
|
+
assert_nil(context["Posts"])
|
|
44
48
|
end
|
|
45
49
|
|
|
46
50
|
def test_define_hash
|
|
47
|
-
Groonga::Schema.create_table("
|
|
51
|
+
Groonga::Schema.create_table("Posts", :type => :hash) do |table|
|
|
48
52
|
end
|
|
49
|
-
assert_kind_of(Groonga::Hash, context["
|
|
53
|
+
assert_kind_of(Groonga::Hash, context["Posts"])
|
|
50
54
|
end
|
|
51
55
|
|
|
52
56
|
def test_define_hash_with_full_option
|
|
53
57
|
path = @tmp_dir + "hash.groonga"
|
|
54
|
-
tokenizer = context["
|
|
55
|
-
|
|
56
|
-
Groonga::Schema.create_table("<posts>",
|
|
58
|
+
tokenizer = context["TokenTrigram"]
|
|
59
|
+
Groonga::Schema.create_table("Posts",
|
|
57
60
|
:type => :hash,
|
|
58
61
|
:key_type => "integer",
|
|
59
62
|
:path => path.to_s,
|
|
60
|
-
:value_type =>
|
|
63
|
+
:value_type => "UInt32",
|
|
61
64
|
:default_tokenizer => tokenizer) do |table|
|
|
62
65
|
end
|
|
63
|
-
table = context["
|
|
66
|
+
table = context["Posts"]
|
|
64
67
|
assert_equal("#<Groonga::Hash " +
|
|
65
68
|
"id: <#{table.id}>, " +
|
|
66
|
-
"name:
|
|
69
|
+
"name: <Posts>, " +
|
|
67
70
|
"path: <#{path}>, " +
|
|
68
|
-
"domain:
|
|
69
|
-
"range:
|
|
71
|
+
"domain: <Int32>, " +
|
|
72
|
+
"range: <UInt32>, " +
|
|
70
73
|
"flags: <>, " +
|
|
71
74
|
"encoding: <#{Groonga::Encoding.default.inspect}>, " +
|
|
72
75
|
"size: <0>>",
|
|
@@ -75,167 +78,278 @@ class SchemaTest < Test::Unit::TestCase
|
|
|
75
78
|
end
|
|
76
79
|
|
|
77
80
|
def test_define_patricia_trie
|
|
78
|
-
Groonga::Schema.create_table("
|
|
81
|
+
Groonga::Schema.create_table("Posts", :type => :patricia_trie) do |table|
|
|
79
82
|
end
|
|
80
|
-
assert_kind_of(Groonga::PatriciaTrie, context["
|
|
83
|
+
assert_kind_of(Groonga::PatriciaTrie, context["Posts"])
|
|
81
84
|
end
|
|
82
85
|
|
|
83
86
|
def test_define_patricia_trie_with_full_option
|
|
84
87
|
path = @tmp_dir + "patricia-trie.groonga"
|
|
85
|
-
|
|
86
|
-
Groonga::Schema.create_table("<posts>",
|
|
88
|
+
Groonga::Schema.create_table("Posts",
|
|
87
89
|
:type => :patricia_trie,
|
|
88
90
|
:key_type => "integer",
|
|
89
91
|
:path => path.to_s,
|
|
90
|
-
:value_type =>
|
|
91
|
-
:default_tokenizer => "
|
|
92
|
+
:value_type => "Float",
|
|
93
|
+
:default_tokenizer => "TokenBigram",
|
|
92
94
|
:key_normalize => true,
|
|
93
95
|
:key_with_sis => true) do |table|
|
|
94
96
|
end
|
|
95
|
-
table = context["
|
|
97
|
+
table = context["Posts"]
|
|
96
98
|
assert_equal("#<Groonga::PatriciaTrie " +
|
|
97
99
|
"id: <#{table.id}>, " +
|
|
98
|
-
"name:
|
|
100
|
+
"name: <Posts>, " +
|
|
99
101
|
"path: <#{path}>, " +
|
|
100
|
-
"domain:
|
|
101
|
-
"range:
|
|
102
|
+
"domain: <Int32>, " +
|
|
103
|
+
"range: <Float>, " +
|
|
102
104
|
"flags: <KEY_WITH_SIS|KEY_NORMALIZE|WITH_SECTION>, " +
|
|
103
105
|
"encoding: <#{Groonga::Encoding.default.inspect}>, " +
|
|
104
106
|
"size: <0>>",
|
|
105
107
|
table.inspect)
|
|
106
|
-
assert_equal(context["
|
|
108
|
+
assert_equal(context["TokenBigram"], table.default_tokenizer)
|
|
107
109
|
end
|
|
108
110
|
|
|
109
111
|
def test_define_array
|
|
110
|
-
Groonga::Schema.create_table("
|
|
112
|
+
Groonga::Schema.create_table("Posts", :type => :array) do |table|
|
|
111
113
|
end
|
|
112
|
-
assert_kind_of(Groonga::Array, context["
|
|
114
|
+
assert_kind_of(Groonga::Array, context["Posts"])
|
|
113
115
|
end
|
|
114
116
|
|
|
115
117
|
def test_define_array_with_full_option
|
|
116
118
|
path = @tmp_dir + "array.groonga"
|
|
117
|
-
|
|
118
|
-
Groonga::Schema.create_table("<posts>",
|
|
119
|
+
Groonga::Schema.create_table("Posts",
|
|
119
120
|
:type => :array,
|
|
120
121
|
:path => path.to_s,
|
|
121
|
-
:value_type =>
|
|
122
|
+
:value_type => "Int32") do |table|
|
|
122
123
|
end
|
|
123
|
-
table = context["
|
|
124
|
+
table = context["Posts"]
|
|
124
125
|
assert_equal("#<Groonga::Array " +
|
|
125
126
|
"id: <#{table.id}>, " +
|
|
126
|
-
"name:
|
|
127
|
+
"name: <Posts>, " +
|
|
127
128
|
"path: <#{path}>, " +
|
|
128
|
-
"domain:
|
|
129
|
-
"range:
|
|
129
|
+
"domain: <Int32>, " +
|
|
130
|
+
"range: <Int32>, " +
|
|
130
131
|
"flags: <>, " +
|
|
131
132
|
"size: <0>>",
|
|
132
133
|
table.inspect)
|
|
133
134
|
end
|
|
134
135
|
|
|
136
|
+
def test_column_with_full_option
|
|
137
|
+
path = @tmp_dir + "column.groonga"
|
|
138
|
+
type = Groonga::Type.new("Niku", :size => 29)
|
|
139
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
140
|
+
table.column("rate",
|
|
141
|
+
type,
|
|
142
|
+
:path => path.to_s,
|
|
143
|
+
:persistent => true,
|
|
144
|
+
:type => :vector,
|
|
145
|
+
:compress => :lzo)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
column_name = "Posts.rate"
|
|
149
|
+
column = context[column_name]
|
|
150
|
+
assert_equal("#<Groonga::VariableSizeColumn " +
|
|
151
|
+
"id: <#{column.id}>, " +
|
|
152
|
+
"name: <#{column_name}>, " +
|
|
153
|
+
"path: <#{path}>, " +
|
|
154
|
+
"domain: <Posts>, " +
|
|
155
|
+
"range: <Niku>, " +
|
|
156
|
+
"flags: <COMPRESS_LZO>>",
|
|
157
|
+
column.inspect)
|
|
158
|
+
end
|
|
159
|
+
|
|
135
160
|
def test_integer32_column
|
|
136
|
-
assert_nil(context["
|
|
137
|
-
Groonga::Schema.create_table("
|
|
161
|
+
assert_nil(context["Posts.rate"])
|
|
162
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
138
163
|
table.integer32 :rate
|
|
139
164
|
end
|
|
140
|
-
assert_equal(context["
|
|
165
|
+
assert_equal(context["Int32"], context["Posts.rate"].range)
|
|
141
166
|
end
|
|
142
167
|
|
|
143
168
|
def test_integer64_column
|
|
144
|
-
assert_nil(context["
|
|
145
|
-
Groonga::Schema.create_table("
|
|
169
|
+
assert_nil(context["Posts.rate"])
|
|
170
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
146
171
|
table.integer64 :rate
|
|
147
172
|
end
|
|
148
|
-
assert_equal(context["
|
|
173
|
+
assert_equal(context["Int64"], context["Posts.rate"].range)
|
|
149
174
|
end
|
|
150
175
|
|
|
151
176
|
def test_unsigned_integer32_column
|
|
152
|
-
assert_nil(context["
|
|
153
|
-
Groonga::Schema.create_table("
|
|
177
|
+
assert_nil(context["Posts.n_viewed"])
|
|
178
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
154
179
|
table.unsigned_integer32 :n_viewed
|
|
155
180
|
end
|
|
156
|
-
assert_equal(context["
|
|
181
|
+
assert_equal(context["UInt32"], context["Posts.n_viewed"].range)
|
|
157
182
|
end
|
|
158
183
|
|
|
159
184
|
def test_unsigned_integer64_column
|
|
160
|
-
assert_nil(context["
|
|
161
|
-
Groonga::Schema.create_table("
|
|
185
|
+
assert_nil(context["Posts.n_viewed"])
|
|
186
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
162
187
|
table.unsigned_integer64 :n_viewed
|
|
163
188
|
end
|
|
164
|
-
assert_equal(context["
|
|
189
|
+
assert_equal(context["UInt64"], context["Posts.n_viewed"].range)
|
|
165
190
|
end
|
|
166
191
|
|
|
167
192
|
def test_float_column
|
|
168
|
-
assert_nil(context["
|
|
169
|
-
Groonga::Schema.create_table("
|
|
193
|
+
assert_nil(context["Posts.rate"])
|
|
194
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
170
195
|
table.float :rate
|
|
171
196
|
end
|
|
172
|
-
assert_equal(context["
|
|
197
|
+
assert_equal(context["Float"], context["Posts.rate"].range)
|
|
173
198
|
end
|
|
174
199
|
|
|
175
200
|
def test_time_column
|
|
176
|
-
assert_nil(context["
|
|
177
|
-
Groonga::Schema.create_table("
|
|
201
|
+
assert_nil(context["Posts.last_modified"])
|
|
202
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
178
203
|
table.time :last_modified
|
|
179
204
|
end
|
|
180
|
-
assert_equal(context["
|
|
205
|
+
assert_equal(context["Time"], context["Posts.last_modified"].range)
|
|
181
206
|
end
|
|
182
207
|
|
|
183
208
|
def test_short_text_column
|
|
184
|
-
assert_nil(context["
|
|
185
|
-
Groonga::Schema.create_table("
|
|
209
|
+
assert_nil(context["Posts.title"])
|
|
210
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
186
211
|
table.short_text :title
|
|
187
212
|
end
|
|
188
|
-
assert_equal(context["
|
|
213
|
+
assert_equal(context["ShortText"], context["Posts.title"].range)
|
|
189
214
|
end
|
|
190
215
|
|
|
191
216
|
def test_text_column
|
|
192
|
-
assert_nil(context["
|
|
193
|
-
Groonga::Schema.create_table("
|
|
217
|
+
assert_nil(context["Posts.comment"])
|
|
218
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
194
219
|
table.text :comment
|
|
195
220
|
end
|
|
196
|
-
assert_equal(context["
|
|
221
|
+
assert_equal(context["Text"], context["Posts.comment"].range)
|
|
197
222
|
end
|
|
198
223
|
|
|
199
224
|
def test_long_text_column
|
|
200
|
-
assert_nil(context["
|
|
201
|
-
Groonga::Schema.create_table("
|
|
225
|
+
assert_nil(context["Posts.content"])
|
|
226
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
202
227
|
table.long_text :content
|
|
203
228
|
end
|
|
204
|
-
assert_equal(context["
|
|
229
|
+
assert_equal(context["LongText"], context["Posts.content"].range)
|
|
205
230
|
end
|
|
206
231
|
|
|
207
232
|
def test_remove_column
|
|
208
|
-
Groonga::Schema.create_table("
|
|
233
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
209
234
|
table.long_text :content
|
|
210
235
|
end
|
|
211
|
-
assert_not_nil(context["
|
|
236
|
+
assert_not_nil(context["Posts.content"])
|
|
212
237
|
|
|
213
|
-
Groonga::Schema.change_table("
|
|
238
|
+
Groonga::Schema.change_table("Posts") do |table|
|
|
214
239
|
table.remove_column("content")
|
|
215
240
|
end
|
|
216
|
-
assert_nil(context["
|
|
241
|
+
assert_nil(context["Posts.content"])
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def test_column_again
|
|
245
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
246
|
+
table.text :content
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
assert_nothing_raised do
|
|
250
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
251
|
+
table.text :content
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
def test_column_again_with_difference_type
|
|
257
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
258
|
+
table.text :content
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
assert_raise(ArgumentError) do
|
|
262
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
263
|
+
table.integer :content
|
|
264
|
+
end
|
|
265
|
+
end
|
|
217
266
|
end
|
|
218
267
|
|
|
219
268
|
def test_index
|
|
220
|
-
assert_nil(context["
|
|
221
|
-
Groonga::Schema.create_table("
|
|
269
|
+
assert_nil(context["Terms.content"])
|
|
270
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
222
271
|
table.long_text :content
|
|
223
272
|
end
|
|
224
|
-
Groonga::Schema.create_table("
|
|
225
|
-
table.index "
|
|
273
|
+
Groonga::Schema.create_table("Terms") do |table|
|
|
274
|
+
table.index "Posts.content"
|
|
275
|
+
end
|
|
276
|
+
assert_equal([context["Posts.content"]],
|
|
277
|
+
context["Terms.Posts_content"].sources)
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
def test_index_with_full_option
|
|
281
|
+
path = @tmp_dir + "index-column.groonga"
|
|
282
|
+
assert_nil(context["Terms.content"])
|
|
283
|
+
index_column_name = "Posts-index"
|
|
284
|
+
|
|
285
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
286
|
+
table.long_text :content
|
|
287
|
+
end
|
|
288
|
+
Groonga::Schema.create_table("Terms") do |table|
|
|
289
|
+
table.index("Posts.content",
|
|
290
|
+
:name => index_column_name,
|
|
291
|
+
:path => path.to_s,
|
|
292
|
+
:persistent => true,
|
|
293
|
+
:with_section => true,
|
|
294
|
+
:with_weight => true,
|
|
295
|
+
:with_position => true)
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
posts = context["Posts"]
|
|
299
|
+
terms = context["Terms"]
|
|
300
|
+
full_index_column_name = "Terms.#{index_column_name}"
|
|
301
|
+
index_column = context[full_index_column_name]
|
|
302
|
+
assert_equal("#<Groonga::IndexColumn " +
|
|
303
|
+
"id: <#{index_column.id}>, " +
|
|
304
|
+
"name: <#{full_index_column_name}>, " +
|
|
305
|
+
"path: <#{path}>, " +
|
|
306
|
+
"domain: <Terms>, " +
|
|
307
|
+
"range: <Posts>, " +
|
|
308
|
+
"flags: <WITH_SECTION|WITH_WEIGHT|WITH_POSITION|" +
|
|
309
|
+
"UNIT_DOCUMENT_SECTION|UNIT_DOCUMENT_POSITION|" +
|
|
310
|
+
"UNIT_USERDEF_DOCUMENT|UNIT_USERDEF_SECTION>>",
|
|
311
|
+
index_column.inspect)
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
def test_index_again
|
|
315
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
316
|
+
table.long_text :content
|
|
317
|
+
end
|
|
318
|
+
Groonga::Schema.create_table("Terms") do |table|
|
|
319
|
+
table.index "Posts.content"
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
assert_nothing_raised do
|
|
323
|
+
Groonga::Schema.create_table("Terms") do |table|
|
|
324
|
+
table.index "Posts.content"
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
def test_index_again_with_difference_source
|
|
330
|
+
Groonga::Schema.create_table("Posts") do |table|
|
|
331
|
+
table.long_text :content
|
|
332
|
+
table.short_text :name
|
|
333
|
+
end
|
|
334
|
+
Groonga::Schema.create_table("Terms") do |table|
|
|
335
|
+
table.index "Posts.content"
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
assert_raise(ArgumentError) do
|
|
339
|
+
Groonga::Schema.create_table("Terms") do |table|
|
|
340
|
+
table.index "Posts.name", :name => "Posts_content"
|
|
341
|
+
end
|
|
226
342
|
end
|
|
227
|
-
assert_equal([context["<posts>.content"]],
|
|
228
|
-
context["<terms>.<posts>_content"].sources)
|
|
229
343
|
end
|
|
230
344
|
|
|
231
345
|
def test_dump
|
|
232
346
|
Groonga::Schema.define do |schema|
|
|
233
|
-
schema.create_table("
|
|
347
|
+
schema.create_table("Posts") do |table|
|
|
234
348
|
table.short_text :title
|
|
235
349
|
end
|
|
236
350
|
end
|
|
237
351
|
assert_equal(<<-EOS, Groonga::Schema.dump)
|
|
238
|
-
create_table("
|
|
352
|
+
create_table("Posts") do |table|
|
|
239
353
|
table.short_text("title")
|
|
240
354
|
end
|
|
241
355
|
EOS
|
|
@@ -243,40 +357,60 @@ EOS
|
|
|
243
357
|
|
|
244
358
|
def test_reference_dump
|
|
245
359
|
Groonga::Schema.define do |schema|
|
|
246
|
-
schema.create_table("
|
|
360
|
+
schema.create_table("Items") do |table|
|
|
247
361
|
table.short_text("title")
|
|
248
362
|
end
|
|
249
363
|
|
|
250
|
-
schema.create_table("
|
|
364
|
+
schema.create_table("Users") do |table|
|
|
251
365
|
table.short_text("name")
|
|
252
366
|
end
|
|
253
367
|
|
|
254
|
-
schema.create_table("
|
|
255
|
-
table.reference("item", "
|
|
256
|
-
table.reference("author", "
|
|
368
|
+
schema.create_table("Comments") do |table|
|
|
369
|
+
table.reference("item", "Items")
|
|
370
|
+
table.reference("author", "Users")
|
|
257
371
|
table.text("content")
|
|
258
372
|
table.time("issued")
|
|
259
373
|
end
|
|
260
374
|
end
|
|
261
375
|
|
|
262
376
|
assert_equal(<<-EOS, Groonga::Schema.dump)
|
|
263
|
-
create_table("
|
|
377
|
+
create_table("Comments") do |table|
|
|
264
378
|
table.text("content")
|
|
265
379
|
table.time("issued")
|
|
266
380
|
end
|
|
267
381
|
|
|
268
|
-
create_table("
|
|
382
|
+
create_table("Items") do |table|
|
|
269
383
|
table.short_text("title")
|
|
270
384
|
end
|
|
271
385
|
|
|
272
|
-
create_table("
|
|
386
|
+
create_table("Users") do |table|
|
|
273
387
|
table.short_text("name")
|
|
274
388
|
end
|
|
275
389
|
|
|
276
|
-
change_table("
|
|
277
|
-
table.reference("author", "
|
|
278
|
-
table.reference("item", "
|
|
390
|
+
change_table("Comments") do |table|
|
|
391
|
+
table.reference("author", "Users")
|
|
392
|
+
table.reference("item", "Items")
|
|
279
393
|
end
|
|
280
394
|
EOS
|
|
281
395
|
end
|
|
396
|
+
|
|
397
|
+
def test_explicit_context_create_table
|
|
398
|
+
context = Groonga::Context.default
|
|
399
|
+
Groonga::Context.default = nil
|
|
400
|
+
|
|
401
|
+
Groonga::Schema.define(:context => context) do |schema|
|
|
402
|
+
schema.create_table('Items', :type => :hash) do |table|
|
|
403
|
+
table.text("text")
|
|
404
|
+
end
|
|
405
|
+
schema.create_table("TermsText",
|
|
406
|
+
:type => :patricia_trie,
|
|
407
|
+
:key_normalize => true,
|
|
408
|
+
:default_tokenizer => "TokenBigram") do |table|
|
|
409
|
+
table.index('Items.text')
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
assert_not_nil(context["Items.text"])
|
|
414
|
+
assert_not_nil(context["TermsText.Items_text"])
|
|
415
|
+
end
|
|
282
416
|
end
|