[Groonga-commit] droonga/droonga-engine at e98a247 [master] Accept mismatched type key for "add" command

Zurück zum Archiv-Index

YUKI Hiroshi null+****@clear*****
Tue Dec 2 12:14:55 JST 2014


YUKI Hiroshi	2014-12-02 12:14:55 +0900 (Tue, 02 Dec 2014)

  New Revision: e98a247981ed8bd44c779ee02316334d1c43efcb
  https://github.com/droonga/droonga-engine/commit/e98a247981ed8bd44c779ee02316334d1c43efcb

  Message:
    Accept mismatched type key for "add" command

  Modified files:
    lib/droonga/plugins/crud.rb

  Modified: lib/droonga/plugins/crud.rb (+14 -1)
===================================================================
--- lib/droonga/plugins/crud.rb    2014-12-02 12:12:55 +0900 (7a2d227)
+++ lib/droonga/plugins/crud.rb    2014-12-02 12:14:55 +0900 (befd29d)
@@ -107,7 +107,8 @@ module Droonga
         def add_record(table, request)
           record = nil
           if table.support_key?
-            record = table.add(request["key"])
+            key = normalize_record_key(request["key"], table)
+            record = table.add(key)
           else
             record = table.add
           end
@@ -126,6 +127,18 @@ module Droonga
             end
           end
         end
+
+        def normalize_record_key(key, table)
+          case table.domain.name
+          when "Int8",  "UInt8",
+               "Int16", "UInt16",
+               "Int32", "UInt32",
+               "Int64", "UInt64"
+            key.to_i
+          else
+            key.to_s
+          end
+        end
       end
 
       define_single_step do |step|
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index