Skip to content

Commit 6fef96a

Browse files
authored
fix: query return type is Array (#124)
1 parent c2bc31d commit 6fef96a

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Bug Fixes
44
1. [#123](https://github.com/influxdata/influxdb-client-ruby/pull/123): Duplicate columns warning shows in improper situations
5+
1. [#124](https://github.com/influxdata/influxdb-client-ruby/pull/124): Query return type is `Array` instead of `Hash`
56

67
## 2.8.0 [2022-10-27]
78

lib/influxdb2/client/flux_csv_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class FluxCsvParser
6060
def initialize(response, stream: false, response_mode: InfluxDB2::FluxResponseMode::FULL)
6161
@response = response
6262
@stream = stream
63-
@tables = {}
63+
@tables = []
6464

6565
@table_index = 0
6666
@table_id = -1

test/influxdb/query_api_test.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,22 @@ def test_headers
144144
assert_requested(:post, 'http://localhost:8086/api/v2/query?org=my-org',
145145
times: 1, headers: headers)
146146
end
147+
148+
def test_query_result_type
149+
stub_request(:post, 'http://localhost:8086/api/v2/query?org=my-org')
150+
.to_return(body: SUCCESS_DATA)
151+
152+
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
153+
bucket: 'my-bucket',
154+
org: 'my-org',
155+
use_ssl: false)
156+
157+
bucket = 'my-bucket'
158+
result = client.create_query_api
159+
.query(query: "from(bucket:\"#{bucket}\") |> range(start: 1970-01-01T00:00:00.000000001Z) |> last()")
160+
161+
assert_equal 1, result.length
162+
assert_equal 4, result[0].records.length
163+
assert_equal Array, result.class
164+
end
147165
end

0 commit comments

Comments
 (0)