influxdb-client 1.6.0.pre.916 → 1.6.0.pre.944

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
  SHA256:
3
- metadata.gz: 4c77af86f0b9b7749ddbf9d5111c76839f492f587ecb38d104a817af22048a2f
4
- data.tar.gz: 290a21b26ce9eeb84ee746ff29bc7100c825b37548c795e8f398c8dafbfa1784
3
+ metadata.gz: 47ed13d8e18444afae6d7d928c352bb36ab60d555bf024c978ddd3e322cb1fab
4
+ data.tar.gz: 1c36796eccceaff2cf95056cf1fa7f8f8574398ec6d98500a652e876d19b78b9
5
5
  SHA512:
6
- metadata.gz: f979e9911c370f77d376dc99035055c35241588007f9d30864fb9bd5db3be87b257a358a6ae6dbacdee68e5a5b95da871f2556e572078fdf939f02f7a6479a69
7
- data.tar.gz: 5d40d9c3981bed04fab6ac9d45d881e8367abe80449a42294bf6eeec775ba830beeba8edc331910d68f286c6db574fcc921924bae5c9035b9d159c19fcc380bd
6
+ metadata.gz: 7e50171c354fedeff31f01c233ea2c467cfb84534b7704c6656473600925d6b72c757f5097404dfd4c80ff751462172595ae7eb6c84cdcdb72a0c0c926eaee3b
7
+ data.tar.gz: 6e8d25c8f1de368c02c96fc8702a21beed2aa5a00338af36953af42e3173d93177756adb8f6d4fe6cc0281beaa67db09d3f001a75249b322ad16bb061dea8a2e
@@ -1,5 +1,8 @@
1
1
  ## 1.6.0 [unreleased]
2
2
 
3
+ ### Bug Fixes
4
+ 1. [#42](https://github.com/influxdata/influxdb-client-ruby/pull/42): Fixed serialization of `\n`, `\r` and `\t` to Line Protocol, `=` is valid sign for measurement name
5
+
3
6
  ## 1.5.0 [2020-06-19]
4
7
 
5
8
  ### API
@@ -21,6 +21,8 @@
21
21
  module InfluxDB2
22
22
  DEFAULT_WRITE_PRECISION = WritePrecision::NANOSECOND
23
23
  ESCAPE_KEY_LIST = ['\\'.freeze, ','.freeze, ' '.freeze, '='.freeze].freeze
24
+ ESCAPE_MEASUREMENT_LIST = ['\\'.freeze, ','.freeze, ' '.freeze].freeze
25
+ REPLACE_KEY_LIST = { "\n".freeze => '\n'.freeze, "\r".freeze => '\r'.freeze, "\t".freeze => '\t'.freeze }.freeze
24
26
  ESCAPE_VALUE_LIST = ['\\'.freeze, '"'.freeze].freeze
25
27
 
26
28
  # Point defines the values that will be written to the database.
@@ -113,7 +115,7 @@ module InfluxDB2
113
115
  # @return a string representation of the point
114
116
  def to_line_protocol
115
117
  line_protocol = ''
116
- measurement = _escape_key(@name || '')
118
+ measurement = _escape_key(@name || '', ESCAPE_MEASUREMENT_LIST)
117
119
 
118
120
  line_protocol << measurement
119
121
 
@@ -161,11 +163,14 @@ module InfluxDB2
161
163
  end.reject(&:nil?).join(','.freeze)
162
164
  end
163
165
 
164
- def _escape_key(value)
166
+ def _escape_key(value, escape_list = ESCAPE_KEY_LIST)
165
167
  result = value.dup
166
- ESCAPE_KEY_LIST.each do |ch|
168
+ escape_list.each do |ch|
167
169
  result = result.gsub(ch) { "\\#{ch}" }
168
170
  end
171
+ REPLACE_KEY_LIST.keys.each do |ch|
172
+ result = result.gsub(ch) { REPLACE_KEY_LIST[ch] }
173
+ end
169
174
  result
170
175
  end
171
176
 
@@ -218,4 +218,25 @@ class PointTest < MiniTest::Test
218
218
 
219
219
  assert_equal 'h2o level=2i 123', point.to_line_protocol
220
220
  end
221
+
222
+ def test_tag_escaping
223
+ point = InfluxDB2::Point.new(name: "h\n2\ro\t_data")
224
+ .add_tag("new\nline", "new\nline")
225
+ .add_tag("carriage\rreturn", "carriage\nreturn")
226
+ .add_tag("t\tab", "t\tab")
227
+ .add_field('level', 2)
228
+
229
+ puts point.to_line_protocol
230
+
231
+ assert_equal 'h\\n2\\ro\\t_data,carriage\\rreturn=carriage\\nreturn,new\\nline=new\\nline,t\\tab=t\\tab level=2i',
232
+ point.to_line_protocol
233
+ end
234
+
235
+ def test_equal_sign_escaping
236
+ point = InfluxDB2::Point.new(name: 'h=2o')
237
+ .add_tag('l=ocation', 'e=urope')
238
+ .add_field('l=evel', 2)
239
+
240
+ assert_equal 'h=2o,l\\=ocation=e\\=urope l\\=evel=2i', point.to_line_protocol
241
+ end
221
242
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: influxdb-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0.pre.916
4
+ version: 1.6.0.pre.944
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Bednar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-19 00:00:00.000000000 Z
11
+ date: 2020-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler