[Groonga-commit] groonga/groonga-query-log at c7daad2 [master] Ignore "null" and null type difference for old Groonga

Back to archive index
Kouhei Sutou null+****@clear*****
Thu Oct 18 12:00:47 JST 2018


Kouhei Sutou	2018-10-18 12:00:47 +0900 (Thu, 18 Oct 2018)

  Revision: c7daad2f797351b175c2e3e806beb60195485024
  https://github.com/groonga/groonga-query-log/commit/c7daad2f797351b175c2e3e806beb60195485024

  Message:
    Ignore "null" and null type difference for old Groonga

  Modified files:
    lib/groonga-query-log/response-comparer.rb
    test/test-response-comparer.rb

  Modified: lib/groonga-query-log/response-comparer.rb (+15 -8)
===================================================================
--- lib/groonga-query-log/response-comparer.rb    2018-10-09 14:36:23 +0900 (1ba4bb0)
+++ lib/groonga-query-log/response-comparer.rb    2018-10-18 12:00:47 +0900 (5000074)
@@ -113,8 +113,8 @@ module GroongaQueryLog
       n_hits2 = records_result2[0]
       return false if n_hits1 != n_hits2
 
-      columns1 = records_result1[1]
-      columns2 = records_result2[1]
+      columns1 = normalize_columns(records_result1[1])
+      columns2 = normalize_columns(records_result2[1])
       if all_output_columns?
         columns1.sort_by(&:first) == columns2.sort_by(&:first)
       else
@@ -137,8 +137,8 @@ module GroongaQueryLog
       n_hits2 = records_result2[0]
       return false if n_hits1 != n_hits2
 
-      columns1 = records_result1[1]
-      columns2 = records_result2[1]
+      columns1 = normalize_columns(records_result1[1])
+      columns2 = normalize_columns(records_result2[1])
       records1 = records_result1[2..-1]
       records2 = records_result2[2..-1]
 
@@ -185,8 +185,8 @@ module GroongaQueryLog
       n_hits2 = records_result2[0]
       return false if n_hits1 != n_hits2
 
-      columns1 = records_result1[1]
-      columns2 = records_result2[1]
+      columns1 = normalize_columns(records_result1[1])
+      columns2 = normalize_columns(records_result2[1])
       return false if columns1.sort_by(&:first) != columns2.sort_by(&:first)
 
       column_to_index1 = make_column_to_index_map(columns1)
@@ -223,8 +223,8 @@ module GroongaQueryLog
       n_hits2 = record_set2[0]
       return false if n_hits1 != n_hits2
 
-      columns1 = record_set1[1]
-      columns2 = record_set2[1]
+      columns1 = normalize_columns(record_set1[1])
+      columns2 = normalize_columns(record_set2[1])
       return false if columns1 != columns2
 
       records1 = record_set1[2..-1]
@@ -282,6 +282,13 @@ module GroongaQueryLog
       true
     end
 
+    def normalize_columns(columns)
+      columns.collect do |name, type|
+        type = nil if type == "null"
+        [name, type]
+      end
+    end
+
     def normalize_value(value, column)
       type = column[1]
       case type

  Modified: test/test-response-comparer.rb (+48 -0)
===================================================================
--- test/test-response-comparer.rb    2018-10-09 14:36:23 +0900 (3d536fe)
+++ test/test-response-comparer.rb    2018-10-18 12:00:47 +0900 (575a3d6)
@@ -363,6 +363,54 @@ class ResponseComparerTest < Test::Unit::TestCase
       end
     end
 
+    class ColumnType < self
+      class Null < self
+        def create_response(type)
+          [
+            [
+              [1],
+              [["snippet_html", type]],
+              ["...snippet..."],
+            ]
+          ]
+        end
+
+        def test_all_output_columns
+          response1 = create_response("null")
+          response2 = create_response(nil)
+          assert do
+            same?(response1, response2)
+          end
+        end
+
+        def test_unary_minus_output_column
+          @command["output_columns"] = "-value, snippet_html(body)"
+          response1 = create_response("null")
+          response2 = create_response(nil)
+          assert do
+            same?(response1, response2)
+          end
+        end
+
+        def test_specific_output_column
+          @command["output_columns"] = "snippet_html(body)"
+          response1 = create_response("null")
+          response2 = create_response(nil)
+          assert do
+            same?(response1, response2)
+          end
+        end
+
+        def test_not_care_order
+          response1 = create_response("null")
+          response2 = create_response(nil)
+          assert do
+            same?(response1, response2, care_order: false)
+          end
+        end
+      end
+    end
+
     class DrilldownTest < self
       def create_response(drilldown)
         [
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20181018/f1975e88/attachment-0001.html>


More information about the Groonga-commit mailing list
Back to archive index