groonga-query-log 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d76c466c0afc38392bb3dec3b4822deb3d8d7ee
4
- data.tar.gz: 2d5f7478e94178b392fe78c75e9fdbcd9e09ba32
3
+ metadata.gz: 4470d1ef7de4d8221d1a79518f1b5676d0dcf5a0
4
+ data.tar.gz: 0cf988c683f5db1eb3d78856b058d2f86a757781
5
5
  SHA512:
6
- metadata.gz: 99182055f76da93c0a2384ad0a01e4719ed672eebbbcf46fa67dd89d3ad3ddefd3042dfecfc75513a34f81e99f87eb6c0928d8029c3b112173e37fa0d8daf686
7
- data.tar.gz: 1e030de8949c5f1e3a31ae354b350f221f2ec3d79ee64157a3684313dec9872661d52db002fd835ea03207451937f2638a351cf7530a3ce662854d51207dd6e5
6
+ metadata.gz: b6444789fc538aaca6f6bce2d23395f22eb8f52028ef11ca5e375544a0a25232c9d94e7bc0d5e77201afd8ea0c5c0ab9f1133bc784fd087a4d9e0d32f04188c1
7
+ data.tar.gz: e8fe331d8afac900ec3369da373a1c2cfa9cb184a47e6872085fd80a551cdfc2fde0e4d72369b9df7d1ea22386bf88ed24c6720194d04abe5c365c0cf324803f
data/doc/text/news.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # News
2
2
 
3
+ ## 1.2.2: 2016-06-15
4
+
5
+ ### Improvements
6
+
7
+ * groonga-query-log-verify-server: Relaxed random score detect condition.
8
+
9
+ * groonga-query-log-verify-server: Supported the case that only one
10
+ response has outputs for `--output_columns "-column"`. The
11
+ `-column` outputs are ignored.
12
+
3
13
  ## 1.2.1: 2016-05-27
4
14
 
5
15
  ### Fixes
@@ -60,7 +60,9 @@ module Groonga
60
60
  def same_select_response?
61
61
  if care_order?
62
62
  if all_output_columns?
63
- same_all_output_columns?
63
+ same_records_all_output_columns?
64
+ elsif have_unary_minus_output_column?
65
+ same_records_unary_minus_output_column?
64
66
  else
65
67
  same_response?
66
68
  end
@@ -78,7 +80,7 @@ module Groonga
78
80
 
79
81
  def random_score?
80
82
  return false unless @command.respond_to?(:scorer)
81
- @command.scorer == "_score=rand()"
83
+ /\A_score\s*=\s*rand\(\)\z/ === @command.scorer
82
84
  end
83
85
 
84
86
  def random_sort?
@@ -111,6 +113,51 @@ module Groonga
111
113
  end
112
114
  end
113
115
 
116
+ def have_unary_minus_output_column?
117
+ output_columns = @command.output_columns
118
+ return false if output_columns.nil?
119
+ output_columns.split(/\s*,?\s*/).any? {|column| column.start_with?("-")}
120
+ end
121
+
122
+ def same_records_unary_minus_output_column?
123
+ records_result1 = @response1.body[0] || []
124
+ records_result2 = @response2.body[0] || []
125
+ return false if records_result1.size != records_result2.size
126
+
127
+ n_hits1 = records_result1[0]
128
+ n_hits2 = records_result2[0]
129
+ return false if n_hits1 != n_hits2
130
+
131
+ columns1 = records_result1[1]
132
+ columns2 = records_result2[1]
133
+ records1 = records_result1[2..-1]
134
+ records2 = records_result2[2..-1]
135
+
136
+ if columns1.size != columns2.size
137
+ if columns2.size > columns1.size
138
+ columns1, columns2 = columns2, columns1
139
+ records1, records2 = records2, records1
140
+ end
141
+ end
142
+
143
+ records1.each_with_index do |record1, record_index|
144
+ record2 = records2[record_index]
145
+ column_offset2 = 0
146
+ columns1.each_with_index do |name, column_index1|
147
+ column_index2 = column_offset2 + column_index1
148
+ if name != columns2[column_index2]
149
+ column_offset2 -= 1
150
+ next
151
+ end
152
+ value1 = record1[column_index1]
153
+ value2 = record2[column_index2]
154
+ return false if value1 != value2
155
+ end
156
+ end
157
+
158
+ true
159
+ end
160
+
114
161
  def all_output_columns?
115
162
  output_columns = @command.output_columns
116
163
  output_columns.nil? or
@@ -118,7 +165,7 @@ module Groonga
118
165
  output_columns.split(/\s*,?\s*/).include?("*")
119
166
  end
120
167
 
121
- def same_all_output_columns?
168
+ def same_records_all_output_columns?
122
169
  records_result1 = @response1.body[0] || []
123
170
  records_result2 = @response2.body[0] || []
124
171
  return false if records_result1.size != records_result2.size
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Groonga
18
18
  module QueryLog
19
- VERSION = "1.2.1"
19
+ VERSION = "1.2.2"
20
20
  end
21
21
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2014-2016 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
@@ -103,6 +103,10 @@ class ResponseComparerTest < Test::Unit::TestCase
103
103
  assert_true(random_score?("_score=rand()"))
104
104
  end
105
105
 
106
+ def test_with_spaces
107
+ assert_true(random_score?("_score = rand()"))
108
+ end
109
+
106
110
  private
107
111
  def random_score?(scorer)
108
112
  @command["scorer"] = scorer
@@ -228,6 +232,69 @@ class ResponseComparerTest < Test::Unit::TestCase
228
232
  comparer([[[0], []]], [[[0], []]]).send(:all_output_columns?)
229
233
  end
230
234
  end
235
+
236
+ class UnaryMinusTest < self
237
+ def setup
238
+ super
239
+ @command["output_columns"] = "_id, -value"
240
+ end
241
+
242
+ def test_ignore
243
+ response1 = [
244
+ [
245
+ [3],
246
+ [
247
+ ["_id", "UInt32"],
248
+ ],
249
+ [1],
250
+ [2],
251
+ [3],
252
+ ],
253
+ ]
254
+ response2 = [
255
+ [
256
+ [3],
257
+ [
258
+ ["_id", "UInt32"],
259
+ ["value", nil],
260
+ ],
261
+ [1, -11],
262
+ [2, -12],
263
+ [3, -13],
264
+ ],
265
+ ]
266
+ assert do
267
+ same?(response1, response2)
268
+ end
269
+ end
270
+ end
271
+
272
+ class DetectUnaryMinusTest < self
273
+ def test_unary_minus_column_only
274
+ assert do
275
+ have_unary_minus_output_column?("-value")
276
+ end
277
+ end
278
+
279
+ def test_include_unary_minus_column
280
+ assert do
281
+ have_unary_minus_output_column?("_id, -value")
282
+ end
283
+ end
284
+
285
+ def test_nonexistent
286
+ assert do
287
+ not have_unary_minus_output_column?("_id, _key")
288
+ end
289
+ end
290
+
291
+ private
292
+ def have_unary_minus_output_column?(output_columns)
293
+ @command["output_columns"] = output_columns if output_columns
294
+ comparer([[[0], []]],
295
+ [[[0], []]]).send(:have_unary_minus_output_column?)
296
+ end
297
+ end
231
298
  end
232
299
 
233
300
  class ForceNoCareOrderTest < self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groonga-query-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-27 00:00:00.000000000 Z
11
+ date: 2016-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: groonga-command-parser