fluent-plugin-filter_where 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e758b04ade2bd2cff6ff9e2ed181a5e621493fc
4
- data.tar.gz: e9c2b7cedb2c2d5cbdcb07f3536ff6bf559b7458
3
+ metadata.gz: 755d2162c27bded3c029e34aecdb63f931f4e00f
4
+ data.tar.gz: 28bc4cb1e1ae126f3ae0a7b47662b145c3dcc6d4
5
5
  SHA512:
6
- metadata.gz: e4be09bba4b267d18a125314fa6499ce05a368c13278c390f3bd44acd587d316fcfa18c211a0dff6aa188375aeeda571ace5a8bb4d8310472656ca22bec98869
7
- data.tar.gz: c5cba7efd6332ba53083e0732918a83919b883257973f07c8a0417f24e792fc0feafba96a2cf39ec82cb2fa64b17f26a59df2e2155be1c92e9d27fbc32468e61
6
+ metadata.gz: eef617fe16e6981af9d8853b9c5fdaca3f78b5aad81f70f01473291bae16cd3fdd994fe04f6a6bafc653181b4337a8ee51370607ad779a417ea0ddf4cb8bc58d
7
+ data.tar.gz: 787fda5c049763e1eedd4dd6f18dccb18127c5d8e8447382136b9e9037771b3b36c36197f895a8d5dfc50f62b0378b3133eaea4cf0ebcbdac3f6d099d7573ab4
@@ -1,3 +1,9 @@
1
+ ## 1.0.3 (2017-05-23)
2
+
3
+ Enhancements:
4
+
5
+ * Support `<>` operator
6
+
1
7
  ## 1.0.2 (2017-05-23)
2
8
 
3
9
  Enhancements:
data/README.md CHANGED
@@ -36,7 +36,7 @@ Use RubyGems:
36
36
  Example:
37
37
 
38
38
  ```sql
39
- where (string_key START_WITH 'str' AND number_key > 1.0) OR ("true_key" = true AND string_key REGEXP '^reg')
39
+ where (string_key START_WITH 'str' AND number_key > 1.0) OR ("true_key" = true AND NOT (string_key REGEXP '^reg'))
40
40
  ```
41
41
 
42
42
  ## Literals
@@ -65,22 +65,22 @@ Characters matching with a regular expression `[a-zA-Z_][a-zA-z0-9_]*` such as `
65
65
 
66
66
  ### Boolean Operator
67
67
 
68
- * `=`
69
- * `!=`
68
+ * `=`: Equal operator
69
+ * `!=`, `<>`: Not equal operator
70
70
 
71
71
  ### Number Operator (Long and Double)
72
72
 
73
- * `=`
74
- * `!=`
75
- * `>`
76
- * `>=`
77
- * `<=`
78
- * `<`
73
+ * `=`: Equal operator
74
+ * `!=`, `<>`: Not equal operator
75
+ * `>`: Greater than operator
76
+ * `>=`: Greater than or equal operator
77
+ * `<=`: Less than or equal operator
78
+ * `<`: Less than operator
79
79
 
80
80
  ### String Operator
81
81
 
82
- * `=`
83
- * `!=`
82
+ * `=`: Equal operator
83
+ * `!=`, `<>`: Not equal operator
84
84
  * `START_WITH`
85
85
  * `END_WITH`
86
86
  * `INCLUDE`
@@ -90,11 +90,14 @@ Characters matching with a regular expression `[a-zA-Z_][a-zA-z0-9_]*` such as `
90
90
 
91
91
  Not supported yet
92
92
 
93
- ### unary operator
93
+ ### Negate Operator
94
94
 
95
- * "xxx IS NULL"
96
- * "xxx IS NOT NULL"
97
- * "NOT xxx"
95
+ * `NOT xxx`
96
+
97
+ ### NULL Operator
98
+
99
+ * `IS NULL`
100
+ * `IS NOT NULL`
98
101
 
