[Groonga-commit] ranguba/rroonga at bd679c3 [master] expression-builder: disable auto ID detection

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Feb 25 19:01:48 JST 2016


Kouhei Sutou	2016-02-25 19:01:48 +0900 (Thu, 25 Feb 2016)

  New Revision: bd679c3592dbfdd97df446ab733825c9074fee9f
  https://github.com/ranguba/rroonga/commit/bd679c3592dbfdd97df446ab733825c9074fee9f

  Message:
    expression-builder: disable auto ID detection
    
    It's confused when Int/Uint types for key.

  Modified files:
    lib/groonga/expression-builder.rb
    test/test-expression-builder.rb

  Modified: lib/groonga/expression-builder.rb (+10 -7)
===================================================================
--- lib/groonga/expression-builder.rb    2016-02-21 19:34:21 +0900 (2c42e1a)
+++ lib/groonga/expression-builder.rb    2016-02-25 19:01:48 +0900 (1a19d15)
@@ -264,14 +264,17 @@ module Groonga
 
       private
       def normalize(other)
-        if****@range*****_a?(Groonga::Table)
-          if other.respond_to?(:record_id)
-            id = other.record_id
-          else
-            id = other
-          end
-          return Groonga::Record.new(@range, id) if id.is_a?(Integer)
+        return other unles****@range*****_a?(Table)
+        return other if other.is_a?(Record)
+
+        if other.respond_to?(:record_raw_id)
+          return Record.new(@range, other.record_raw_id)
         end
+
+        if other.respond_to?(:record_id)
+          return @range[other.record_id]
+        end
+
         other
       end
 

  Modified: test/test-expression-builder.rb (+17 -3)
===================================================================
--- test/test-expression-builder.rb    2016-02-21 19:34:21 +0900 (ecbf30e)
+++ test/test-expression-builder.rb    2016-02-25 19:01:48 +0900 (51a18ec)
@@ -686,9 +686,9 @@ EOC
                    result.collect {|record| record.key["uri"]})
     end
 
-    def test_id
+    def test_key
       result =****@bookm***** do |record|
-        record["user"] ==****@morit*****
+        record["user"] ==****@morit*****
       end
       assert_equal(["http://groonga.org/", "http://ruby-lang.org/"],
                    result.collect {|record| record.key["uri"]})
@@ -697,8 +697,22 @@ EOC
     def test_record_like_object
       morita = Object.new
       morita_singleton_class = (class << morita; self; end)
-      morita_id =****@morit*****
+      morita_key =****@morit*****
       morita_singleton_class.send(:define_method, :record_id) do
+        morita_key
+      end
+      result =****@bookm***** do |record|
+        record["user"] == morita
+      end
+      assert_equal(["http://groonga.org/", "http://ruby-lang.org/"],
+                   result.collect {|record| record.key["uri"]})
+    end
+
+    def test_record_like_object_raw
+      morita = Object.new
+      morita_singleton_class = (class << morita; self; end)
+      morita_id =****@morit*****
+      morita_singleton_class.send(:define_method, :record_raw_id) do
         morita_id
       end
       result =****@bookm***** do |record|
-------------- next part --------------
HTML����������������������������...
Download 



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