[Groonga-commit] groonga/groonga-command-parser at 8303f2f [master] Fix a bug that can't convert to the Elasticsearch format when a "load" command hasn't option name of "--value" (#3)

Back to archive index
Yasuhiro Horimoto null+****@clear*****
Mon Mar 25 10:09:39 JST 2019


Yasuhiro Horimoto	2019-03-25 10:09:39 +0900 (Mon, 25 Mar 2019)

  Revision: 8303f2f4179a4fc7d242823e412be03bcf4ecde8
  https://github.com/groonga/groonga-command-parser/commit/8303f2f4179a4fc7d242823e412be03bcf4ecde8

  Message:
    Fix a bug that can't convert to the Elasticsearch format when a "load" command hasn't option name of "--value" (#3)
    
    * groonga-command-convert-format: fix a bug that can't convert to the Elasticsearch format when a "load" command hasn't option name of "--value"
    
    * groonga-command-convert-format: fix a wrong type of option value
    
    * groonga-command-convert-format: fix a wrong conversion of type
    
    * groonga-command-convert-format: use "columns" parameter

  Modified files:
    lib/groonga/command/parser/command/groonga-command-convert-format.rb

  Modified: lib/groonga/command/parser/command/groonga-command-convert-format.rb (+18 -2)
===================================================================
--- lib/groonga/command/parser/command/groonga-command-convert-format.rb    2019-03-22 09:20:47 +0900 (7e15707)
+++ lib/groonga/command/parser/command/groonga-command-convert-format.rb    2019-03-25 10:09:39 +0900 (dde1f7a)
@@ -86,6 +86,7 @@ module Groonga
                              "Currently, we can specify 5, 6, 7, and 8" +
                                                       " in this option",
                              "Available only in elasticsearch format",
+                             Integer,
                              "[#{@elasticsearch_version}]") do |version|
               @elasticsearch_version = version
             end
@@ -95,8 +96,23 @@ module Groonga
 
           def convert(input)
             parser = Parser.new
-            parser.on_command do |command|
-              puts(convert_format(command))
+            case @format
+            when :elasticsearch
+              loaded_values = []
+              parser.on_load_value do |command, value|
+                loaded_values << value
+              end
+              parser.on_load_columns do |command, columns|
+                command[:columns] ||= columns.join(",")
+              end
+              parser.on_load_complete do |command|
+                command[:values] = JSON.generate(loaded_values)
+                puts(convert_format(command))
+              end
+            else
+              parser.on_command do |command|
+                puts(convert_format(command))
+              end
             end
             input.each_line do |line|
               parser << line
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190325/b7994402/attachment-0001.html>


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