99
102
  ## ChangeLog
100
103
 
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "fluent-plugin-filter_where"
6
- gem.version = "1.0.2"
6
+ gem.version = "1.0.3"
7
7
  gem.authors = ["Naotoshi Seo"]
8
8
  gem.email = "sonots@gmail.com"
9
9
  gem.homepage = "https://github.com/sonots/fluent-plugin-filter_where"
@@ -86,6 +86,7 @@ rule
86
86
  :STRING \\ { @string << "\\"; nil }
87
87
 
88
88
  inner
89
+ require 'logger'
89
90
  attr_reader :log
90
91
  def initialize(log: nil)
91
92
  @log = log || ::Logger.new(nil)
@@ -93,6 +94,6 @@ inner
93
94
  end
94
95
 
95
96
  def on_error(error_token_id, error_value, value_stack)
96
- raise Fluent::ConfigError.new("filter_where: failed to parse where value_stack:#{value_stack} error_value:#{error_value.inspect}")
97
+ raise Fluent::ConfigError.new("filter_where: failed to parse \"where\" value_stack:#{value_stack} error_value:#{error_value.inspect}")
97
98
  end
98
99
  end
@@ -200,12 +200,13 @@ class Fluent::FilterWhere::Parser < Racc::Parser
200
200
  token
201
201
  end # def _next_token
202
202
 
203
+ require 'logger'
203
204
  attr_reader :log
204
205
  def initialize(log: nil)
205
206
  @log = log || ::Logger.new(nil)
206
207
  super()
207
208
  end
208
209
  def on_error(error_token_id, error_value, value_stack)
209
- raise Fluent::ConfigError.new("filter_where: failed to parse where value_stack:#{value_stack} error_value:#{error_value.inspect}")
210
+ raise Fluent::ConfigError.new("filter_where: failed to parse \"where\" value_stack:#{value_stack} error_value:#{error_value.inspect}")
210
211
  end
211
212
  end # class
@@ -53,6 +53,8 @@ class WhereParserTest < Test::Unit::TestCase
53
53
  assert_true(result.eval(record))
54
54
  result = parser.scan(%q[boolean != false])
55
55
  assert_true(result.eval(record))
56
+ result = parser.scan(%q[boolean <> false])
57
+ assert_true(result.eval(record))
56
58
  assert_raise(Fluent::ConfigError) { parser.scan(%q[boolean > false]) }
57
59
  end
58
60
 
@@ -61,6 +63,8 @@ class WhereParserTest < Test::Unit::TestCase
61
63
  assert_true(result.eval(record))
62
64
  result = parser.scan(%q[integer != 0])
63
65
  assert_true(result.eval(record))
66
+ result = parser.scan(%q[integer <> 0])
67
+ assert_true(result.eval(record))
64
68
  result = parser.scan(%q[integer > 0])
65
69
  assert_true(result.eval(record))
66
70
  result = parser.scan(%q[integer >= 0])
@@ -76,6 +80,8 @@ class WhereParserTest < Test::Unit::TestCase
76
80
  assert_true(result.eval(record))
77
81
  result = parser.scan(%q[string != 'foobar'])
78
82
  assert_true(result.eval(record))
83
+ result = parser.scan(%q[string <> 'foobar'])
84
+ assert_true(result.eval(record))
79
85
  result = parser.scan(%q[string start_with'str'])
80
86
  assert_true(result.eval(record))
81
87
  result = parser.scan(%q[string end_with 'ing'])
@@ -100,4 +106,9 @@ class WhereParserTest < Test::Unit::TestCase
100
106
  result = parser.scan(%q[boolean = true OR string = 'foobar'])
101
107
  assert_true(result.eval(record))
102
108
  end
109
+
110
+ def test_negate_op
111
+ result = parser.scan(%q[NOT boolean = true])
112
+ assert_false(result.eval(record))
113
+ end
103
114
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-filter_where
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo