rroonga 2.0.4 → 2.0.5

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.
Files changed (90) hide show
  1. data/Rakefile +21 -2
  2. data/bin/grndump +3 -2
  3. data/ext/groonga/extconf.rb +1 -6
  4. data/ext/groonga/rb-grn-array.c +58 -31
  5. data/ext/groonga/rb-grn-column.c +220 -148
  6. data/ext/groonga/rb-grn-context.c +46 -32
  7. data/ext/groonga/rb-grn-database.c +102 -90
  8. data/ext/groonga/rb-grn-double-array-trie.c +205 -163
  9. data/ext/groonga/rb-grn-encoding-support.c +2 -3
  10. data/ext/groonga/rb-grn-encoding.c +13 -8
  11. data/ext/groonga/rb-grn-exception.c +1 -1
  12. data/ext/groonga/rb-grn-expression.c +110 -133
  13. data/ext/groonga/rb-grn-fix-size-column.c +5 -4
  14. data/ext/groonga/rb-grn-geo-point.c +55 -0
  15. data/ext/groonga/rb-grn-hash.c +120 -82
  16. data/ext/groonga/rb-grn-index-column.c +66 -70
  17. data/ext/groonga/rb-grn-index-cursor.c +3 -0
  18. data/ext/groonga/rb-grn-logger.c +33 -51
  19. data/ext/groonga/rb-grn-object.c +2 -0
  20. data/ext/groonga/rb-grn-operator.c +1 -1
  21. data/ext/groonga/rb-grn-patricia-trie.c +287 -232
  22. data/ext/groonga/rb-grn-plugin.c +11 -14
  23. data/ext/groonga/rb-grn-snippet.c +37 -54
  24. data/ext/groonga/rb-grn-table-cursor-key-support.c +3 -3
  25. data/ext/groonga/rb-grn-table-cursor.c +8 -6
  26. data/ext/groonga/rb-grn-table-key-support.c +22 -29
  27. data/ext/groonga/rb-grn-table.c +355 -279
  28. data/ext/groonga/rb-grn-type.c +18 -25
  29. data/ext/groonga/rb-grn-utils.c +77 -7
  30. data/ext/groonga/rb-grn-variable-size-column.c +12 -20
  31. data/ext/groonga/rb-grn-view.c +56 -51
  32. data/ext/groonga/rb-grn.h +28 -1
  33. data/ext/groonga/rb-groonga.c +1 -0
  34. data/lib/groonga.rb +2 -0
  35. data/lib/groonga/command.rb +3 -1
  36. data/lib/groonga/database.rb +27 -0
  37. data/lib/groonga/dumper.rb +96 -17
  38. data/lib/groonga/geo-point.rb +216 -0
  39. data/lib/groonga/schema.rb +29 -46
  40. data/rroonga-build.rb +1 -1
  41. data/rroonga.gemspec +90 -0
  42. data/test/groonga-test-utils.rb +168 -0
  43. data/test/run-test.rb +60 -0
  44. data/test/test-accessor.rb +36 -0
  45. data/test/test-array.rb +146 -0
  46. data/test/test-column.rb +350 -0
  47. data/test/test-command-select.rb +181 -0
  48. data/test/test-context.rb +130 -0
  49. data/test/test-database-dumper.rb +259 -0
  50. data/test/test-database.rb +173 -0
  51. data/test/test-double-array-trie.rb +189 -0
  52. data/test/test-encoding.rb +33 -0
  53. data/test/test-exception.rb +230 -0
  54. data/test/test-expression-builder.rb +602 -0
  55. data/test/test-expression.rb +134 -0
  56. data/test/test-fix-size-column.rb +77 -0
  57. data/test/test-geo-point.rb +190 -0
  58. data/test/test-gqtp.rb +70 -0
  59. data/test/test-hash.rb +367 -0
  60. data/test/test-index-column.rb +180 -0
  61. data/test/test-index-cursor.rb +123 -0
  62. data/test/test-logger.rb +37 -0
  63. data/test/test-pagination.rb +249 -0
  64. data/test/test-patricia-trie.rb +440 -0
  65. data/test/test-plugin.rb +35 -0
  66. data/test/test-procedure.rb +37 -0
  67. data/test/test-query-log.rb +258 -0
  68. data/test/test-record.rb +577 -0
  69. data/test/test-remote.rb +63 -0
  70. data/test/test-schema-create-table.rb +267 -0
  71. data/test/test-schema-dumper.rb +235 -0
  72. data/test/test-schema-type.rb +208 -0
  73. data/test/test-schema-view.rb +90 -0
  74. data/test/test-schema.rb +886 -0
  75. data/test/test-snippet.rb +130 -0
  76. data/test/test-table-dumper.rb +353 -0
  77. data/test/test-table-offset-and-limit.rb +100 -0
  78. data/test/test-table-select-mecab.rb +80 -0
  79. data/test/test-table-select-normalize.rb +57 -0
  80. data/test/test-table-select-weight.rb +123 -0
  81. data/test/test-table-select.rb +191 -0
  82. data/test/test-table-traverse.rb +304 -0
  83. data/test/test-table.rb +711 -0
  84. data/test/test-type.rb +79 -0
  85. data/test/test-variable-size-column.rb +147 -0
  86. data/test/test-variable.rb +28 -0
  87. data/test/test-vector-column.rb +76 -0
  88. data/test/test-version.rb +61 -0
  89. data/test/test-view.rb +72 -0
  90. metadata +330 -202
