[Groonga-commit] ranguba/groonga-client at 7456e0e [master] groonga-client-index-check: support Time

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Nov 9 15:52:03 JST 2017


Kouhei Sutou	2017-11-09 15:52:03 +0900 (Thu, 09 Nov 2017)

  New Revision: 7456e0e4a5ce2e681bfd2864d985841f41175121
  https://github.com/ranguba/groonga-client/commit/7456e0e4a5ce2e681bfd2864d985841f41175121

  Message:
    groonga-client-index-check: support Time

  Modified files:
    lib/groonga/client/command-line/groonga-client-index-check.rb
    test/command-line/test-index-check.rb

  Modified: lib/groonga/client/command-line/groonga-client-index-check.rb (+3 -0)
===================================================================
--- lib/groonga/client/command-line/groonga-client-index-check.rb    2017-10-31 13:46:34 +0900 (c67a988)
+++ lib/groonga/client/command-line/groonga-client-index-check.rb    2017-11-09 15:52:03 +0900 (0d276f5)
@@ -135,6 +135,8 @@ module Groonga
             case token
             when String
               value = Groonga::Client::ScriptSyntax.format_string(token)
+            when Time
+              value = token.to_f
             else
               value = token
             end
@@ -174,6 +176,7 @@ module Groonga
                                     full_index_column_name,
                                     full_new_index_column_name,
                                     token)
+                  token = token.to_f if token.is_a?(Time)
                   $stderr.puts("Broken: #{index_column.full_name}: <#{token}>")
                   return false
                 end

  Modified: test/command-line/test-index-check.rb (+28 -0)
===================================================================
--- test/command-line/test-index-check.rb    2017-10-31 13:46:34 +0900 (fd9dcc6)
+++ test/command-line/test-index-check.rb    2017-11-09 15:52:03 +0900 (0426bf0)
@@ -288,5 +288,33 @@ delete Scores --key 9
       assert_equal([false, "", "Broken: Scores.memos_score: <9>\n"],
                    index_check("--method=content"))
     end
+
+    def test_time
+      time = Time.parse("2017-11-09T15:40:50+09:00")
+      restore(<<-COMMANDS)
+table_create Memos TABLE_HASH_KEY ShortText
+column_create Memos created_at COLUMN_SCALAR Time
+
+table_create Times TABLE_PAT_KEY Time
+column_create Times memos_created_at \
+  COLUMN_INDEX \
+  Memos created_at
+
+load --table Memos
+[
+{"_key": "groonga", "created_at": #{time.to_i}},
+{"_key": "mroonga", "created_at": #{time.to_i * 1}}
+]
+
+delete Times --key #{time.to_i}
+      COMMANDS
+
+      assert_equal([
+                     false,
+                     "",
+                     "Broken: Times.memos_created_at: <#{time.to_f}>\n",
+                   ],
+                   index_check("--method=content"))
+    end
   end
 end
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171109/c7579d4e/attachment-0001.htm 



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