Skip to content

Commit

Permalink
fix: query return type is Array (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
bednar authored Nov 2, 2022
1 parent c2bc31d commit 6fef96a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

## 2.8.0 [2022-10-27]

Expand Down
2 changes: 1 addition & 1 deletion lib/influxdb2/client/flux_csv_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class FluxCsvParser
def initialize(response, stream: false, response_mode: InfluxDB2::FluxResponseMode::FULL)
@response = response
@stream = stream
@tables = {}
@tables = []

@table_index = 0
@table_id = -1
Expand Down
18 changes: 18 additions & 0 deletions test/influxdb/query_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,22 @@ def test_headers
assert_requested(:post, 'http://localhost:8086/api/v2/query?org=my-org',
times: 1, headers: headers)
end

def test_query_result_type
stub_request(:post, 'http://localhost:8086/api/v2/query?org=my-org')
.to_return(body: SUCCESS_DATA)

client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
bucket: 'my-bucket',
org: 'my-org',
use_ssl: false)

bucket = 'my-bucket'
result = client.create_query_api
.query(query: "from(bucket:\"#{bucket}\") |> range(start: 1970-01-01T00:00:00.000000001Z) |> last()")

assert_equal 1, result.length
assert_equal 4, result[0].records.length
assert_equal Array, result.class
end
end

0 comments on commit 6fef96a

Please sign in to comment.