@@ -0,0 +1,100 @@
1
+ # Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License version 2.1 as published by the Free Software Foundation.
6
+ #
7
+ # This library is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
+ # Lesser General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU Lesser General Public
13
+ # License along with this library; if not, write to the Free Software
14
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
+
16
+ module TestOffsetAndLimitSupport
17
+ def test_zero_and_positive_offset
18
+ assert_equal(((100 + 0)...200).to_a, ids(:offset => 0))
19
+ assert_equal(((100 + 32)...200).to_a, ids(:offset => 32))
20
+ assert_equal(((100 + 99)...200).to_a, ids(:offset => 99))
21
+ assert_raise(Groonga::TooLargeOffset) do
22
+ ids(:offset => 100)
23
+ end
24
+ end
25
+
26
+ def test_negative_offset
27
+ assert_equal(((200 - 1)...200).to_a, ids(:offset => -1))
28
+ assert_equal(((200 - 32)...200).to_a, ids(:offset => -32))
29
+ assert_equal(((200 - 100)...200).to_a, ids(:offset => -100))
30
+ assert_raise(Groonga::TooSmallOffset) do
31
+ ids(:offset => -101)
32
+ end
33
+ end
34
+
35
+ def test_zero_and_positive_limit
36
+ all_ids = (100...200).to_a
37
+ assert_equal(all_ids[0, 0], ids(:limit => 0))
38
+ assert_equal(all_ids[0, 32], ids(:limit => 32))
39
+ assert_equal(all_ids[0, 100], ids(:limit => 100))
40
+ assert_nothing_raised do
41
+ ids(:limit => 101)
42
+ end
43
+ end
44
+
45
+ def test_negative_limit
46
+ all_ids = (100...200).to_a
47
+ assert_equal(all_ids[0..-1], ids(:limit => -1))
48
+ assert_equal(all_ids[0..-32], ids(:limit => -32))
49
+ assert_equal(all_ids[0..-100], ids(:limit => -100))
50
+ assert_equal([], ids(:limit => -101))
51
+ end
52
+
53
+ private
54
+ def create_bookmarks
55
+ @bookmarks = Groonga::Array.create(:name => "Bookmarks")
56
+ @bookmarks.define_column("id", "Int32")
57
+ @bookmarks
58
+ end
59
+
60
+ def add_ids
61
+ 100.times do |i|
62
+ bookmark = @bookmarks.add
63
+ bookmark["id"] = i + 100
64
+ end
65
+ @bookmarks
66
+ end
67
+ end
68
+
69
+ class TestOffsetAndLimit < Test::Unit::TestCase
70
+ include GroongaTestUtils
71
+ def setup
72
+ setup_database
73
+ @bookmarks = create_bookmarks
74
+ add_ids
75
+ end
76
+ end
77
+
78
+ class TestTableCursorOffsetAndLimit < TestOffsetAndLimit
79
+ include TestOffsetAndLimitSupport
80
+
81
+ private
82
+ def ids(options={})
83
+ @bookmarks.open_cursor(options) do |cursor|
84
+ cursor.collect do |record|
85
+ record["id"]
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ class TestTableSortOffsetAndLimit < TestOffsetAndLimit
92
+ include TestOffsetAndLimitSupport
93
+
94
+ private
95
+ def ids(options={})
96
+ @bookmarks.sort([:key => "id", :order => :asc], options).collect do |record|
97
+ record["id"]
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,80 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2010 Kouhei Sutou <kou@clear-code.com>
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License version 2.1 as published by the Free Software Foundation.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the Free Software
16
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+ class TableSelectMecabTest < Test::Unit::TestCase
19
+ include GroongaTestUtils
20
+
21
+ setup :setup_database
22
+
23
+ setup
24
+ def check_mecab_availability
25
+ omit("MeCab isn't available") if context["TokenMecab"].nil?
26
+ end
27
+
28
+ setup
29
+ def setup_tables
30
+ Groonga::Schema.define do |schema|
31
+ schema.create_table("Users", :key_type => "ShortText") do |table|
32
+ end
33
+
34
+ schema.create_table("Comments", :type => :array) do |table|
35
+ table.short_text("title")
36
+ table.text("content")
37
+ table.time("created_at")
38
+ table.reference("user", "Users")
39
+ end
40
+
41
+ schema.create_table("Terms",
42
+ :type => :patricia_trie,
43
+ :default_tokenizer => "TokenMecab") do |table|
44
+ table.index("Comments.title", :with_section => true)
45
+ table.index("Comments.content", :with_section => true)
46
+ end
47
+ end
48
+ end
49
+
50
+ setup
51
+ def setup_comments
52
+ @comments = context["Comments"]
53
+ @hello = @comments.add(:title => "Hello",
54
+ :content => "Hello Good-bye!",
55
+ :created_at => Time.parse("2009-08-09"),
56
+ :user => "morita")
57
+ @hello_only_in_content =
58
+ @comments.add(:title => "(no title)",
59
+ :content => "Hello! Hello! Hello!",
60
+ :created_at => Time.parse("2009-07-09"))
61
+ @test = @comments.add(:title => "title",
62
+ :content => "test",
63
+ :created_at => Time.parse("2009-06-09"),
64
+ :user => "gunyara-kun")
65
+ @japanese =
66
+ @comments.add(:title => "日本語",
67
+ :content => "うちのボロTVはまだ現役です",
68
+ :created_at => Time.parse("2009-06-09"),
69
+ :user => "darashi")
70
+ end
71
+
72
+ def test_match
73
+ result = @comments.select do |record|
74
+ record.content =~ "ボロ"
75
+ end
76
+ assert_equal_select_result(["日本語"], result) do |record|
77
+ record.title
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,57 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2009 SHIDARA Yoji <dara@shidara.net>
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License version 2.1 as published by the Free Software Foundation.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the Free Software
16
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+ class TableSelectNormalizeTest < Test::Unit::TestCase
19
+ include GroongaTestUtils
20
+
21
+ setup :setup_database
22
+
23
+ setup
24
+ def setup_comments
25
+ @comments = Groonga::Array.create(:name => "Comments")
26
+ @comments.define_column("content", "Text")
27
+ @comments.define_column("created_at", "Time")
28
+ options = {
29
+ :name => "Terms",
30
+ :default_tokenizer => "TokenBigramSplitSymbol",
31
+ :key_normalize => true,
32
+ }
33
+ terms = Groonga::PatriciaTrie.create(options)
34
+ terms.define_index_column("comment_content", @comments,
35
+ :with_section => true,
36
+ :with_position => true,
37
+ :source => "Comments.content")
38
+ @japanese_comment =
39
+ @comments.add(:content => "うちのボロTV(アナログ...)はまだ現役です",
40
+ :created_at => Time.parse("2009-06-09"))
41
+ end
42
+
43
+ def test_select_query_with_japanese
44
+ result = @comments.select("content:@ボロTV")
45
+ assert_equal_select_result([@japanese_comment], result)
46
+ end
47
+
48
+ def test_select_query_with_japanese_parenthesis
49
+ result = @comments.select("content:@)は")
50
+ assert_equal_select_result([@japanese_comment], result)
51
+ end
52
+
53
+ def test_select_query_only_in_japanese
54
+ result = @comments.select("content:@うちの")
55
+ assert_equal_select_result([@japanese_comment], result)
56
+ end
57
+ end
@@ -0,0 +1,123 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2010-2011 Kouhei Sutou <kou@clear-code.com>
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License version 2.1 as published by the Free Software Foundation.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the Free Software
16
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+ class TableSelectWeightTest < Test::Unit::TestCase
19
+ include GroongaTestUtils
20
+
21
+ setup :setup_database
22
+
23
+ setup
24
+ def setup_tables
25
+ Groonga::Schema.define do |schema|
26
+ schema.create_table("Users",
27
+ :type => :hash,
28
+ :key_type => "ShortText") do |table|
29
+ end
30
+
31
+ schema.create_table("Comments") do |table|
32
+ table.short_text("title")
33
+ table.text("content")
34
+ table.time("created_at")
35
+ table.reference("user", "Users")
36
+ end
37
+
38
+ schema.create_table("Terms",
39
+ :type => :patricia_trie,
40
+ :default_tokenizer => "TokenBigram") do |table|
41
+ table.index("Comments.title", :with_section => true)
42
+ table.index("Comments.content", :with_section => true)
43
+ end
44
+
45
+ schema.create_table("Titles",
46
+ :type => :hash) do |table|
47
+ table.index("Comments.title")
48
+ end
49
+
50
+ schema.change_table("Users") do |table|
51
+ table.index("Comments.user")
52
+ end
53
+ end
54
+ end
55
+
56
+ setup
57
+ def setup_comments
58
+ @comments = context["Comments"]
59
+ @hello = @comments.add(:title => "Hello",
60
+ :content => "Hello Good-bye!",
61
+ :created_at => Time.parse("2009-08-09"),
62
+ :user => "morita")
63
+ @hello_only_in_content =
64
+ @comments.add(:title => "(no title)",
65
+ :content => "Hello! Hello! Hello!",
66
+ :created_at => Time.parse("2009-07-09"))
67
+ @test = @comments.add(:title => "title",
68
+ :content => "test",
69
+ :created_at => Time.parse("2009-06-09"),
70
+ :user => "gunyara-kun")
71
+ @japanese =
72
+ @comments.add(:title => "日本語",
73
+ :content => "うちのボロTVはまだ現役です",
74
+ :created_at => Time.parse("2009-06-09"),
75
+ :user => "darashi")
76
+ end
77
+
78
+ def test_full_text_search
79
+ result = @comments.select do |record|
80
+ record.match("Hello") do |match_record|
81
+ (match_record.title * 100) |
82
+ match_record.content
83
+ end
84
+ end
85
+ assert_equal_select_result([["Hello", 101], ["(no title)", 3]],
86
+ result) do |record|
87
+ [record.title, record.score]
88
+ end
89
+ end
90
+
91
+ def test_reference
92
+ result = @comments.select do |record|
93
+ full_text_match = record.match("Hello") do |match_record|
94
+ (match_record.title * 100) |
95
+ match_record.content
96
+ end
97
+ reference_match = record.match("darashi") do |match_record|
98
+ match_record.user * 1000
99
+ end
100
+ full_text_match | reference_match
101
+ end
102
+ assert_equal_select_result([["Hello", 101],
103
+ ["(no title)", 3],
104
+ ["日本語", 1000]],
105
+ result) do |record|
106
+ [record.title, record.score]
107
+ end
108
+ end
109
+
110
+ def test_index
111
+ result = @comments.select do |record|
112
+ record.match("Hello") do |match_record|
113
+ (match_record.index("Titles.Comments_title") * 1000) |
114
+ (match_record.index("Terms.Comments_title") * 100) |
115
+ match_record.content
116
+ end
117
+ end
118
+ assert_equal_select_result([["Hello", 1101], ["(no title)", 3]],
119
+ result) do |record|
120
+ [record.title, record.score]
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,191 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2009-2011 Kouhei Sutou <kou@clear-code.com>
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License version 2.1 as published by the Free Software Foundation.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the Free Software
16
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+ class TableSelectTest < Test::Unit::TestCase
19
+ include GroongaTestUtils
20
+
21
+ setup :setup_database
22
+
23
+ setup
24
+ def setup_comments
25
+ @users = Groonga::Hash.create(:name => "Users", :key_type => "ShortText")
26
+
27
+ @comments = Groonga::Array.create(:name => "Comments")
28
+ @comments.define_column("content", "Text")
29
+ @comments.define_column("created_at", "Time")
30
+ @comments.define_column("user", "Users")
31
+
32
+ terms = Groonga::PatriciaTrie.create(:name => "Terms",
33
+ :default_tokenizer => "TokenBigram")
34
+ terms.define_index_column("comment_content", @comments,
35
+ :with_section => true,
36
+ :with_position => true,
37
+ :source => "content")
38
+ terms.define_index_column("users_key", @users,
39
+ :with_section => true,
40
+ :with_position => true,
41
+ :source => "_key")
42
+ @comment1 = @comments.add(:content => "Hello Good-bye!",
43
+ :created_at => Time.parse("2009-08-09"),
44
+ :user => "morita")
45
+ @comment2 = @comments.add(:content => "Hello World",
46
+ :created_at => Time.parse("2009-07-09"))
47
+ @comment3 = @comments.add(:content => "test",
48
+ :created_at => Time.parse("2009-06-09"),
49
+ :user => "gunyara-kun")
50
+ @japanese_comment =
51
+ @comments.add(:content => "うちのボロTVはまだ現役です",
52
+ :created_at => Time.parse("2009-06-09"),
53
+ :user => "darashi")
54
+ end
55
+
56
+ setup
57
+ def setup_variables
58
+ @result = nil
59
+ end
60
+
61
+ def test_sub_expression
62
+ @result = @comments.select do |record|
63
+ record.match("Hello", "content") &
64
+ (record["created_at"] < Time.parse("2009-08-01"))
65
+ end
66
+ assert_equal_select_result([@comment2], @result)
67
+ end
68
+
69
+ def test_query
70
+ @result = @comments.select("content:@Hello")
71
+ assert_equal_select_result([@comment1, @comment2], @result)
72
+ end
73
+
74
+ def test_query_with_parser
75
+ @result = @comments.select("content @ \"Hello\"", :syntax => :script)
76
+ assert_equal_select_result([@comment1, @comment2], @result)
77
+ end
78
+
79
+ def test_query_with_default_column
80
+ @result = @comments.select("Hello", {:default_column => 'content'})
81
+ assert_equal_select_result([@comment1, @comment2], @result)
82
+ end
83
+
84
+ def test_expression
85
+ expression = Groonga::Expression.new
86
+ variable = expression.define_variable(:domain => @comments)
87
+ expression.append_object(variable)
88
+ expression.parse("content:@Hello", :syntax => :query)
89
+ expression.compile
90
+ @result = @comments.select(expression)
91
+ assert_equal(expression, @result.expression)
92
+ assert_equal_select_result([@comment1, @comment2], @result)
93
+ end
94
+
95
+ def test_query_with_block
96
+ @result = @comments.select("content:@Hello") do |record|
97
+ record["created_at"] < Time.parse("2009-08-01")
98
+ end
99
+ assert_equal_select_result([@comment2], @result)
100
+ end
101
+
102
+ def test_query_with_block_match
103
+ @result = @comments.select("content:@Hello") do |record|
104
+ record.match("World", "content")
105
+ end
106
+ assert_equal_select_result([@comment2], @result)
107
+ end
108
+
109
+ def test_without_block
110
+ @result = @comments.select
111
+ assert_equal_select_result([@comment1, @comment2,
112
+ @comment3, @japanese_comment],
113
+ @result)
114
+ end
115
+
116
+ def test_query_japanese
117
+ @result = @comments.select("content:@ボロTV")
118
+ assert_equal_select_result([@japanese_comment], @result)
119
+ end
120
+
121
+ def test_but_query
122
+ @result = @comments.select do |record|
123
+ record["content"].match "Hello -World"
124
+ end
125
+ assert_equal_select_result([@comment1], @result)
126
+ end
127
+
128
+ def test_query_with_three_terms
129
+ @result = @comments.select do |record|
130
+ record["content"].match "Say Hello World"
131
+ end
132
+ assert_equal_select_result([], @result)
133
+ end
134
+
135
+ def test_query_with_brackets
136
+ @result = @comments.select do |record|
137
+ record["content"].match "Say (Hello World)"
138
+ end
139
+ assert_equal_select_result([], @result)
140
+ end
141
+
142
+ def test_equal_reference_column_by_key
143
+ @result = @comments.select do |record|
144
+ record["user"] == "darashi"
145
+ end
146
+ assert_equal_select_result([@japanese_comment], @result)
147
+ end
148
+
149
+ def test_not_equal_reference_column_by_key
150
+ @result = @comments.select('user != "darashi"', :syntax => :script)
151
+ assert_equal_select_result([@comment1, @comment2, @comment3],
152
+ @result)
153
+ end
154
+
155
+ def test_not_equal_block
156
+ only_ruby19
157
+ @result = @comments.select do |record|
158
+ record.user != "darashi"
159
+ end
160
+ assert_equal_select_result([@comment1, @comment2, @comment3],
161
+ @result)
162
+ end
163
+
164
+ def test_equal_reference_column_by_nonexistent_key
165
+ @result = @comments.select do |record|
166
+ record["user"] == "nonexistent"
167
+ end
168
+ assert_equal_select_result([], @result)
169
+ end
170
+
171
+ def test_query_key
172
+ @result = @users.select do |record|
173
+ record["_key"] =~ "mori"
174
+ end
175
+ assert_equal_select_result([@users["morita"]], @result)
176
+ end
177
+
178
+ def test_symbol
179
+ @result = @comments.select do |record|
180
+ record[:content].match("Say Hello World")
181
+ end
182
+ assert_equal_select_result([], @result)
183
+ end
184
+
185
+ def test_method
186
+ @result = @comments.select do |record|
187
+ record.content.match("Say Hello World")
188
+ end
189
+ assert_equal_select_result([], @result)
190
+ end
191
+ end