[Groonga-commit] ranguba/groonga-client at 1106d13 [master] Ignore space only expression

Back to archive index

Kouhei Sutou null+****@clear*****
Wed May 31 15:24:51 JST 2017


Kouhei Sutou	2017-05-31 15:24:51 +0900 (Wed, 31 May 2017)

  New Revision: 1106d1367ad89daf1b235eaf1679455b6eea0e7c
  https://github.com/ranguba/groonga-client/commit/1106d1367ad89daf1b235eaf1679455b6eea0e7c

  Message:
    Ignore space only expression

  Modified files:
    lib/groonga/client/request/select.rb
    test/request/select/test-scorer.rb

  Modified: lib/groonga/client/request/select.rb (+7 -4)
===================================================================
--- lib/groonga/client/request/select.rb    2017-05-31 15:21:11 +0900 (8cd3ffc)
+++ lib/groonga/client/request/select.rb    2017-05-31 15:24:51 +0900 (69aea77)
@@ -151,10 +151,13 @@ module Groonga
             values = { column: column_name }
           when String
             expression = expression_or_column_name
-            unless expression.empty?
-              unless expression.start_with?("_score = ")
-                expression = "_score = " + expression
-              end
+            case expression
+            when /\A\s*\z/
+              expression = nil
+            when /\A_score\s*=/
+              # have "_score ="
+            else
+              expression = "_score = #{expression}"
             end
             values = values_or_value
           else

  Modified: test/request/select/test-scorer.rb (+7 -0)
===================================================================
--- test/request/select/test-scorer.rb    2017-05-31 15:21:11 +0900 (6454ceb)
+++ test/request/select/test-scorer.rb    2017-05-31 15:24:51 +0900 (ec5cbbe)
@@ -47,6 +47,13 @@ class TestRequestSelectScorer < Test::Unit::TestCase
                    scorer(""))
     end
 
+    def test_space_only_string
+      assert_equal({
+                     :table => "posts",
+                   },
+                   scorer(" \t\r\n"))
+    end
+
     def test_symbol
       assert_equal({
                      :table => "posts",
-------------- next part --------------
HTML����������������������������...
Download 



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