Issue #15967 has been updated by kou (Kouhei Sutou).

Assignee set to kou (Kouhei Sutou)
Status changed from Third Party's Issue to Rejected

It's introduced by #10013.
Adding `CSV::Row#to_ary` may be wrong. But I couldn't remove `CSV::Row#to_ary` to avoid compatibility breakage again. 

----------------------------------------
Bug #15967: Two dimensional array which have CSV::Row object returns different result in ruby 2.3 and ruby 2.6
https://bugs.ruby-lang.org/issues/15967#change-78988

* Author: kota0919wasabi (Kota Osabe)
* Status: Rejected
* Priority: Normal
* Assignee: kou (Kouhei Sutou)
* Target version: 
* ruby -v: 2.6.0rc1
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
I posted this issue at stackoverlow below. 

https://stackoverflow.com/questions/56821461/two-dimensional-array-which-have-csvrow-object-returns-different-result-in-rub?noredirect=1#comment100198376_56821461

Two dimensional array has the element which is CSV::Row object like this.

[[csv_row_object]]

I tried to flatten this array and got different result in ruby 2.3 and 2.6.


In the case of Ruby 2.3.8
```
[1] pry(main)> RUBY_VERSION
=> "2.3.8"
[2] pry(main)> filepath = "/Users/kota/Desktop/test.csv"
=> "/Users/kota/Desktop/test.csv"
[3] pry(main)> data = fixture_file_upload(filepath, "text/csv")
=> #<Rack::Test::UploadedFile:0x00007ffc51843988
 @content_type="text/csv",
 @original_filename="test.csv",
 @tempfile=#<File:/var/folders/95/tnt69fz133z6s0b6tpxy0gqr0000gn/T/test.csv20190630-8692-11zzuh9>>
[4] pry(main)> require 'csv'
=> true
[5] pry(main)> parsed_csv = CSV.parse(data.read, headers:true, converters: nil)
=> #<CSV::Table mode:col_or_row row_count:4>
[6] pry(main)> parsed_csv[0]
=> #<CSV::Row "order_no":"10" "status":"1">
[7] pry(main)> parsed_csv[1]
=> #<CSV::Row "order_no":"20" "status":"1">
[8] pry(main)> parsed_csv[2]
=> #<CSV::Row "order_no":"30" "status":"1">
[9] pry(main)> array = [[parsed_csv[0]],[parsed_csv[1]],[parsed_csv[2]]]
=> [[#<CSV::Row "order_no":"10" "status":"1">], [#<CSV::Row "order_no":"20" "status":"1">], [#<CSV::Row "order_no":"30" "status":"1">]]
[10] pry(main)> array.flatten
=> [#<CSV::Row "order_no":"10" "status":"1">, #<CSV::Row "order_no":"20" "status":"1">, #<CSV::Row "order_no":"30" "status":"1">]
```

In the case of Ruby 2.6

```
[1] pry(main)> RUBY_VERSION
=> "2.6.0"
[2] pry(main)> filepath = "/Users/kota/Desktop/test.csv"
=> "/Users/kota/Desktop/test.csv"
[3] pry(main)> data = fixture_file_upload(filepath, "text/csv")
=> #<Rack::Test::UploadedFile:0x00007fc91d0a0828
 @content_type="text/csv",
 @original_filename="test.csv",
 @tempfile=#<File:/var/folders/95/tnt69fz133z6s0b6tpxy0gqr0000gn/T/test.csv20190630-8971-rjpb5g>>
[4] pry(main)> require 'csv'
=> true
[5] pry(main)> parsed_csv = CSV.parse(data.read, headers:true, converters: nil)
=> #<CSV::Table mode:col_or_row row_count:4>
[6] pry(main)> parsed_csv[0]
=> #<CSV::Row "order_no":"10" "status":"1">
[7] pry(main)> parsed_csv[1]
=> #<CSV::Row "order_no":"20" "status":"1">
[8] pry(main)> parsed_csv[2]
=> #<CSV::Row "order_no":"30" "status":"1">
[9] pry(main)> array = [[parsed_csv[0]],[parsed_csv[1]],[parsed_csv[2]]]
=> [[#<CSV::Row "order_no":"10" "status":"1">], [#<CSV::Row "order_no":"20" "status":"1">], [#<CSV::Row "order_no":"30" "status":"1">]]
[10] pry(main)> array.flatten
=> ["order_no", "10", "status", "1", "order_no", "20", "status", "1", "order_no", "30", "status", "1"]
```



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>